Skip to content

Commit

Permalink
Add the rig-related executables, move stereo_utils.py to Python dir
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed May 17, 2024
1 parent 0aa5e1d commit dc3a0f1
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 45 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build_isis.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

# TODO(oalexan1): This broke after GitHub no longer allows unzipping
# files to system directories. See build_test.sh for the latest logic.

# This is a scratch pad of commands used to build ASP dependencies for OSX
# in the cloud, while connecting with ssh.yml. It will go away once
Expand All @@ -10,9 +8,9 @@
cd
echo Now in $(pwd)

# Fetch previously built packages
wget https://github.com/NeoGeographyToolkit/BinaryBuilder/releases/download/mac_conda_env6/asp_deps.tar.gz
/usr/bin/time tar xzf asp_deps.tar.gz -C / > /dev/null 2>&1 # this is verbose
# Fetch the ASP dependencies, as described in build_test.sh. Update the needed
# packages as further down this document. Then archive them as in build_test.sh,
# and continue the rest of the instructions from there.

# Set up the conda env
conda init bash
Expand Down Expand Up @@ -94,15 +92,17 @@ else
fi
export PREFIX=/usr/local/miniconda/envs/asp_deps
mkdir -p build && cd build
cmake .. -DALE_USE_EXTERNAL_EIGEN=ON -DALE_USE_EXTERNAL_JSON=ON -DUSGSCSM_EXTERNAL_DEPS=ON -DCMAKE_VERBOSE_MAKEFILE=TRUE -DCMAKE_C_COMPILER=${PREFIX}/bin/$cc_comp -DCMAKE_CXX_COMPILER=${PREFIX}/bin/$cxx_comp -DUSGSCSM_BUILD_DOCS=OFF -DALE_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=${PREFIX} -DALE_BUILD_TESTS=OFF -DUSGSCSM_BUILD_TESTS=OFF -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_EIGEN=ON -DALE_BUILD_TESTS=OFF
cmake .. -DALE_USE_EXTERNAL_EIGEN=ON -DALE_USE_EXTERNAL_JSON=ON -DUSGSCSM_EXTERNAL_DEPS=ON -DCMAKE_VERBOSE_MAKEFILE=TRUE -DCMAKE_C_COMPILER=${PREFIX}/bin/$cc_comp -DCMAKE_CXX_COMPILER=${PREFIX}/bin/$cxx_comp -DALE_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=${PREFIX} -DALE_BUILD_TESTS=OFF -DUSGSCSM_BUILD_TESTS=OFF -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_EIGEN=ON -DALE_BUILD_TESTS=OFF
make -j 20 install

# Continue with building usgscsm with the same env as above
cd
#git clone git@github.com:USGS-Astrogeology/usgscsm.git --recursive
git clone https://github.com/DOI-USGS/usgscsm.git --recursive
#git clone https://github.com/DOI-USGS/usgscsm.git --recursive
git clone git@github.com:oleg-alexandrov/usgscsm.git --recursive
cd usgscsm
git reset --hard 0f065ca
#git reset --hard 0f065ca
git checkout height_radtan_fixes
mkdir -p build && cd build
cmake .. -DALE_USE_EXTERNAL_EIGEN=ON -DALE_USE_EXTERNAL_JSON=ON -DUSGSCSM_EXTERNAL_DEPS=ON -DCMAKE_VERBOSE_MAKEFILE=TRUE -DCMAKE_C_COMPILER=${PREFIX}/bin/$cc_comp -DCMAKE_CXX_COMPILER=${PREFIX}/bin/$cxx_comp -DUSGSCSM_BUILD_DOCS=OFF -DALE_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=${PREFIX} -DALE_BUILD_TESTS=OFF -DUSGSCSM_BUILD_TESTS=OFF -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_JSON=ON -DALE_USE_EXTERNAL_EIGEN=ON -DALE_BUILD_TESTS=OFF
make -j 20 install
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ if [ 1 -eq 0 ]; then
mkdir -p ~/work/StereoPipeline/packages
/usr/bin/time tar cfz ~/work/StereoPipeline/packages/asp_deps.tar.gz \
/Users/runner/miniconda3/envs
#/usr/local/miniconda/envs/asp_deps /usr/local/miniconda/envs/python_isis8

# When ssh.yml exits, it will cache ~/work/StereoPipeline/packages
# This can be fetched on a local machine, then the desired tarball
Expand Down
47 changes: 26 additions & 21 deletions src/asp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,6 @@ find_external_library(USGSCSM ${ASP_DEPS_DIR} "usgscsm" "usgscsm" REQUIRED)
# ALE
find_external_library(ALE ${ASP_DEPS_DIR} "ale" "ale" REQUIRED)

# These are needed for rig_calibrator
# MVE
set(MVE_LIB_NAMES mveUtil mveCore mveOgl mveDmrecon)
find_external_library(MVE ${ASP_DEPS_DIR} "mve" "${MVE_LIB_NAMES}" REQUIRED)
# Rayint only has headers, no libraries
find_external_library(MVE ${ASP_DEPS_DIR} "rayint" "" REQUIRED)
# texture reconstruction
find_external_library(TEXRECON ${ASP_DEPS_DIR} "" "texture_reconstruction" REQUIRED)

# PCL
# The PCL include directory is include/pcl-x.xx
file(GLOB PCL_DIRS "${ASP_DEPS_DIR}/include/pcl-*") # all matches
Expand Down Expand Up @@ -276,6 +267,9 @@ set(PDAL_LIB_NAMES pdal_plugin_kernel_fauxplugin
pdal_plugin_writer_tiledb pdalcpp)
find_external_library(PDAL ${ASP_DEPS_DIR} "pdal" "${PDAL_LIB_NAMES}" REQUIRED)

set(TBB_LIB_NAMES tbb tbbmalloc tbbmalloc_proxy)
find_external_library(TBB ${ASP_DEPS_DIR} "" "${TBB_LIB_NAMES}" REQUIRED)

# This is an experiment, to be continued
# Use only a small portion of VTK, and only in one stand-alone
# tool. That one is a giant library. Thse are installed using
Expand All @@ -288,11 +282,21 @@ find_external_library(PDAL ${ASP_DEPS_DIR} "pdal" "${PDAL_LIB_NAMES}" REQUIRED)
#find_external_library(VTK ${ASP_DEPS_DIR} "vtk-9.1" "${VTK_LIB_NAMES}" REQUIRED)

# For convenience, list some libraries that VW and ISIS depend on.
set(VW_3RD_PARTY_LIBS ${Z_LIBRARIES} ${OPENCV_LIBRARIES} ${ILMBASE_LIBRARIES} ${OPENEXR_LIBRARIES}
${GDAL_LIBRARIES} ${LAPACK_LIBRARIES} ${Boost_LIBRARIES} ${PROJ4_LIBRARIES}
${GEOTIFF_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES} ${PNG_LIBRARIES}
${FLANN_LIBRARIES} ${LZ4_LIBRARIES})
set(ISIS_3RD_PARTY_LIBS Qt5::Core ${EMBREE_LIBRARIES} ${PROTOBUF_LIBRARIES} ${QWT_LIBRARIES} ${ARMADILLO_LIBRARIES})
set(VW_3RD_PARTY_LIBS ${Z_LIBRARIES} ${OPENCV_LIBRARIES} ${ILMBASE_LIBRARIES}
${OPENEXR_LIBRARIES} ${GDAL_LIBRARIES} ${LAPACK_LIBRARIES} ${Boost_LIBRARIES}
${PROJ4_LIBRARIES} ${GEOTIFF_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARIES}
${PNG_LIBRARIES} ${FLANN_LIBRARIES} ${LZ4_LIBRARIES})
set(ISIS_3RD_PARTY_LIBS Qt5::Core ${EMBREE_LIBRARIES} ${PROTOBUF_LIBRARIES}
${QWT_LIBRARIES} ${ARMADILLO_LIBRARIES})

# These are needed for rig_calibrator
# MVE
set(MVE_LIB_NAMES mveUtil mveCore mveOgl mveDmrecon)
find_external_library(MVE ${ASP_DEPS_DIR} "mve" "${MVE_LIB_NAMES}" REQUIRED)
# Rayint only has headers, no libraries
find_external_library(RAYINT ${ASP_DEPS_DIR} "rayint" "" REQUIRED)
# texture reconstruction
find_external_library(TEXRECON ${ASP_DEPS_DIR} "" "texture_reconstruction" REQUIRED)

# Libraries use paths like "asp/src/Core/Common.h" so we just need to
# add this one include path. These must take precedence over anything
Expand Down Expand Up @@ -338,12 +342,6 @@ get_all_source_files( "OpenMVG" ASP_OPENMVG_SRC_FILES)
get_all_source_files( "OpenMVG/tests" ASP_OPENMVG_TEST_FILES)
set(ASP_OPENMVG_LIB_DEPENDENCIES "")

# ASP Rig
get_all_source_files( "Rig" ASP_RIG_SRC_FILES)
get_all_source_files( "Rig/tests" ASP_RIG_TEST_FILES)
set(ASP_RIG_LIB_DEPENDENCIES AspCore AspOpenMvg ${OPENCV_LIBRARIES}
${SOLVER_LIBRARIES})

# ASP_CAMERA
get_all_source_files( "Camera" ASP_CAMERA_SRC_FILES)
get_all_source_files( "Camera/tests" ASP_CAMERA_TEST_FILES)
Expand All @@ -364,14 +362,21 @@ set(ASP_GUI_LIB_DEPENDENCIES AspCore AspCamera Qt5::Core Qt5::Gui Qt5::Widgets $
# ASP_GOTCHA
get_all_source_files( "Gotcha" ASP_GOTCHA_SRC_FILES)
get_all_source_files( "Gotcha/tests" ASP_GOTCHA_TEST_FILES)
set(ASP_GOTCHA_LIB_DEPENDENCIES ${VISIONWORKBENCH_LIBRARIES} ${OPENCV_LIBRARIES} ${Boost_LIBRARIES})
set(ASP_GOTCHA_LIB_DEPENDENCIES ${VISIONWORKBENCH_LIBRARIES} ${OPENCV_LIBRARIES}
${Boost_LIBRARIES})

# ASP_PclIO
get_all_source_files("PclIO" ASP_PCLIO_SRC_FILES)
get_all_source_files( "PclIO/tests" ASP_PCLIO_TEST_FILES)
set(ASP_PCLIO_LIB_DEPENDENCIES pcl_common pcl_io_ply pcl_io
AspCore ${VISIONWORKBENCH_LIBRARIES})

# ASP Rig
get_all_source_files("Rig" ASP_RIG_SRC_FILES)
get_all_source_files("Rig/tests" ASP_RIG_TEST_FILES)
set(ASP_RIG_LIB_DEPENDENCIES AspCore AspOpenMvg AspPclIO tbb ${OPENCV_LIBRARIES}
${SOLVER_LIBRARIES} ${MVE_LIBRARIES} ${RAYINT_LIBRARIES} ${TEXRECON_LIBRARIES})

# Add all of the library subdirectories

add_subdirectory(Core)
Expand Down
3 changes: 2 additions & 1 deletion src/asp/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
set(PYTHON_FILES asp_alg_utils.py asp_image_utils.py
asp_cmd_utils.py asp_string_utils.py
asp_file_utils.py asp_system_utils.py
asp_geo_utils.py)
asp_geo_utils.py asp_stereo_utils.py
asp_rig_utils.py)

foreach(p ${PYTHON_FILES})
INSTALL(FILES ${p} DESTINATION libexec)
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Python/asp_system_utils.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os.path as P
import asp_string_utils, asp_cmd_utils

# This is explained further down.
# This is explained further down
if 'ASP_LIBRARY_PATH' in os.environ:
os.environ['LD_LIBRARY_PATH'] = os.environ['ASP_LIBRARY_PATH']

Expand Down
28 changes: 24 additions & 4 deletions src/asp/Tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ set(PYTHON_TOOLS cam2map4stereo.py hiedr2mosaic.py
time_trials camera_calibrate
camera_solve parallel_sfs
mapproject parallel_bundle_adjust
extract_bag list_timestamps
rig_bracket texrecon
theia_sfm multi_stereo
historical_helper.py
bathy_threshold_calc.py
scale_bathy_mask.py
crs2crs2grid.py
orbit_plot.py)
set(PYTHON_LIBS stereo_utils.py)

foreach(p ${PYTHON_TOOLS})
INSTALL(FILES ${p} PERMISSIONS
Expand All @@ -28,9 +30,6 @@ foreach(p ${PYTHON_TOOLS})
WORLD_READ WORLD_EXECUTE
DESTINATION bin)
endforeach()
foreach(p ${PYTHON_LIBS})
INSTALL(FILES ${p} DESTINATION libexec)
endforeach()

add_executable(aster2asp aster2asp.cc)
target_link_libraries(aster2asp AspSessions)
Expand Down Expand Up @@ -251,3 +250,24 @@ install(TARGETS disp2ip DESTINATION bin)
add_executable(pc_filter pc_filter.cc)
target_link_libraries(pc_filter AspPclIO AspSessions)
install(TARGETS pc_filter DESTINATION bin)

add_executable(rig_calibrator rig_calibrator.cc)
target_link_libraries(rig_calibrator AspRig)
install(TARGETS rig_calibrator DESTINATION bin)

add_executable(undistort_image_texrecon undistort_image_texrecon.cc)
target_link_libraries(undistort_image_texrecon AspRig)
install(TARGETS undistort_image_texrecon DESTINATION bin)

add_executable(fit_rpc fit_rpc.cc)
target_link_libraries(fit_rpc AspRig)
install(TARGETS fit_rpc DESTINATION bin)

add_executable(sfm_submap sfm_submap.cc)
target_link_libraries(sfm_submap AspRig)
install(TARGETS sfm_submap DESTINATION bin)

add_executable(sfm_merge sfm_merge.cc)
target_link_libraries(sfm_merge AspRig)
install(TARGETS sfm_merge DESTINATION bin)

2 changes: 1 addition & 1 deletion src/asp/Tools/cam2map4stereo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
sys.path.insert(0, pythonpath)
sys.path.insert(0, libexecpath)

from stereo_utils import get_asp_version
from asp_stereo_utils import get_asp_version
from asp_system_utils import mkdir_p

import asp_system_utils
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/dg_mosaic
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sys.path.insert(0, pythonpath)
sys.path.insert(0, libexecpath)

from asp_system_utils import * # must be after the path is altered above
from stereo_utils import get_asp_version
from asp_stereo_utils import get_asp_version
verify_python_version_is_supported()

# Prepend to system PATH
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/hiedr2mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

libexecpath = os.path.abspath(sys.path[0] + '/../libexec')
sys.path.insert(0, libexecpath) # prepend to Python path
from stereo_utils import get_asp_version
from asp_stereo_utils import get_asp_version

import asp_system_utils
asp_system_utils.verify_python_version_is_supported()
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/lronac2mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

libexecpath = os.path.abspath(sys.path[0] + '/../libexec')
sys.path.insert(0, libexecpath) # prepend to Python path
from stereo_utils import get_asp_version
from asp_stereo_utils import get_asp_version

import asp_system_utils
asp_system_utils.verify_python_version_is_supported()
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/parallel_bundle_adjust
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sys.path.insert(0, libexecpath)
import asp_system_utils, asp_cmd_utils
asp_system_utils.verify_python_version_is_supported()

from stereo_utils import * # must be after the path is altered above
from asp_stereo_utils import * # must be after the path is altered above

# Prepend to system PATH
os.environ["PATH"] = libexecpath + os.pathsep + os.environ["PATH"]
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/parallel_stereo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ sys.path.insert(0, libexecpath)

import asp_system_utils, asp_string_utils, asp_cmd_utils
asp_system_utils.verify_python_version_is_supported()
from stereo_utils import * # must be after the path is altered above
from asp_stereo_utils import * # must be after the path is altered above

# Prepend to system PATH
os.environ["PATH"] = libexecpath + os.pathsep + os.environ["PATH"]
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/sparse_disp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ sys.path.insert(0, basepath) # prepend to Python path
sys.path.insert(0, pythonpath)
sys.path.insert(0, libexecpath)

from stereo_utils import get_asp_version
from asp_stereo_utils import get_asp_version

#==============================================================================
# Start of supporting functions
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/stereo
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sys.path.insert(0, basepath) # prepend to Python path
sys.path.insert(0, pythonpath)
sys.path.insert(0, libexecpath)

from stereo_utils import * # must be after the path is altered above
from asp_stereo_utils import * # must be after the path is altered above

import asp_system_utils, asp_cmd_utils
asp_system_utils.verify_python_version_is_supported()
Expand Down
2 changes: 1 addition & 1 deletion src/asp/Tools/time_trials
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from __future__ import print_function
import os, sys, optparse, string, subprocess, math

from stereo_utils.py import get_asp_version
from asp_stereo_utils import get_asp_version

import asp_system_utils
asp_system_utils.verify_python_version_is_supported()
Expand Down

0 comments on commit dc3a0f1

Please sign in to comment.