|
@@ -433,6 +433,7 @@ def get_camera_points(world_points, world_mat_contents, save_path, cam_id, debug
|
433
|
433
|
v_p_array.append(v_p)
|
434
|
434
|
|
435
|
435
|
x_c_array, y_c_array, z_c_array, u_p_array, v_p_array = np.array(x_c_array), np.array(y_c_array), np.array(z_c_array), np.array(u_p_array), np.array(v_p_array)
|
|
436
|
+ #print('camera_points =', np.mean(x_c_array), np.mean(y_c_array), np.mean(z_c_array))
|
436
|
437
|
camera_points = np.column_stack((x_c_array, y_c_array, z_c_array))
|
437
|
438
|
|
438
|
439
|
if debug:
|
|
@@ -470,15 +471,24 @@ def get_screen_points(point_data, x_phase_unwrapped, y_phase_unwrapped, screen_p
|
470
|
471
|
Rs2w = screen_to_world['screen_to_world_rotation']
|
471
|
472
|
Ts2w = screen_to_world['screen_to_world_translation']
|
472
|
473
|
|
|
474
|
+ #checked
|
|
475
|
+ #print('Rs2w = ', Rs2w)
|
|
476
|
+ #print('Ts2w = ', Ts2w)
|
|
477
|
+
|
473
|
478
|
# 计算 x_phase_unwrapped 中所有非 NaN 值的平均值
|
474
|
479
|
average_x_phase_unwrapped = np.nanmean(x_phase_unwrapped)
|
475
|
480
|
average_y_phase_unwrapped = np.nanmean(y_phase_unwrapped)
|
476
|
481
|
|
|
482
|
+ #checked
|
|
483
|
+ # print('average_x_phase_unwrapped = ', average_x_phase_unwrapped)
|
|
484
|
+ # print('average_y_phase_unwrapped = ', average_y_phase_unwrapped)
|
|
485
|
+
|
477
|
486
|
# import pdb; pdb.set_trace()
|
478
|
487
|
# 计算 value_map 并找到最小值
|
479
|
488
|
value_map = np.abs(x_phase_unwrapped - average_x_phase_unwrapped) + np.abs(y_phase_unwrapped - average_y_phase_unwrapped)
|
480
|
489
|
min_index = np.unravel_index(np.nanargmin(value_map), value_map.shape)
|
481
|
490
|
|
|
491
|
+
|
482
|
492
|
# import pdb; pdb.set_trace()
|
483
|
493
|
# 选定一个中心相位值作为绝对相位值
|
484
|
494
|
# abs_phasepoint_picture = np.array(min_index)
|
|
@@ -496,7 +506,8 @@ def get_screen_points(point_data, x_phase_unwrapped, y_phase_unwrapped, screen_p
|
496
|
506
|
Axis_conversion[1] * cfg['pixelSize_mm'] * (abs_phasepoint_screen[1] - screenorigin_point[1]),
|
497
|
507
|
0])
|
498
|
508
|
abs_phasepoint_world = np.dot(Rs2w, arrow_abs_mm) + Ts2w.T
|
499
|
|
-
|
|
509
|
+
|
|
510
|
+ #checked
|
500
|
511
|
print('abs_phasepoint 绝对相位值:')
|
501
|
512
|
print(abs_phasepoint)
|
502
|
513
|
print('abs_phasepoint_world 绝对相位值对应的世界坐标系的位置:')
|
|
@@ -517,6 +528,9 @@ def get_screen_points(point_data, x_phase_unwrapped, y_phase_unwrapped, screen_p
|
517
|
528
|
phase_x_now = x_phase_unwrapped[v_now, u_now] # 注意这里的索引要按照Python的行列顺序,与MATLAB相反 raw
|
518
|
529
|
phase_y_now = y_phase_unwrapped[v_now, u_now]
|
519
|
530
|
|
|
531
|
+ #print('phase_x_now = ', phase_x_now)
|
|
532
|
+ #print('phase_y_now = ', phase_y_now)
|
|
533
|
+
|
520
|
534
|
#phase_x_now = x_phase_unwrapped[u_now, v_now]
|
521
|
535
|
#phase_y_now = y_phase_unwrapped[u_now, v_now]
|
522
|
536
|
|
|
@@ -539,6 +553,8 @@ def get_screen_points(point_data, x_phase_unwrapped, y_phase_unwrapped, screen_p
|
539
|
553
|
x_data = np.array(x_data)
|
540
|
554
|
y_data = np.array(y_data)
|
541
|
555
|
z_data = np.array(z_data)
|
|
556
|
+ print('u_p size = ', x_data.shape)
|
|
557
|
+ print('screen_points = ', x_data, np.nanmean(x_data),np.nanmean(y_data),np.nanmean(z_data))
|
542
|
558
|
screen_points = np.column_stack((x_data, y_data, z_data))
|
543
|
559
|
|
544
|
560
|
if debug:
|
|
@@ -1287,15 +1303,23 @@ def post_process_with_grad(img_folder, n_cam, debug=False):
|
1287
|
1303
|
#print(x_grad_expand.shape, y_grad_expand.shape, x_expand.shape, y_expand.shape)
|
1288
|
1304
|
# 调用 Southwell 重建函数
|
1289
|
1305
|
#Z_reconstructed = southwell_integrate_smooth(x_grad_expand, y_grad_expand, x_expand, y_expand, (0, 0))
|
|
1306
|
+ print('x_gradient shape = ', x_gradient.shape)
|
|
1307
|
+ x_gradient = x_gradient.reshape(47, -1)
|
|
1308
|
+ y_gradient = y_gradient.reshape(47, -1)
|
|
1309
|
+ Z_reconstructed = np.cumsum(x_gradient, 1)*1 + np.cumsum(y_gradient, 0)*1
|
1290
|
1310
|
|
1291
|
|
- Z_reconstructed = np.cumsum(x_grad_expand, 1)*1 + np.cumsum(y_grad_expand, 0)*1
|
1292
|
|
- print('min_z =', np.min(Z_reconstructed))
|
|
1311
|
+
|
|
1312
|
+ #print('y_grad_expand =', np.cumsum(y_grad_expand, 0))
|
|
1313
|
+ #print('max_z =', np.max(Z_reconstructed))
|
1293
|
1314
|
|
1294
|
|
- #Z_reconstructed = poisson_reconstruct(x_grad_expand, y_grad_expand)
|
|
1315
|
+ #Z_reconstructed = poisson_reconstruct(x_gradient, y_gradient)
|
|
1316
|
+ print('min_z =', np.min(Z_reconstructed))
|
|
1317
|
+ print('max_z =', np.max(Z_reconstructed))
|
|
1318
|
+ print('x_grad_expand =', np.cumsum(x_grad_expand, 1))
|
1295
|
1319
|
|
1296
|
|
- z1_lookup = {(x1, y1): z1 for x1, y1, z1 in np.column_stack((x_expand.reshape(-1,1), y_expand.reshape(-1,1), Z_reconstructed.reshape(-1,1)))}
|
|
1320
|
+ #z1_lookup = {(x1, y1): z1 for x1, y1, z1 in np.column_stack((x_expand.reshape(-1,1), y_expand.reshape(-1,1), Z_reconstructed.reshape(-1,1)))}
|
1297
|
1321
|
|
1298
|
|
- z1_values = np.array([z1_lookup.get((x, y), np.nan) for x, y in np.column_stack((x, y))])
|
|
1322
|
+ #z1_values = np.array([z1_lookup.get((x, y), np.nan) for x, y in np.column_stack((x, y))])
|
1299
|
1323
|
#fitted_points = post_process(np.column_stack((x,y,z1_values)), debug=0)
|
1300
|
1324
|
|
1301
|
1325
|
|
|
@@ -1308,9 +1332,9 @@ def post_process_with_grad(img_folder, n_cam, debug=False):
|
1308
|
1332
|
# x_vals = fitted_points[:,0]
|
1309
|
1333
|
# y_vals = fitted_points[:,1]
|
1310
|
1334
|
# z_vals = fitted_points[:,2]
|
1311
|
|
- x_vals = x_expand
|
1312
|
|
- y_vals = y_expand
|
1313
|
|
- z_vals = x_grad_expand
|
|
1335
|
+ x_vals = x.reshape(47, -1)
|
|
1336
|
+ y_vals = y.reshape(47, -1)
|
|
1337
|
+ z_vals = Z_reconstructed
|
1314
|
1338
|
# 绘制3D点云
|
1315
|
1339
|
ax.scatter(x_vals, y_vals, z_vals, c=z_vals, cmap='viridis', marker='o')
|
1316
|
1340
|
|
|
@@ -1322,7 +1346,8 @@ def post_process_with_grad(img_folder, n_cam, debug=False):
|
1322
|
1346
|
plt.show()
|
1323
|
1347
|
|
1324
|
1348
|
#return fitted_points
|
1325
|
|
- return np.column_stack((x,y,z1_values))
|
|
1349
|
+ #return np.column_stack((x,y,Z_reconstructed))
|
|
1350
|
+ return 0
|
1326
|
1351
|
|
1327
|
1352
|
|
1328
|
1353
|
|