标签:文件 目标 检测 tco image 之间 nbsp import append
车牌检测
2.图片人脸检测
# 人脸识别,正则分析 import cv2 import numpy as np from PIL import Image #pip install PIL #pip install opencv-python #pip install dlib dector=cv2.CascadeClassifier() ret=dector.load(‘haarcascade_frontalface_alt_tree.xml‘) if not ret: print(‘未找到级联表文件:plate_cascade.xml‘) exit() img=cv2.imread(‘e:/85n.jpg‘) if img is None: print(‘文件不存在‘) exit() #彩色转成灰度图像 gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # 正则化,亮度调成均匀的 gray=np.uint8(gray/gray.ptp()*255) boxs=dector.detectMultiScale(gray,1.015,1) platelist=[] for box in boxs: x,y,w,h=box g=img[y:y+h,x:x+w,:] platelist.append(g) linew=h//100+1 cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),linew) gimg=cv2.cvtColor(img,cv2.COLOR_BGR2RGB) image=Image.fromarray(gimg) image.show() image.close()
3.视频人脸检测
# 人脸识别,正则分析 import cv2 import numpy as np from PIL import Image #pip install PIL #pip install opencv-python #pip install dlib dector=cv2.CascadeClassifier() ret=dector.load(‘haarcascade_frontalface_alt_tree.xml‘) if not ret: print(‘未找到级联表文件:plate_cascade.xml‘) exit() img=cv2.imread(‘e:/85n.jpg‘) if img is None: print(‘文件不存在‘) exit() #彩色转成灰度图像 gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) # 正则化,亮度调成均匀的 gray=np.uint8(gray/gray.ptp()*255) boxs=dector.detectMultiScale(gray,1.015,1) platelist=[] for box in boxs: x,y,w,h=box g=img[y:y+h,x:x+w,:] platelist.append(g) linew=h//100+1 cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),linew) gimg=cv2.cvtColor(img,cv2.COLOR_BGR2RGB) image=Image.fromarray(gimg) image.show() image.close()
标签:文件 目标 检测 tco image 之间 nbsp import append
原文地址:https://www.cnblogs.com/hellangels333/p/9042967.html