我想保存/写不模糊的照片。如何将下面两个代码组合起来?在
import cv2
image = cv2.imread('./facesData/ID.jpg')
cv2.Laplacian(image, cv2.CV_64F).var()
while 1:
ret, img = cap.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.2, 8)
for x,y,w,h in faces:
sampleN = sampleN + 1
cv2.imwrite("./facesData/ID." + str(sampleN) + ".jpg", gray[y:y+h, x:x+w])
cv2.rectangle(img, (x,y), (x+w,y+h), (255,0,0), 2)
cv2.waitKey(2)
cv2.imshow('user', img)
cv2.waitKey(1)
if sampleN > 20:
break
cap.release()
cv2.destroyAllWindows()
这会将模糊图像移到一个单独的文件夹(code source)。在
要使用它,请设置文件夹结构,如:
最后,欢迎使用Stackoverflow:)来最大限度地提高您使用这个网站的价值(并帮助我们帮助您)尝试一下these tips
相关问题 更多 >
编程相关推荐