My H7 Plus was just updated to firmware 4.5.5, and code that previously worked quite accurately is now showing face counts of 2 when there is only a single face in the image. Key parts of the code below.
# Reset sensor
sensor.reset()
sensor.set_contrast(3)
sensor.set_gainceiling(16)
# HQVGA and GRAYSCALE are the best for face tracking.
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framebuffers(1)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
faceCount = 0;
# The set of angles to rotate the raw image and determine the best orientation for face detection
angles = [-45, 0, 45]
rimg = sensor.alloc_extra_fb(240,160,sensor.GRAYSCALE)
totalFaceCount = 0
while (True):
# Capture snapshot
img = sensor.snapshot()
img.gamma(gamma=1.0,contrast=1.5,brightness=0.0)
maxFaceCount = 0
# Account for tilted faces or a tilted camera
for angle in angles:
rimg.replace(img)
rimg.rotation_corr(x_rotation=0.0, y_rotation=0.0, z_rotation=angle)
# Find objects.
objects = rimg.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
newFaceCount = len(objects)
if(faceCount != newFaceCount)
faceCount = newFaceCount
print(faceCount)
Hi Rick,
We haven’t changed anything with the functions you are mentioning recently.
It is not the case though that behavior may stay exactly the same if we just something or improve a feature.
Can you determine where the script is having issues? When does it detect extra faces from what it did previously?
…
I can test your code in about 12 hours and report my own results.
Hi! I’m as surprised as you are. The code would (correctly) always return either a zero (0) or one (1) value when running it - and just recently after the firmware update it started returning two (2) intermittently, even with a full frontal face image with a single face (mine!) in it. Let me know if there’s any suggestions for code changes or configuration/settings and I’ll be happy to test on my end also. Thank you!
Hi Rick,
I ran the code on my OpenMV Cam H7 Plus with the latest firmware and I just get 0/1 printed alternating over and over again. You are probably experiencing a different issue.
import sensor
import image
# Reset sensor
sensor.reset()
sensor.set_contrast(3)
sensor.set_gainceiling(16)
# HQVGA and GRAYSCALE are the best for face tracking.
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framebuffers(1)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)
faceCount = 0;
# The set of angles to rotate the raw image and determine the best orientation for face detection
angles = [-45, 0, 45]
rimg = sensor.alloc_extra_fb(240,160,sensor.GRAYSCALE)
totalFaceCount = 0
while (True):
# Capture snapshot
img = sensor.snapshot()
img.gamma(gamma=1.0,contrast=1.5,brightness=0.0)
maxFaceCount = 0
# Account for tilted faces or a tilted camera
for angle in angles:
rimg.replace(img)
rimg.rotation_corr(x_rotation=0.0, y_rotation=0.0, z_rotation=angle)
# Find objects.
objects = rimg.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
newFaceCount = len(objects)
if(faceCount != newFaceCount):
faceCount = newFaceCount
print(faceCount)