Run skelda tests with new implementation.

This commit is contained in:
Daniel
2024-09-13 11:04:38 +02:00
parent 91a502811f
commit f7a7f69f37
3 changed files with 366 additions and 346 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import json
import os
import sys
import time
import cv2
@ -8,10 +9,12 @@ import numpy as np
import tqdm
import test_triangulate
import triangulate_poses
import utils_2d_pose
from skelda import evals, utils_pose
sys.path.append("/SimplePoseTriangulation/swig/")
import spt
# ==================================================================================================
# dataset_use = "panoptic"
@ -316,12 +319,27 @@ def main():
# Print a dataset sample for debugging
print(labels[0])
minscores = {
# Choose this depending on the fraction of invalid/missing persons
# A higher value reduces the number of proposals
"panoptic": 0.94,
"human36m": 0.94,
"mvor": 0.86,
"campus": 0.96,
"shelf": 0.96,
"ikeaasm": 0.89,
"tsinghua": 0.96,
"human36m_wb": 0.94,
"koarob": 0.91,
}
minscore = minscores.get(dataset_use, 0.95)
print("\nRunning predictions ...")
all_poses = []
all_ids = []
all_paths = []
times = []
last_poses_3d = np.array([])
triangulator = spt.Triangulator(min_score=minscore)
old_scene = ""
for label in tqdm.tqdm(labels):
images_2d = []
@ -329,7 +347,7 @@ def main():
if old_scene != label.get("scene", ""):
# Reset last poses if scene changes
old_scene = label.get("scene", "")
last_poses_3d = np.array([])
triangulator.reset()
try:
start = time.time()
@ -366,28 +384,20 @@ def main():
time_2d = time.time() - start
print("2D time:", time_2d)
minscores = {
# Choose this depending on the fraction of invalid/missing persons
# A higher value reduces the number of proposals
"panoptic": 0.94,
"human36m": 0.94,
"mvor": 0.86,
"campus": 0.96,
"shelf": 0.96,
"ikeaasm": 0.89,
"tsinghua": 0.96,
"human36m_wb": 0.94,
}
minscore = minscores.get(dataset_use, 0.95)
start = time.time()
if sum(np.sum(p) for p in poses_2d) == 0:
poses3D = np.zeros([1, len(joint_names_3d), 4])
poses2D = np.zeros([len(images_2d), 1, len(joint_names_3d), 3])
else:
poses3D = triangulate_poses.get_3d_pose(
poses_2d, label["cameras"], roomparams, joint_names_2d, last_poses_3d, minscore
cameras = spt.convert_cameras(label["cameras"])
roomp = [roomparams["room_center"], roomparams["room_size"]]
poses_3d = triangulator.triangulate_poses(
poses_2d, cameras, roomp, joint_names_2d
)
poses3D = np.array(poses_3d)
if len(poses3D) == 0:
poses3D = np.zeros([1, len(joint_names_3d), 4])
poses2D = []
for cam in label["cameras"]:
poses_2d, _ = utils_pose.project_poses(poses3D, cam)
@ -401,7 +411,6 @@ def main():
drop_few_limbs=(dataset_use != "mvor"),
)
poses3D = add_missing_joints(poses3D, joint_names_3d)
last_poses_3d = poses3D
time_3d = time.time() - start
print("3D time:", time_3d)

View File

@ -1,6 +1,7 @@
import copy
import json
import os
import sys
import time
from typing import List
@ -9,10 +10,12 @@ import matplotlib
import numpy as np
import draw_utils
import triangulate_poses
import utils_2d_pose
from skelda import utils_pose
sys.path.append("/SimplePoseTriangulation/swig/")
import spt
# ==================================================================================================
filepath = os.path.dirname(os.path.realpath(__file__)) + "/"
@ -437,7 +440,7 @@ def main():
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())
# print([np.array(p).round(6).tolist() for p in poses_2d])
fig1 = draw_utils.show_poses2d(
poses_2d, np.array(images_2d), joint_names_2d, "2D detections"
@ -454,11 +457,19 @@ def main():
poses3D = np.zeros([1, len(joint_names_3d), 4])
poses2D = np.zeros([len(images_2d), 1, len(joint_names_3d), 3])
else:
cameras = spt.convert_cameras(camparams)
roomp = [roomparams["room_center"], roomparams["room_size"]]
triangulator = spt.Triangulator(min_score=0.95)
stime = time.time()
poses3D = triangulate_poses.get_3d_pose(
poses_2d, camparams, roomparams, joint_names_2d
poses_3d = triangulator.triangulate_poses(
poses_2d, cameras, roomp, joint_names_2d
)
poses3D = np.array(poses_3d)
if len(poses3D) == 0:
poses3D = np.zeros([1, len(joint_names_3d), 4])
print("3D time:", time.time() - stime)
poses2D = []
for cam in camparams:
poses_2d, _ = utils_pose.project_poses(poses3D, cam)