Skip to content
Snippets Groups Projects
Commit c1531d6d authored by Guillaume Duret's avatar Guillaume Duret
Browse files

evaluation running

parent 092cc0fd
No related branches found
No related tags found
No related merge requests found
......@@ -8,13 +8,14 @@ import open3d as o3d
import argparse
import os
import sys
from plyfile import PlyData, PlyElement
def read_diameter(object_name):
filename = f'Generated_Worlds_/Generated/{class_name}/diameter.txt'
filename = f'Generated_Worlds_/Generated/{class_name}/{class_name}_diameter.txt'
with open(filename) as f:
diameter_in_cm = float(f.readline())
return diameter_in_cm * 0.01
#return diameter_in_cm * 0.01
return diameter_in_cm
def transform_pts_Rt(pts, R, t):
......@@ -245,6 +246,7 @@ def eval_pose(r_est, t_est, r_gt, t_gt, pc, k, diameter, sym=False):
if __name__ == '__main__':
ap = argparse.ArgumentParser()
ap.add_argument("--path_evaluation", type=str, required=True)
ap.add_argument("-cls_name", "--class_name", type=str,
default='kiwi1',
help="[apple2, apricot, banana1, kiwi1, lemon2, orange2, peach1, pear2]")
......@@ -252,57 +254,74 @@ if __name__ == '__main__':
default=False)
args = vars(ap.parse_args())
class_name = args["class_name"]
symmetry = args["symmetry"]
basePath = os.path.dirname(
os.path.realpath(__file__)) + '/Generated_Worlds_/Generated_Worlds_Evaluating/' + class_name
images_ls, labels_ls, mask_ls, choice_ls = data.getAllValData(class_name)
print(len(images_ls))
basePath = args["path_evaluation"] + "/" + args["class_name"]
#basePath = os.path.dirname(
# os.path.realpath(__file__)) + '/Generated_Worlds_/Generated_Worlds_Evaluating/' + class_name
#images_ls, labels_ls, mask_ls, choice_ls = data.getAllValData(class_name)
#print(len(images_ls))
pc_path = f'/gpfswork/rech/uli/ubn15wo/guimod/Models/{class_name}/{class_name}.ply'
#pcd = o3d.io.read_point_cloud(pc_path)
#pc = np.asarray(pcd.points)
plydata = PlyData.read(pc_path)
elm = plydata.elements
data = np.asarray(elm[0][:])
pc = np.zeros((len(data), 3))
print("len(data)", len(data))
print("len(pc)", len(pc))
diameter = read_diameter(class_name)
print(diameter)
for i in range(len(data)):
pc[i][0], pc[i][1], pc[i][2] = data[i][0], data[i][1], data[i][2]
pc_path = f'/{basePath}/Models/{class_name}.ply'
pcd = o3d.io.read_point_cloud(pc_path)
pc = np.asarray(pcd.points)
add_res_ls = []
proj_res_ls = []
count_add = 0
count_iadd = 0
count_proj = 0
length_data=len(os.listdir(f"{basePath}/Pose_prediction"))
print("number of evaluating data :", length_data)
for idx in range(len(images_ls)):
for files in os.listdir(f"{basePath}/Pose_prediction"):
# ============== Loading Pose ===============
pose_est = np.load(f'{basePath}/Pose_prediction/{idx}.npy')
pose_est = np.load(f'{basePath}/Pose_prediction/{files}')
r_est = pose_est[:3, :3]
t_est = pose_est[:3, 3]
t_est = np.array(pose_est[:3, 3]).reshape(3, 1)
print("t_est", t_est)
pose_gt = np.load(f'{basePath}/Pose_transformed/{idx}.npy')
pose_gt = np.load(f'{basePath}/Pose_transformed/{files}')
r_gt = np.array(pose_gt[0:3, 0:3], dtype='float64')
t_gt = np.array(pose_gt[0:3, 3], dtype='float64').reshape(3, 1)
print("t_gt", t_gt)
# ============== Evaluation ===============
k = np.array([[543.25272224, 0., 320.25],
[0., 724.33696299, 240.33333333],
[0., 0., 1.]])
diameter = read_diameter(class_name)
[0., 0., 1.]])
add_res, is_add, proj_res, is_proj, adi_res, is_adi = eval_pose(r_est, t_est, r_gt, t_gt, pc, k, diameter, symmetry)
if is_add:
count_add += 1
if is_proj:
count_proj += 1
if is_adi:
count_iadd += 1
print(f"ADD_Res: {count_add / len(images_ls)}")
print(f"ADI_Res: {count_iadd / len(images_ls)}")
print(f"Proj_Res: {count_proj / len(images_ls)}")
print(f"ADD_Res: {count_add / length_data}")
print(f"ADI_Res: {count_iadd / length_data}")
print(f"Proj_Res: {count_proj / length_data}")
print(f"======================")
print("Done")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment