def main(): np.random.seed(1234) if len(sys.argv) < 2: print("Usage: $python3 run_reconstruction.py <path to PLY file>") exit(0) filename = sys.argv[1] # Camera intrinsic matrix # In this case, the image coordinate is represented in a non-homogeneous 2D # vector, therefore the intrinsic matrix is represented in a 2x3 matrix. # In this script, we assume the orthogonal projection as a camera # projection model intrinsic_parameters = np.array([[1, 0, 0], [0, 1, 0]]) # Load the 3D object from the file X_true = read_object(filename) X_true = normalize_object_size(X_true) # Number of viewpoints to be used for reconstruction n_views = 128 # Standard deviation of noise noise_std = 0.0 target_object = Object3D(X_true) # Create the target object camera = Camera( intrinsic_parameters) # Camera object to observe the target # The ground truth object `X_true` is passed to the TomasiKanade method, # though, this is used only for the evaluation, not reconstruction tomasi_kanade = TomasiKanade(X_eval=X_true, learning_rate=0.0027) for i in range(n_views): # Generate a random camera pose R = rigid_motion.random_rotation_matrix_3d() t = rigid_motion.random_vector_3d() camera.set_pose(R, t) # Observe the 3D object by projecting it onto the image plane image_points = take_picture(target_object, camera, noise_std) tomasi_kanade.add_image_points(image_points) # Run reconstruction # M is a stacked motion matrices # X contains the reconstructed object M, X = tomasi_kanade.run() V = to_viewpoints(M) plot3d(X, azim=180, elev=90) plot_result(X, V) plt.show()
var = pd.DataFrame(test_rmse) var.to_csv(path+'/test_rmse.csv',index = False,header = False) #var = pd.DataFrame(alpha1) #var.to_csv(path+'/alpha.csv',index = False, header = False) #print('min_rmse:%r'%(np.min(test_rmse)), # 'min_mae:%r'%(np.min(test_mae)), # 'max_acc:%r'%(np.max(test_acc))) index = test_rmse.index(np.min(test_rmse)) #test_mae.index(np.min(test_mae)) #test_acc.index(np.max(test_acc)) test_result = test_pred[index] var = pd.DataFrame(test_result) var.to_csv(path+'/test_result.csv',index = False,header = False) plot_result(test_result,test_label1,path) plot_error(train_rmse,train_loss,test_rmse,test_acc,test_mae,path) fig1 = plt.figure(figsize=(7,3)) ax1 = fig1.add_subplot(1,1,1) plt.plot(np.sum(alpha1,0)) plt.savefig(path+'/alpha.jpg',dpi=500) plt.show() plt.imshow(np.mat(np.sum(alpha1,0))) plt.savefig(path+'/alpha11.jpg',dpi=500) plt.show() print('min_rmse:%r'%(np.min(test_rmse)), 'min_mae:%r'%(test_mae[index]),