Initial cpp reimplementation.

This commit is contained in:
Daniel
2024-09-11 11:40:00 +02:00
parent 7b426d209c
commit 244f46559c
14 changed files with 1904 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import copy
import json
import os
import time
from typing import List
import cv2
@ -413,6 +414,7 @@ def main():
continue
# Load sample infos
print("\n" + dirpath)
with open(os.path.join(dirpath, "sample.json"), "r", encoding="utf-8") as file:
sample = json.load(file)
sample = update_sample(sample, dirpath)
@ -431,8 +433,11 @@ def main():
images_2d.append(img)
# Get 2D poses
stime = time.time()
poses_2d = utils_2d_pose.get_2d_pose(kpt_model, images_2d)
poses_2d = update_keypoints(poses_2d, joint_names_2d)
print("2D time:", time.time() - stime)
# print(np.array(poses_2d).round(3).tolist())
fig1 = draw_utils.show_poses2d(
poses_2d, np.array(images_2d), joint_names_2d, "2D detections"
@ -449,9 +454,11 @@ def main():
poses3D = np.zeros([1, len(joint_names_3d), 4])
poses2D = np.zeros([len(images_2d), 1, len(joint_names_3d), 3])
else:
stime = time.time()
poses3D = triangulate_poses.get_3d_pose(
poses_2d, camparams, roomparams, joint_names_2d
)
print("3D time:", time.time() - stime)
poses2D = []
for cam in camparams:
poses_2d, _ = utils_pose.project_poses(poses3D, cam)
@ -463,9 +470,9 @@ def main():
joint_names_3d,
)
print("\n" + dirpath)
print(poses3D)
# print(poses2D)
# print(poses3D.round(3).tolist())
fig2 = draw_utils.utils_view.show_poses3d(
poses3D, joint_names_3d, roomparams, camparams