Skip to content

Commit 7843b74

Browse files
committed
update detectMultiScale
1 parent 53a5492 commit 7843b74

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

ch02-安装OpenCV/最简单-使用pip安装opencv-python和opencv-contrib-python/test_opencv_contrib_python.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
# cv2.imshow('gray', gray)
2626

2727

28-
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
28+
# faces = face_cascade.detectMultiScale(gray, 1.3, 5)
29+
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
2930
print("Detected ", len(faces), " face")
3031

3132
plt.ion()
@@ -40,11 +41,11 @@
4041
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
4142
plt.show()
4243
# cv2.waitKey(500)
43-
plt.pause(2)
44+
plt.pause(1)
4445
# sleep(2)
4546
# sleep(2)
4647
# cv2.waitKey(500)
47-
plt.pause(2)
48+
plt.pause(1)
4849

4950
# plt.show()
5051
plt.show(block=True)

ch51-对象检测-使用Haar分类器进行面部检测/51.CascadeClassifier级联分类器.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
# have to retain it.
4141
# minSize – Minimum possible object size. Objects smaller than that are ignored.
4242
# maxSize – Maximum possible object size. Objects larger than that are ignored.
43-
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
43+
# faces = face_cascade.detectMultiScale(gray, 1.3, 5)
44+
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)#改进
4445
print("Detected ", len(faces), " face")
4546

4647
for (x, y, w, h) in faces:

0 commit comments

Comments
 (0)