mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use scale_factor instead of scale in find_features
* Updated all scripts.
This commit is contained in:
parent
861627d61b
commit
96e4f770c0
@ -2127,7 +2127,7 @@ static mp_obj_t py_image_find_features(uint n_args, const mp_obj_t *args, mp_map
|
|||||||
|
|
||||||
cascade_t *cascade = py_cascade_cobj(args[1]);
|
cascade_t *cascade = py_cascade_cobj(args[1]);
|
||||||
cascade->threshold = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold), 0.5f);
|
cascade->threshold = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_threshold), 0.5f);
|
||||||
cascade->scale_factor = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_scale), 1.5f);
|
cascade->scale_factor = py_helper_lookup_float(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_scale_factor), 1.5f);
|
||||||
|
|
||||||
rectangle_t arg_r;
|
rectangle_t arg_r;
|
||||||
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
||||||
|
|||||||
@ -39,7 +39,7 @@ while(True):
|
|||||||
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
||||||
# higher detection rate with more false positives. The scale value
|
# higher detection rate with more false positives. The scale value
|
||||||
# controls the matching scale allowing you to detect smaller faces.
|
# controls the matching scale allowing you to detect smaller faces.
|
||||||
faces = img.find_features(face_cascade, threshold=0.5, scale=1.5)
|
faces = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
|
|
||||||
if faces:
|
if faces:
|
||||||
diff -= 1
|
diff -= 1
|
||||||
|
|||||||
@ -43,7 +43,7 @@ while(True):
|
|||||||
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
||||||
# higher detection rate with more false positives. The scale value
|
# higher detection rate with more false positives. The scale value
|
||||||
# controls the matching scale allowing you to detect smaller faces.
|
# controls the matching scale allowing you to detect smaller faces.
|
||||||
faces = img.find_features(face_cascade, threshold=0.5, scale=1.5)
|
faces = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
|
|
||||||
if faces:
|
if faces:
|
||||||
diff -= 1
|
diff -= 1
|
||||||
|
|||||||
@ -44,7 +44,7 @@ while(True):
|
|||||||
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
# Threshold can be between 0.0 and 1.0. A higher threshold results in a
|
||||||
# higher detection rate with more false positives. The scale value
|
# higher detection rate with more false positives. The scale value
|
||||||
# controls the matching scale allowing you to detect smaller faces.
|
# controls the matching scale allowing you to detect smaller faces.
|
||||||
faces = img.find_features(face_cascade, threshold=0.5, scale=1.5)
|
faces = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
|
|
||||||
if faces:
|
if faces:
|
||||||
diff -= 1
|
diff -= 1
|
||||||
|
|||||||
@ -40,7 +40,7 @@ while (True):
|
|||||||
# Find objects.
|
# Find objects.
|
||||||
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
||||||
# Higher threshold results in a higher detection rate, with more false positives.
|
# Higher threshold results in a higher detection rate, with more false positives.
|
||||||
objects = img.find_features(face_cascade, threshold=0.75, scale=1.35)
|
objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.35)
|
||||||
|
|
||||||
# Draw objects
|
# Draw objects
|
||||||
for r in objects:
|
for r in objects:
|
||||||
|
|||||||
@ -50,7 +50,7 @@ while (kpts1 == None):
|
|||||||
img = sensor.snapshot()
|
img = sensor.snapshot()
|
||||||
img.draw_string(0, 0, "Looking for a face...")
|
img.draw_string(0, 0, "Looking for a face...")
|
||||||
# Find faces
|
# Find faces
|
||||||
objects = img.find_features(face_cascade, threshold=0.5, scale=1.5)
|
objects = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
if objects:
|
if objects:
|
||||||
# Expand the ROI by 11 pixels in each direction (half the pattern scale)
|
# Expand the ROI by 11 pixels in each direction (half the pattern scale)
|
||||||
face = (objects[0][0]-22, objects[0][1]-22,objects[0][2]+22*2, objects[0][3]+22*2)
|
face = (objects[0][0]-22, objects[0][1]-22,objects[0][2]+22*2, objects[0][3]+22*2)
|
||||||
|
|||||||
@ -33,14 +33,14 @@ while (True):
|
|||||||
# Find a face !
|
# Find a face !
|
||||||
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
||||||
# Higher threshold results in a higher detection rate, with more false positives.
|
# Higher threshold results in a higher detection rate, with more false positives.
|
||||||
objects = img.find_features(face_cascade, threshold=0.5, scale=1.5)
|
objects = img.find_features(face_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
|
|
||||||
# Draw faces
|
# Draw faces
|
||||||
for face in objects:
|
for face in objects:
|
||||||
img.draw_rectangle(face)
|
img.draw_rectangle(face)
|
||||||
# Now find eyes within each face.
|
# Now find eyes within each face.
|
||||||
# Note: Use a higher threshold here (more detections) and lower scale (to find small objects)
|
# Note: Use a higher threshold here (more detections) and lower scale (to find small objects)
|
||||||
eyes = img.find_features(eyes_cascade, threshold=0.5, scale=1.2, roi=face)
|
eyes = img.find_features(eyes_cascade, threshold=0.5, scale_factor=1.2, roi=face)
|
||||||
for e in eyes:
|
for e in eyes:
|
||||||
img.draw_rectangle(e)
|
img.draw_rectangle(e)
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ while (True):
|
|||||||
# Find eyes !
|
# Find eyes !
|
||||||
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
# Note: Lower scale factor scales-down the image more and detects smaller objects.
|
||||||
# Higher threshold results in a higher detection rate, with more false positives.
|
# Higher threshold results in a higher detection rate, with more false positives.
|
||||||
eyes = img.find_features(eyes_cascade, threshold=0.5, scale=1.5)
|
eyes = img.find_features(eyes_cascade, threshold=0.5, scale_factor=1.5)
|
||||||
|
|
||||||
# Find iris
|
# Find iris
|
||||||
for e in eyes:
|
for e in eyes:
|
||||||
|
|||||||
@ -38,7 +38,7 @@ while (True):
|
|||||||
clock.tick()
|
clock.tick()
|
||||||
img = sensor.snapshot()
|
img = sensor.snapshot()
|
||||||
|
|
||||||
objects = img.find_features(face_cascade, threshold=0.5, scale=1.25)
|
objects = img.find_features(face_cascade, threshold=0.5, scale_factor=1.25)
|
||||||
if objects:
|
if objects:
|
||||||
face = objects[0]
|
face = objects[0]
|
||||||
d1 = img.find_lbp(face)
|
d1 = img.find_lbp(face)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user