normalement ca marche mais il faut faire beaucoup de calculs

This commit is contained in:
gdamms 2023-01-25 21:24:54 +01:00
parent 1d8f97b2fd
commit 4af6119841

View file

@ -11,8 +11,8 @@ from fvi import fast_voxel_intersect
VOXEL_SIZE = 5e-3
X_MIN, X_MAX = 0.7, 1.3
Y_MIN, Y_MAX = -0.1, 0.1
Z_MIN, Z_MAX = -0.1, 0.1
Y_MIN, Y_MAX = -0.05, 0.05
Z_MIN, Z_MAX = -0.05, 0.05
nb_frame = 24
@ -35,7 +35,7 @@ for k in range(nb_frame):
matrices = pickle.load(file)
proj_mat = matrices["P"]
proj_mats.append(proj_mat)
position = matrices["RT"][:, 3]
position = -np.linalg.inv(matrices["RT"][:3,:3]) @ matrices["RT"][:3,3]
positions.append(position)
cam_points = proj_mat @ points.T
@ -71,8 +71,7 @@ for k in range(nb_frame):
# cv2.imshow('Frame', frame)
# cv2.waitKey(0)
voxel = np.zeros((int((X_MAX-X_MIN)/VOXEL_SIZE + 1), int((Y_MAX-Y_MIN)/VOXEL_SIZE + 1), int((Z_MAX-Z_MIN)/VOXEL_SIZE + 1)))
voxel = np.zeros((int((X_MAX-X_MIN)/VOXEL_SIZE), int((Y_MAX-Y_MIN)/VOXEL_SIZE), int((Z_MAX-Z_MIN)/VOXEL_SIZE)))
idx = np.floor_divide(points[:, :3] - np.array([X_MIN, Y_MIN, Z_MIN]), VOXEL_SIZE).astype(int)
voxel[idx[:,0], idx[:,1], idx[:,2]] = 1
@ -107,9 +106,11 @@ for idx in track(np.argwhere(border)):
# si le rayon ne traverse aucun autre voxel entre le centre du voxel (idx) et le centre de la caméra
_, _, voxels_intersected = fast_voxel_intersect(start, end, origin, step, shape)
print(f"ntm: {voxels_intersected}")
voxels_intersected = np.array(voxels_intersected, dtype=np.int32)
visible = voxel[voxels_intersected].sum() == 0
if len(voxels_intersected) == 0:
visible = True
else:
visible = voxel[voxels_intersected[:, 0], voxels_intersected[:, 1], voxels_intersected[:, 2]].sum() == 0
if visible:
proj = proj_mats[i] @ np.array([start[0], start[1], start[2], 1.0])
@ -119,8 +120,7 @@ for idx in track(np.argwhere(border)):
# calcule écartype des valeurs
std = np.std(values)
# print(std)
# print(values)
print(f"std: {std}, values: {values}, nb_values: {len(values)}")
# changer le levelset en fonction de l'écartype
if std < 2: