diff --git a/demo_multipose.py b/demo_multipose.py index 25b16ca..5c83fe2 100644 --- a/demo_multipose.py +++ b/demo_multipose.py @@ -10,6 +10,8 @@ import tensorflow as tf import tensorflow_hub as tfhub +from pose_helper import draw_debug_multi_person + def get_args(): parser = argparse.ArgumentParser() @@ -103,6 +105,8 @@ def main(): module = tfhub.load(model_url) model = module.signatures['serving_default'] + cv.namedWindow('MoveNet(multipose) Demo', cv.WINDOW_NORMAL) + while True: start_time = time.time() @@ -124,7 +128,7 @@ def main(): elapsed_time = time.time() - start_time # デバッグ描画 - debug_image = draw_debug( + debug_image = draw_debug_multi_person( debug_image, elapsed_time, keypoint_score_th, @@ -146,191 +150,5 @@ def main(): cv.destroyAllWindows() -def draw_debug( - image, - elapsed_time, - keypoint_score_th, - keypoints_list, - scores_list, - bbox_score_th, - bbox_list, -): - debug_image = copy.deepcopy(image) - - # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 - # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 - for keypoints, scores in zip(keypoints_list, scores_list): - # Line:鼻 → 左目 - index01, index02 = 0, 1 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右目 - index01, index02 = 0, 2 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左目 → 左耳 - index01, index02 = 1, 3 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右目 → 右耳 - index01, index02 = 2, 4 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 左肩 - index01, index02 = 0, 5 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右肩 - index01, index02 = 0, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 右肩 - index01, index02 = 5, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左肘 - index01, index02 = 5, 7 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肘 → 左手首 - index01, index02 = 7, 9 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右肘 - index01, index02 = 6, 8 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肘 → 右手首 - index01, index02 = 8, 10 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 右股関節 - index01, index02 = 11, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左股関節 - index01, index02 = 5, 11 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 左ひざ - index01, index02 = 11, 13 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左ひざ → 左足首 - index01, index02 = 13, 15 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右股関節 - index01, index02 = 6, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右股関節 → 右ひざ - index01, index02 = 12, 14 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右ひざ → 右足首 - index01, index02 = 14, 16 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - - # Circle:各点 - for keypoint, score in zip(keypoints, scores): - if score > keypoint_score_th: - cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) - cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) - - # バウンディングボックス - for bbox in bbox_list: - if bbox[4] > bbox_score_th: - cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), - (255, 255, 255), 4) - cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), - (0, 0, 0), 2) - - # 処理時間 - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, - cv.LINE_AA) - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, - cv.LINE_AA) - - return debug_image - - if __name__ == '__main__': main() \ No newline at end of file diff --git a/demo_multipose_onnx.py b/demo_multipose_onnx.py index 1a0b65f..63346f7 100644 --- a/demo_multipose_onnx.py +++ b/demo_multipose_onnx.py @@ -10,6 +10,7 @@ import onnxruntime import tensorflow as tf +from pose_helper import draw_debug_multi_person def get_args(): parser = argparse.ArgumentParser() @@ -103,6 +104,7 @@ def main(): input_size = 256 onnx_session = onnxruntime.InferenceSession(model_path) + cv.namedWindow('MoveNet(multipose) Demo', cv.WINDOW_NORMAL) while True: start_time = time.time() @@ -125,7 +127,7 @@ def main(): elapsed_time = time.time() - start_time # デバッグ描画 - debug_image = draw_debug( + debug_image = draw_debug_multi_person( debug_image, elapsed_time, keypoint_score_th, @@ -147,191 +149,5 @@ def main(): cv.destroyAllWindows() -def draw_debug( - image, - elapsed_time, - keypoint_score_th, - keypoints_list, - scores_list, - bbox_score_th, - bbox_list, -): - debug_image = copy.deepcopy(image) - - # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 - # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 - for keypoints, scores in zip(keypoints_list, scores_list): - # Line:鼻 → 左目 - index01, index02 = 0, 1 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右目 - index01, index02 = 0, 2 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左目 → 左耳 - index01, index02 = 1, 3 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右目 → 右耳 - index01, index02 = 2, 4 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 左肩 - index01, index02 = 0, 5 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右肩 - index01, index02 = 0, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 右肩 - index01, index02 = 5, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左肘 - index01, index02 = 5, 7 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肘 → 左手首 - index01, index02 = 7, 9 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右肘 - index01, index02 = 6, 8 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肘 → 右手首 - index01, index02 = 8, 10 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 右股関節 - index01, index02 = 11, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左股関節 - index01, index02 = 5, 11 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 左ひざ - index01, index02 = 11, 13 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左ひざ → 左足首 - index01, index02 = 13, 15 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右股関節 - index01, index02 = 6, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右股関節 → 右ひざ - index01, index02 = 12, 14 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右ひざ → 右足首 - index01, index02 = 14, 16 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - - # Circle:各点 - for keypoint, score in zip(keypoints, scores): - if score > keypoint_score_th: - cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) - cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) - - # バウンディングボックス - for bbox in bbox_list: - if bbox[4] > bbox_score_th: - cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), - (255, 255, 255), 4) - cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), - (0, 0, 0), 2) - - # 処理時間 - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, - cv.LINE_AA) - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, - cv.LINE_AA) - - return debug_image - - if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/demo_singlepose.py b/demo_singlepose.py index 70f655e..6d78556 100644 --- a/demo_singlepose.py +++ b/demo_singlepose.py @@ -10,6 +10,8 @@ import tensorflow as tf import tensorflow_hub as tfhub +from pose_helper import draw_debug + def get_args(): parser = argparse.ArgumentParser() @@ -92,6 +94,8 @@ def main(): module = tfhub.load(model_url) model = module.signatures['serving_default'] + cv.namedWindow('MoveNet(singlepose) Demo', cv.WINDOW_NORMAL) + while True: start_time = time.time() @@ -133,180 +137,5 @@ def main(): cv.destroyAllWindows() -def draw_debug( - image, - elapsed_time, - keypoint_score_th, - keypoints, - scores, -): - debug_image = copy.deepcopy(image) - - # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 - # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 - # Line:鼻 → 左目 - index01, index02 = 0, 1 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右目 - index01, index02 = 0, 2 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左目 → 左耳 - index01, index02 = 1, 3 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右目 → 右耳 - index01, index02 = 2, 4 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 左肩 - index01, index02 = 0, 5 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右肩 - index01, index02 = 0, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 右肩 - index01, index02 = 5, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左肘 - index01, index02 = 5, 7 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肘 → 左手首 - index01, index02 = 7, 9 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右肘 - index01, index02 = 6, 8 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肘 → 右手首 - index01, index02 = 8, 10 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 右股関節 - index01, index02 = 11, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左股関節 - index01, index02 = 5, 11 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 左ひざ - index01, index02 = 11, 13 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左ひざ → 左足首 - index01, index02 = 13, 15 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右股関節 - index01, index02 = 6, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右股関節 → 右ひざ - index01, index02 = 12, 14 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右ひざ → 右足首 - index01, index02 = 14, 16 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - - # Circle:各点 - for keypoint, score in zip(keypoints, scores): - if score > keypoint_score_th: - cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) - cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) - - # 処理時間 - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, - cv.LINE_AA) - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, - cv.LINE_AA) - - return debug_image - - if __name__ == '__main__': main() \ No newline at end of file diff --git a/demo_singlepose_onnx.py b/demo_singlepose_onnx.py index 4f5e16c..10b0771 100644 --- a/demo_singlepose_onnx.py +++ b/demo_singlepose_onnx.py @@ -10,6 +10,7 @@ import onnxruntime import tensorflow as tf +from pose_helper import draw_debug def get_args(): parser = argparse.ArgumentParser() @@ -93,6 +94,8 @@ def main(): onnx_session = onnxruntime.InferenceSession(model_path) + cv.namedWindow('MoveNet(singlepose) Demo', cv.WINDOW_NORMAL) + while True: start_time = time.time() @@ -134,180 +137,5 @@ def main(): cv.destroyAllWindows() -def draw_debug( - image, - elapsed_time, - keypoint_score_th, - keypoints, - scores, -): - debug_image = copy.deepcopy(image) - - # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 - # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 - # Line:鼻 → 左目 - index01, index02 = 0, 1 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右目 - index01, index02 = 0, 2 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左目 → 左耳 - index01, index02 = 1, 3 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右目 → 右耳 - index01, index02 = 2, 4 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 左肩 - index01, index02 = 0, 5 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右肩 - index01, index02 = 0, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 右肩 - index01, index02 = 5, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左肘 - index01, index02 = 5, 7 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肘 → 左手首 - index01, index02 = 7, 9 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右肘 - index01, index02 = 6, 8 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肘 → 右手首 - index01, index02 = 8, 10 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 右股関節 - index01, index02 = 11, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左股関節 - index01, index02 = 5, 11 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 左ひざ - index01, index02 = 11, 13 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左ひざ → 左足首 - index01, index02 = 13, 15 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右股関節 - index01, index02 = 6, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右股関節 → 右ひざ - index01, index02 = 12, 14 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右ひざ → 右足首 - index01, index02 = 14, 16 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - - # Circle:各点 - for keypoint, score in zip(keypoints, scores): - if score > keypoint_score_th: - cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) - cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) - - # 処理時間 - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, - cv.LINE_AA) - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, - cv.LINE_AA) - - return debug_image - - if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/demo_singlepose_tflite.py b/demo_singlepose_tflite.py index c8aaee8..376d708 100644 --- a/demo_singlepose_tflite.py +++ b/demo_singlepose_tflite.py @@ -9,6 +9,8 @@ import numpy as np import tensorflow as tf +from pose_helper import draw_debug + def get_args(): parser = argparse.ArgumentParser() @@ -100,6 +102,7 @@ def main(): interpreter = tf.lite.Interpreter(model_path=model_path) interpreter.allocate_tensors() + cv.namedWindow('MoveNet(singlepose) Demo', cv.WINDOW_NORMAL) while True: start_time = time.time() @@ -141,180 +144,5 @@ def main(): cv.destroyAllWindows() -def draw_debug( - image, - elapsed_time, - keypoint_score_th, - keypoints, - scores, -): - debug_image = copy.deepcopy(image) - - # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 - # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 - # Line:鼻 → 左目 - index01, index02 = 0, 1 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右目 - index01, index02 = 0, 2 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左目 → 左耳 - index01, index02 = 1, 3 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右目 → 右耳 - index01, index02 = 2, 4 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 左肩 - index01, index02 = 0, 5 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:鼻 → 右肩 - index01, index02 = 0, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 右肩 - index01, index02 = 5, 6 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左肘 - index01, index02 = 5, 7 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肘 → 左手首 - index01, index02 = 7, 9 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右肘 - index01, index02 = 6, 8 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肘 → 右手首 - index01, index02 = 8, 10 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 右股関節 - index01, index02 = 11, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左肩 → 左股関節 - index01, index02 = 5, 11 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左股関節 → 左ひざ - index01, index02 = 11, 13 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:左ひざ → 左足首 - index01, index02 = 13, 15 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右肩 → 右股関節 - index01, index02 = 6, 12 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右股関節 → 右ひざ - index01, index02 = 12, 14 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - # Line:右ひざ → 右足首 - index01, index02 = 14, 16 - if scores[index01] > keypoint_score_th and scores[ - index02] > keypoint_score_th: - point01 = keypoints[index01] - point02 = keypoints[index02] - cv.line(debug_image, point01, point02, (255, 255, 255), 4) - cv.line(debug_image, point01, point02, (0, 0, 0), 2) - - # Circle:各点 - for keypoint, score in zip(keypoints, scores): - if score > keypoint_score_th: - cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) - cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) - - # 処理時間 - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, - cv.LINE_AA) - cv.putText(debug_image, - "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", - (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, - cv.LINE_AA) - - return debug_image - - if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/pose_helper.py b/pose_helper.py new file mode 100644 index 0000000..14d3469 --- /dev/null +++ b/pose_helper.py @@ -0,0 +1,132 @@ +import copy +from typing import List + +import cv2 as cv +import numpy as np + + +def draw_debug( + image: np.ndarray, + elapsed_time: float, + keypoint_score_th: float, + keypoints: List, + scores: List[float], +) -> np.ndarray: + debug_image = copy.deepcopy(image) + + # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 + # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 + for index01, index02 in ((0, 1), # Line:鼻 → 左目 + (0, 2), # Line:鼻 → 右目 + (1, 3), # Line:左目 → 左耳 + (2, 4), # Line:右目 → 右耳 + (0, 5), # Line:鼻 → 左肩 + (0, 6), # Line:鼻 → 右肩 + (5, 6), # Line:左肩 → 右肩 + (5, 7), # Line:左肩 → 左肘 + (7, 9), # Line:左肘 → 左手首 + (6, 8), # Line:右肩 → 右肘 + (8, 10), # Line:右肘 → 右手首 + (11, 12), # Line:左股関節 → 右股関節 + (5, 11), # Line:左肩 → 左股関節 + (11, 13), # Line:左股関節 → 左ひざ + (13, 15), # Line:左ひざ → 左足首 + (6, 12), # Line:右肩 → 右股関節 + (12, 14), # Line:右股関節 → 右ひざ + (14, 16), # Line:右ひざ → 右足首 + ): + if is_good_keypoints(index01, index02, keypoint_score_th, scores): + draw_keypoints(debug_image, index01, index02, keypoints) + + # Circle:各点 + for keypoint, score in zip(keypoints, scores): + if score > keypoint_score_th: + cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) + cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) + + # 処理時間 + cv.putText(debug_image, + "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", + (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, + cv.LINE_AA) + cv.putText(debug_image, + "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", + (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, + cv.LINE_AA) + + return debug_image + + +def is_good_keypoints(index01: int, index02: int, keypoint_score_th: float, scores: List[float]) -> bool: + return scores[index01] > keypoint_score_th and scores[ + index02] > keypoint_score_th + + +def draw_keypoints(debug_image: np.ndarray, index01: int, index02: int, keypoints: List): + point01 = keypoints[index01] + point02 = keypoints[index02] + cv.line(debug_image, point01, point02, (255, 255, 255), 4) + cv.line(debug_image, point01, point02, (0, 0, 0), 2) + + +def draw_debug_multi_person( + image: np.ndarray, + elapsed_time: float, + keypoint_score_th: float, + keypoints_list: List, + scores_list: List[float], + bbox_score_th: float, + bbox_list: List, +) -> np.ndarray: + debug_image = copy.deepcopy(image) + + # 0:鼻 1:左目 2:右目 3:左耳 4:右耳 5:左肩 6:右肩 7:左肘 8:右肘 # 9:左手首 + # 10:右手首 11:左股関節 12:右股関節 13:左ひざ 14:右ひざ 15:左足首 16:右足首 + for keypoints, scores in zip(keypoints_list, scores_list): + for index01, index02 in ((0, 1), # Line:鼻 → 左目 + (0, 2), # Line:鼻 → 右目 + (1, 3), # Line:左目 → 左耳 + (2, 4), # Line:右目 → 右耳 + (0, 5), # Line:鼻 → 左肩 + (0, 6), # Line:鼻 → 右肩 + (5, 6), # Line:左肩 → 右肩 + (5, 7), # Line:左肩 → 左肘 + (7, 9), # Line:左肘 → 左手首 + (6, 8), # Line:右肩 → 右肘 + (8, 10), # Line:右肘 → 右手首 + (11, 12), # Line:左股関節 → 右股関節 + (5, 11), # Line:左肩 → 左股関節 + (11, 13), # Line:左股関節 → 左ひざ + (13, 15), # Line:左ひざ → 左足首 + (6, 12), # Line:右肩 → 右股関節 + (12, 14), # Line:右股関節 → 右ひざ + (14, 16), # Line:右ひざ → 右足首 + ): + if is_good_keypoints(index01, index02, keypoint_score_th, scores): + draw_keypoints(debug_image, index01, index02, keypoints) + + # Circle:各点 + for keypoint, score in zip(keypoints, scores): + if score > keypoint_score_th: + cv.circle(debug_image, keypoint, 6, (255, 255, 255), -1) + cv.circle(debug_image, keypoint, 3, (0, 0, 0), -1) + + # バウンディングボックス + for bbox in bbox_list: + if bbox[4] > bbox_score_th: + cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), + (255, 255, 255), 4) + cv.rectangle(debug_image, (bbox[0], bbox[1]), (bbox[2], bbox[3]), + (0, 0, 0), 2) + + # 処理時間 + cv.putText(debug_image, + "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", + (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 4, + cv.LINE_AA) + cv.putText(debug_image, + "Elapsed Time : " + '{:.1f}'.format(elapsed_time * 1000) + "ms", + (10, 30), cv.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2, + cv.LINE_AA) + + return debug_image