def renconstruct_measure(): print("*********start a measurement****************") print("3. Compute matches") pMatches = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeMatches"), "-i", matches_dir + "/sfm_data.json", "-o", matches_dir ]) pMatches.wait() print("4. Do Sequential/Incremental reconstruction") pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_IncrementalSfM"), "-i", matches_dir + "/sfm_data.json", "-m", matches_dir, "-o", reconstruction_dir ]) pRecons.wait() print("5. Convert bin to json") pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ConvertSfM_DataFormat"), "-i", reconstruction_dir + "/sfm_data.bin", "-o", reconstruction_dir + "/sfm_data.json" ]) pRecons.wait() print("6. Generate sfm_data_markers.json using markers") add_markers.add_aruco_markers(reconstruction_dir + "/sfm_data.json") print("7. Generate sfm_data_aligned.bin with ControlPointsRegistration") pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ControlPointsRegistration"), "-i", reconstruction_dir + "/sfm_data_markers.json", "-o", reconstruction_dir + "/sfm_data_aligned.bin" ]) pRecons.wait() print("8. Convert sfm_data_aligned bin to sfm_data_aligned.json") pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ConvertSfM_DataFormat"), "-i", reconstruction_dir + "/sfm_data_aligned.bin", "-o", reconstruction_dir + "/sfm_data_aligned.json" ]) pRecons.wait() # compute final valid structure from the known camera poses print("9. Structure from Known Poses (robust triangulation)") pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeStructureFromKnownPoses"), "-i", reconstruction_dir + "/sfm_data_aligned.bin", "-m", matches_dir, "-f", os.path.join(matches_dir, "matches.f.bin"), "-o", os.path.join(reconstruction_dir, "robust_aligned.bin") ]) pRecons.wait() pRecons = subprocess.Popen([ os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir + "/robust_aligned.bin", "-o", os.path.join(reconstruction_dir, "robust_colorized.ply") ]) pRecons.wait() # use elas to dense the scene ''' print ("10. use elas to dense the scene") pRecons = subprocess.Popen( ["/home/neousys/Project/volume_measurement/src/sfm/build/dense", reconstruction_dir+"/sfm_data_aligned.json"] ) pRecons.wait() ''' print("11. Measure volume") mes_instance = Measurement() mes_instance.measure( os.path.join(reconstruction_dir, 'robust_aligned.ply'), os.path.join(reconstruction_dir, 'robust_colorized.ply')) # show and save result [length, width, height] = mes_instance.result with open("/home/neousys/Project/volume_measurement/src/sfm/result.txt", "a") as file: file.write("length = %f, width = %f, height = %f \n" % (length, width, height)) """
print ("4. Do Sequential/Incremental reconstruction") pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_IncrementalSfM"), "-i", matches_dir+"/sfm_data.json", "-m", matches_dir, "-o", reconstruction_dir] ) pRecons.wait() print ("5. Convert bin to json") pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ConvertSfM_DataFormat"), "-i", reconstruction_dir+"/sfm_data.bin", "-o", reconstruction_dir+"/sfm_data.json"] ) pRecons.wait() print ("6. Generate sfm_data_markers.json using markers") add_markers.add_aruco_markers(reconstruction_dir+"/sfm_data.json") print ("7. Generate sfm_data_aligned.bin with ControlPointsRegistration") pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ControlPointsRegistration"), "-i", reconstruction_dir+"/sfm_data_markers.json", "-o", reconstruction_dir+"/sfm_data_aligned.bin"] ) pRecons.wait() print ("8. Convert sfm_data_aligned bin to sfm_data_aligned.json") pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ConvertSfM_DataFormat"), "-i", reconstruction_dir+"/sfm_data_aligned.bin", "-o", reconstruction_dir+"/sfm_data_aligned.json"] ) pRecons.wait() # compute final valid structure from the known camera poses print ("8. Structure from Known Poses (robust triangulation)") pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeStructureFromKnownPoses"), "-i", reconstruction_dir+"/sfm_data_aligned.bin", "-m", matches_dir, "-f", os.path.join(matches_dir, "matches.f.bin"), "-o", os.path.join(reconstruction_dir,"robust_aligned.bin"), "-r", "4.0"] ) pRecons.wait() pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir+"/robust_aligned.bin", "-o", os.path.join(reconstruction_dir,"robust_colorized.ply")] ) pRecons.wait() print ("9. Measure volume") mes_instance = Measurement() mes_instance.measure(os.path.join(reconstruction_dir, 'robust_aligned.ply'), os.path.join(reconstruction_dir, 'robust_colorized.ply'))