Skip to content

Commit

Permalink
[src/software/sfm] Merge SfM engines in a common SfM binary openMVG#1872
Browse files Browse the repository at this point in the history
 (openMVG#1873)

* [src/software/sfm] Merge SfM engines in a common SfM binary openMVG#1872

* Handle comments on PR openMVG#1873 (Thx you @rjanvier, @rperrot)
  • Loading branch information
pmoulon authored Mar 27, 2021
1 parent c76aa77 commit d3466ed
Show file tree
Hide file tree
Showing 11 changed files with 615 additions and 883 deletions.
10 changes: 2 additions & 8 deletions dist/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,8 @@ apps:
geodesy-registration-to-gps-position:
command: openMVG_main_geodesy_registration_to_gps_position
plugs: [home]
GlobalSfM:
command: openMVG_main_GlobalSfM
plugs: [home]
IncrementalSfM:
command: openMVG_main_IncrementalSfM
plugs: [home]
IncrementalSfM2:
command: openMVG_main_IncrementalSfM2
SfM:
command: openMVG_main_SfM
plugs: [home]
ListMatchingPairs:
command: openMVG_main_ListMatchingPairs
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/rst/software/SfM/GlobalSfM.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The chain will only consider images with known approximate focal length. Image w

.. code-block:: c++

$ openMVG_main_GlobalSfM -i Dataset/matches/sfm_data.json -m Dataset/matches/ -o Dataset/out_Global_Reconstruction/
$ openMVG_main_SfM --engine GLOBAL -i Dataset/matches/sfm_data.json -m Dataset/matches/ -o Dataset/out_Global_Reconstruction/

Arguments description:

Expand Down
20 changes: 8 additions & 12 deletions docs/sphinx/rst/software/SfM/IncrementalSfM.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ The chain is designed to run on a sfm_data.json file and some pre-computed match

.. code-block:: c++

$ openMVG_main_IncrementalSfM -i Dataset/matches/sfm_data.json -m Dataset/matches/ -o Dataset/out_Incremental_Reconstruction/

openMVG_main_IncrementalSfM displays to you some initial pairs that share an important number of common point.
**Please select two image index that are convergent and the 3D reconstruction will start.
The initial pair must be chosen with numerous correspondences while keeping a wide enough baseline.**
$ openMVG_main_SfM --engine INCREMENTAL -i Dataset/matches/sfm_data.json -m Dataset/matches/ -o Dataset/out_Incremental_Reconstruction/

Arguments description:

Expand All @@ -52,21 +48,21 @@ Arguments description:

- a SfM_Data file

- **[-m|--matchdir]**
- **[-m|--match_dir]**

- path were geometric matches were stored

- **[-o|--outdir]**
- **[-o|--out_dir]**

- path where the output data will be stored

**Optional parameters:**

- **[-a|--initialPairA NAME]**
- **[-a|--initial_pair_a NAME]**

- the filename image to use (i.e. 100_7001.JPG)

- **[-b|--initialPairB NAME]**
- **[-b|--initial_pair_b NAME]**

- the filename image to use (i.e. 100_7002.JPG)

Expand All @@ -80,7 +76,7 @@ Arguments description:
- 4: Pinhole radial 3 + tangential 2
- 5: Pinhole fisheye

- **[-f|--refineIntrinsics]**
- **[-f|--refine_intrinsic_config]**
User can control exactly which parameter will be considered as constant/variable and combine them by using the '|' operator.
- ADJUST_ALL -> refine all existing parameters (default)
Expand All @@ -101,10 +97,10 @@ Arguments description:
-> refine the principal point position & the distortion coefficient(s) (if any)

*************************************
openMVG_main_IncrementalSfM2
IncrementalSfM2
*************************************

`openMVG_main_IncrementalSfM2` is a more generic incremental pipeline than `openMVG_main_IncrementalSfM` since it can:
`INCREMENTALV2` is a more generic incremental pipeline than `INCREMENTAL` since it can:

- extend a scene that was started by using existing poses or an abstract scene initialization (2 view or n-views).

Expand Down
45 changes: 7 additions & 38 deletions src/software/SfM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,50 +118,23 @@ target_link_libraries(openMVG_main_MatchesToTracks
# Installation rules
set_property( TARGET openMVG_main_ListMatchingPairs PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_ComputeFeatures PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_PairGenerator PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_PairGenerator PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_ComputeMatches PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_GeometricFilter PROPERTY FOLDER OpenMVG/software )
set_property( TARGET openMVG_main_MatchesToTracks PROPERTY FOLDER OpenMVG/software )

install( TARGETS openMVG_main_ListMatchingPairs DESTINATION bin/ )
install( TARGETS openMVG_main_ComputeFeatures DESTINATION bin/ )
install( TARGETS openMVG_main_PairGenerator DESTINATION bin/ )
install( TARGETS openMVG_main_PairGenerator DESTINATION bin/ )
install( TARGETS openMVG_main_ComputeMatches DESTINATION bin/ )
install( TARGETS openMVG_main_GeometricFilter DESTINATION bin/ )
install( TARGETS openMVG_main_MatchesToTracks DESTINATION bin/ )

###
# SfM Pipelines
# - Incremental/Sequential
# - Global
# SfM Pipelines & SfM Data format tools, ...
###
# - Convert SfM_Data format (from one to another)
# - Pair filtering (from frustum)
# - Compute structure from known camera poses
# - Compute structure color
###
add_executable(openMVG_main_IncrementalSfM main_IncrementalSfM.cpp)
target_link_libraries(openMVG_main_IncrementalSfM
PRIVATE
openMVG_system
openMVG_image
openMVG_features
openMVG_sfm
${STLPLUS_LIBRARY}
)

add_executable(openMVG_main_IncrementalSfM2 main_IncrementalSfM2.cpp)
target_link_libraries(openMVG_main_IncrementalSfM2
PRIVATE
openMVG_system
openMVG_image
openMVG_features
openMVG_sfm
${STLPLUS_LIBRARY}
)

add_executable(openMVG_main_GlobalSfM main_GlobalSfM.cpp)
target_link_libraries(openMVG_main_GlobalSfM
add_executable(openMVG_main_SfM main_SfM.cpp)
target_link_libraries(openMVG_main_SfM
PRIVATE
openMVG_system
openMVG_image
Expand Down Expand Up @@ -231,12 +204,8 @@ target_link_libraries(openMVG_main_ChangeLocalOrigin
)

# Installation rules
set_property(TARGET openMVG_main_IncrementalSfM PROPERTY FOLDER OpenMVG/software)
install(TARGETS openMVG_main_IncrementalSfM DESTINATION bin/)
set_property(TARGET openMVG_main_IncrementalSfM2 PROPERTY FOLDER OpenMVG/software)
install(TARGETS openMVG_main_IncrementalSfM2 DESTINATION bin/)
set_property(TARGET openMVG_main_GlobalSfM PROPERTY FOLDER OpenMVG/software)
install(TARGETS openMVG_main_GlobalSfM DESTINATION bin/)
set_property(TARGET openMVG_main_SfM PROPERTY FOLDER OpenMVG/software)
install(TARGETS openMVG_main_SfM DESTINATION bin/)
set_property(TARGET openMVG_main_ConvertSfM_DataFormat PROPERTY FOLDER OpenMVG/software)
install(TARGETS openMVG_main_ConvertSfM_DataFormat DESTINATION bin/)
set_property(TARGET openMVG_main_FrustumFiltering PROPERTY FOLDER OpenMVG/software)
Expand Down
14 changes: 2 additions & 12 deletions src/software/SfM/SfM_GlobalPipeline.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,9 @@ if not os.path.exists(reconstruction_dir):
os.mkdir(reconstruction_dir)

print ("6. Do Global reconstruction")
pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_GlobalSfM"), "-i", matches_dir+"/sfm_data.json", "-m", matches_dir, "-o", reconstruction_dir] )
pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_SfM"), "--engine", "GLOBAL", "--input_file", matches_dir+"/sfm_data.json", "--match_file", matches_dir+"/matches.e.bin", "--output_dir", reconstruction_dir] )
pRecons.wait()

print ("7. Colorize Structure")
pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir+"/sfm_data.bin", "-o", os.path.join(reconstruction_dir,"colorized.ply")] )
pRecons.wait()

# optional, 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.bin", "-m", matches_dir, "-f", os.path.join(matches_dir, "matches.e.bin"), "-o", os.path.join(reconstruction_dir,"robust.bin")] )
pRecons.wait()

pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir+"/robust.bin", "-o", os.path.join(reconstruction_dir,"robust_colorized.ply")] )
pRecons.wait()


pRecons.wait()
14 changes: 2 additions & 12 deletions src/software/SfM/SfM_SequentialPipeline.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,9 @@ if not os.path.exists(reconstruction_dir):
os.mkdir(reconstruction_dir)

print ("6. 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 = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_SfM"), "--engine", "INCREMENTAL", "--input_file", matches_dir+"/sfm_data.json", "--match_dir", matches_dir, "--output_dir", reconstruction_dir] )
pRecons.wait()

print ("7. Colorize Structure")
pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir+"/sfm_data.bin", "-o", os.path.join(reconstruction_dir,"colorized.ply")] )
pRecons.wait()

# optional, 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.bin", "-m", matches_dir, "-f", os.path.join(matches_dir, "matches.f.bin"), "-o", os.path.join(reconstruction_dir,"robust.bin")] )
pRecons.wait()

pRecons = subprocess.Popen( [os.path.join(OPENMVG_SFM_BIN, "openMVG_main_ComputeSfM_DataColor"), "-i", reconstruction_dir+"/robust.bin", "-o", os.path.join(reconstruction_dir,"robust_colorized.ply")] )
pRecons.wait()


pRecons.wait()
Loading

0 comments on commit d3466ed

Please sign in to comment.