summaryrefslogtreecommitdiff
path: root/megapixels/commands/cv/face_pose.py
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-01-17 15:11:47 +0100
committerJules Laplace <julescarbon@gmail.com>2019-01-17 15:11:47 +0100
commit85ae432fb6c6c17292b319bca068e46a4ea81eb3 (patch)
tree4d0270fac0fdc7c1c1333af9c4bb82c6eb00669d /megapixels/commands/cv/face_pose.py
parentc293006ba43944ffeb4dcab17b2256f3a5491a36 (diff)
parent03ad11fb2a3dcd425d50167b15d72d4e0ef536a2 (diff)
Merge branch 'master' of github.com:adamhrv/megapixels_dev
Diffstat (limited to 'megapixels/commands/cv/face_pose.py')
-rw-r--r--megapixels/commands/cv/face_pose.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/megapixels/commands/cv/face_pose.py b/megapixels/commands/cv/face_pose.py
index 70ea1f30..cb7ec56c 100644
--- a/megapixels/commands/cv/face_pose.py
+++ b/megapixels/commands/cv/face_pose.py
@@ -92,7 +92,7 @@ def cli(ctx, opt_fp_in, opt_fp_out, opt_dir_media, opt_data_store, opt_dataset,
# load data
fp_record = data_store.metadata(types.Metadata.FILE_RECORD)
- df_record = pd.read_csv(fp_record).set_index('index')
+ df_record = pd.read_csv(fp_record, dtype=cfg.FILE_RECORD_DTYPES).set_index('index')
# load ROI data
fp_roi = data_store.metadata(types.Metadata.FACE_ROI)
df_roi = pd.read_csv(fp_roi).set_index('index')
@@ -125,10 +125,11 @@ def cli(ctx, opt_fp_in, opt_fp_out, opt_dir_media, opt_data_store, opt_dataset,
x, y, w, h = df_img.x, df_img.y, df_img.w, df_img.h
#dim = (file_record.width, file_record.height)
dim = im_resized.shape[:2][::-1]
- bbox = BBox.from_xywh(x, y, w, h).to_dim(dim)
+ bbox_norm = BBox.from_xywh(x, y, w, h)
+ bbox_dim = bbox_norm.to_dim(dim)
# get pose
- landmarks = face_landmarks.landmarks(im_resized, bbox)
+ landmarks = face_landmarks.landmarks(im_resized, bbox_norm)
pose_data = face_pose.pose(landmarks, dim)
#pose_degrees = pose_data['degrees'] # only keep the degrees data
#pose_degrees['points_nose'] = pose_data
@@ -143,8 +144,8 @@ def cli(ctx, opt_fp_in, opt_fp_out, opt_dir_media, opt_data_store, opt_dataset,
# add image index and append to result CSV data
pose_data['roi_index'] = roi_index
for k, v in pose_data['points'].items():
- pose_data[f'point_{k}_x'] = v[0][0] / dim[0]
- pose_data[f'point_{k}_y'] = v[0][1] / dim[1]
+ pose_data[f'point_{k}_x'] = v[0] / dim[0]
+ pose_data[f'point_{k}_y'] = v[1] / dim[1]
# rearrange data structure for DataFrame
pose_data.pop('points')