summaryrefslogtreecommitdiff
path: root/megapixels/commands/cv/face_pose.py
diff options
context:
space:
mode:
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..75db603b 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={'fn':str}).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')