summaryrefslogtreecommitdiff
path: root/megapixels/commands/cv/face_roi.py
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2019-01-03 12:51:31 +0100
committeradamhrv <adam@ahprojects.com>2019-01-03 12:51:31 +0100
commitf215db6e84071077082d14f8366ae1cf1aea500f (patch)
tree33e4573eb618f21685809cf567fdf196ff673a91 /megapixels/commands/cv/face_roi.py
parent5340bee951c18910fd764241945f1f136b5a22b4 (diff)
fix roi index, clean up pose, roi, records, vector
Diffstat (limited to 'megapixels/commands/cv/face_roi.py')
-rw-r--r--megapixels/commands/cv/face_roi.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/megapixels/commands/cv/face_roi.py b/megapixels/commands/cv/face_roi.py
index a08566a8..a09a1ce0 100644
--- a/megapixels/commands/cv/face_roi.py
+++ b/megapixels/commands/cv/face_roi.py
@@ -20,7 +20,7 @@ color_filters = {'color': 1, 'gray': 2, 'all': 3}
help='Override enum media directory')
@click.option('--data_store', 'opt_data_store',
type=cfg.DataStoreVar,
- default=click_utils.get_default(types.DataStore.SSD),
+ default=click_utils.get_default(types.DataStore.HDD),
show_default=True,
help=click_utils.show_help(types.Dataset))
@click.option('--dataset', 'opt_dataset',
@@ -52,10 +52,12 @@ color_filters = {'color': 1, 'gray': 2, 'all': 3}
help='Filter to keep color or grayscale images (color = keep color')
@click.option('--largest/--all-faces', 'opt_largest', is_flag=True, default=True,
help='Only keep largest face')
+@click.option('--zone', 'opt_zone', default=(0.0, 0.0), type=(float, float),
+ help='Face center must be located within zone region (0.5 = half width/height)')
@click.pass_context
def cli(ctx, opt_fp_in, opt_dir_media, opt_fp_out, opt_data_store, opt_dataset, opt_size, opt_detector_type,
opt_gpu, opt_conf_thresh, opt_pyramids, opt_slice, opt_display, opt_force, opt_color_filter,
- opt_largest):
+ opt_largest, opt_zone):
"""Converts frames with faces to CSV of ROIs"""
import sys
@@ -130,7 +132,7 @@ def cli(ctx, opt_fp_in, opt_dir_media, opt_fp_out, opt_data_store, opt_dataset,
continue
try:
- bboxes = detector.detect(im, size=opt_size, pyramids=opt_pyramids, largest=opt_largest)
+ bboxes = detector.detect(im, size=opt_size, pyramids=opt_pyramids, largest=opt_largest, zone=opt_zone)
except Exception as e:
log.error('could not detect: {}'.format(fp_im))
log.error('{}'.format(e))
@@ -142,17 +144,17 @@ def cli(ctx, opt_fp_in, opt_dir_media, opt_fp_out, opt_data_store, opt_dataset,
'x': bbox.x,
'y': bbox.y,
'w': bbox.w,
- 'h': bbox.h,
- 'image_width': im.shape[1],
- 'image_height': im.shape[0]}
+ 'h': bbox.h
+ }
data.append(roi)
+ if len(bboxes) == 0:
+ log.warn(f'no faces in: {fp_im}')
# debug display
if opt_display and len(bboxes):
im_md = im_utils.resize(im, width=min(1200, opt_size[0]))
for bbox in bboxes:
bbox_dim = bbox.to_dim(im_md.shape[:2][::-1])
- log.debug(f'bbox: {bbox_dim}')
cv.rectangle(im_md, bbox_dim.pt_tl, bbox_dim.pt_br, (0,255,0), 3)
cv.imshow('', im_md)
while True:
@@ -168,4 +170,7 @@ def cli(ctx, opt_fp_in, opt_dir_media, opt_fp_out, opt_data_store, opt_dataset,
file_utils.mkdirs(fp_out)
df = pd.DataFrame.from_dict(data)
df.index.name = 'index'
- df.to_csv(fp_out) \ No newline at end of file
+ df.to_csv(fp_out)
+ # save script
+ cmd_line = ' '.join(sys.argv)
+ file_utils.write_text(cmd_line, '{}.sh'.format(fp_out)) \ No newline at end of file