mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Fix finding small apriltags.
This commit is contained in:
parent
6efc8b78e6
commit
157a469ec3
@ -46,10 +46,10 @@ while(True):
|
||||
|
||||
for blob in img.find_blobs([thresholds], pixels_threshold=100, area_threshold=100, merge=True):
|
||||
# Next we look for a tag in an ROI that's bigger than the blob.
|
||||
w = min(max(int(blob.w() * 1.2), 20), 100) # Not too small, not too big.
|
||||
h = min(max(int(blob.h() * 1.2), 20), 100) # Not too small, not too big.
|
||||
x = min(max(int(blob.x() - (w * 0.1)), 0), img.width()-1)
|
||||
y = min(max(int(blob.y() - (h * 0.1)), 0), img.height()-1)
|
||||
w = min(max(int(blob.w() * 1.2), 10), 160) # Not too small, not too big.
|
||||
h = min(max(int(blob.h() * 1.2), 10), 160) # Not too small, not too big.
|
||||
x = min(max(int(blob.x() + (blob.w()/4) - (w * 0.1)), 0), img.width()-1)
|
||||
y = min(max(int(blob.y() + (blob.h()/4) - (h * 0.1)), 0), img.height()-1)
|
||||
|
||||
box_list.append((x, y, w, h)) # We'll draw these later.
|
||||
|
||||
@ -57,7 +57,7 @@ while(True):
|
||||
# But, if it does we handle it...
|
||||
try:
|
||||
tag_list.extend(img.find_apriltags(roi=(x,y,w,h), families=tag_families))
|
||||
except (MemoryError, OSError): # Don't catch all exceptions otherwise you can't stop the script.
|
||||
except (MemoryError): # Don't catch all exceptions otherwise you can't stop the script.
|
||||
pass
|
||||
|
||||
for b in box_list:
|
||||
|
||||
@ -4528,13 +4528,13 @@ static const mp_obj_type_t py_apriltag_type = {
|
||||
static mp_obj_t py_image_find_apriltags(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_helper_arg_to_image_mutable(args[0]);
|
||||
PY_ASSERT_TRUE_MSG((arg_img->w * arg_img->h) < 65536, "The maximum supported resolution for find_apriltags() is 64K pixels.");
|
||||
if ((arg_img->w < 4) || (arg_img->h < 4)) {
|
||||
return mp_obj_new_list(0, NULL);
|
||||
}
|
||||
|
||||
rectangle_t roi;
|
||||
py_helper_keyword_rectangle_roi(arg_img, n_args, args, 1, kw_args, &roi);
|
||||
PY_ASSERT_TRUE_MSG((roi.w * roi.h) < 65536, "The maximum supported resolution for find_apriltags() is < 64K pixels.");
|
||||
if ((roi.w < 4) || (roi.h < 4)) {
|
||||
return mp_obj_new_list(0, NULL);
|
||||
}
|
||||
|
||||
apriltag_families_t families = py_helper_keyword_int(n_args, args, 2, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_families), TAG36H11);
|
||||
// 2.8mm Focal Length w/ OV7725 sensor for reference.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user