Skip to content

Commit db24876

Browse files
committed
Initial commit
0 parents  commit db24876

File tree

200 files changed

+78581
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+78581
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
__pycache__
2+
*.pyc
3+
*.egg-info
4+

CMakeLists.txt

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
cmake_minimum_required(VERSION 3.20)
2+
project(upsp)
3+
cmake_policy(SET CMP0074 NEW)
4+
5+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
6+
7+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
8+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)
9+
set(CMAKE_CXX_STANDARD 17)
10+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
12+
13+
# Direct inclusion of open-source tools for
14+
# integrating pandoc w/ CMake, copied into cmake/Modules. Ref:
15+
# https://github.com/jeetsukumaran/cmake-pandocology/
16+
# (SHA: 10900f9aec4431b504fa8979576f950533cf20d9)
17+
include(pandocology)
18+
19+
find_package(Eigen3 CONFIG REQUIRED)
20+
find_package(Boost REQUIRED)
21+
find_package(OpenCV CONFIG REQUIRED COMPONENTS core imgproc imgcodecs calib3d videoio tracking)
22+
find_package(OpenMP REQUIRED)
23+
find_package(MPI REQUIRED)
24+
find_package(Python3 COMPONENTS Interpreter Development)
25+
find_package(pybind11 REQUIRED)
26+
find_library(LIBRT rt)
27+
find_package(hdf5 CONFIG REQUIRED)
28+
find_package(IlmBase CONFIG REQUIRED)
29+
30+
pybind11_add_module(cine cpp/pybind11/cine.cpp)
31+
target_link_libraries(cine PRIVATE upsp_video)
32+
pybind11_add_module(raycast cpp/pybind11/raycast.cpp)
33+
target_link_libraries(raycast PRIVATE upsp_kdtree)
34+
35+
include_directories(cpp/include)
36+
37+
add_library(
38+
upsp_video
39+
SHARED
40+
cpp/lib/PSPVideo.cpp
41+
cpp/lib/MrawReader.cpp
42+
cpp/lib/CineReader.cpp
43+
)
44+
target_link_libraries(upsp_video PRIVATE opencv_core)
45+
target_link_libraries(upsp_video PRIVATE Eigen3::Eigen)
46+
47+
add_library(
48+
upsp_utils
49+
SHARED
50+
cpp/utils/asyncIO.c
51+
cpp/utils/cv_extras.cpp
52+
cpp/utils/file_io.cpp
53+
cpp/utils/file_readers.cpp
54+
cpp/utils/file_writers.cpp
55+
cpp/utils/general_utils.cpp
56+
)
57+
target_link_libraries(upsp_utils PRIVATE opencv_core)
58+
target_link_libraries(upsp_utils PRIVATE ${LIBRT})
59+
target_link_libraries(upsp_utils PRIVATE upsp_video)
60+
target_link_libraries(upsp_utils PRIVATE Eigen3::Eigen)
61+
62+
add_library(
63+
upsp
64+
SHARED
65+
cpp/lib/cart3d.cpp
66+
cpp/lib/image_processing.cpp
67+
cpp/lib/logging.cpp
68+
cpp/lib/kulites.cpp
69+
cpp/lib/non_cv_upsp.cpp
70+
cpp/lib/patches.cpp
71+
cpp/lib/plot3d.cpp
72+
cpp/lib/projection.cpp
73+
cpp/lib/registration.cpp
74+
cpp/lib/upsp_inputs.cpp
75+
cpp/lib/CameraCal.cpp
76+
cpp/lib/PSPHDF5.cpp
77+
cpp/lib/P3DModel.cpp
78+
)
79+
target_link_libraries(upsp PUBLIC opencv_core opencv_imgproc opencv_tracking opencv_calib3d)
80+
target_link_libraries(upsp PRIVATE hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
81+
target_link_libraries(upsp PRIVATE Eigen3::Eigen)
82+
83+
add_library(
84+
upsp_kdtree
85+
SHARED
86+
cpp/utils/pspKdtree.c
87+
cpp/utils/pspRT.cpp
88+
cpp/utils/pspRTmem.cpp
89+
)
90+
target_link_libraries(upsp_kdtree IlmBase::Imath)
91+
92+
function(upsp_add_executable NAME)
93+
add_executable(${NAME} ${ARGN})
94+
target_link_libraries(${NAME} upsp)
95+
target_link_libraries(${NAME} upsp_video)
96+
target_link_libraries(${NAME} upsp_utils)
97+
target_link_libraries(${NAME} upsp_kdtree)
98+
target_link_libraries(${NAME} opencv_core)
99+
target_link_libraries(${NAME} opencv_videoio)
100+
target_link_libraries(${NAME} opencv_imgproc)
101+
target_link_libraries(${NAME} OpenMP::OpenMP_CXX)
102+
target_link_libraries(${NAME} hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
103+
target_link_libraries(${NAME} Eigen3::Eigen)
104+
endfunction()
105+
106+
upsp_add_executable(psp_process cpp/exec/psp_process.cpp)
107+
target_link_libraries(psp_process MPI::MPI_CXX)
108+
target_link_libraries(psp_process OpenMP::OpenMP_CXX)
109+
target_link_libraries(psp_process hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
110+
111+
add_executable(xyz_scalar_to_tbl cpp/exec/xyz_scalar_to_tbl.cpp)
112+
add_executable(xyz_scalar_to_tbl_delta cpp/exec/xyz_scalar_to_tbl_delta.cpp)
113+
114+
upsp_add_executable(upsp-extract-frames cpp/exec/upsp_extract_frames.cpp)
115+
116+
add_executable(add_field cpp/exec/add_field.cpp cpp/utils/asyncIO.c)
117+
target_link_libraries(add_field ${LIBRT})
118+
target_link_libraries(add_field hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
119+
120+
add_executable(upsp_matrix_transpose cpp/exec/upsp_matrix_transpose.cpp)
121+
target_link_libraries(upsp_matrix_transpose MPI::MPI_CXX)
122+
target_link_libraries(upsp_matrix_transpose OpenMP::OpenMP_CXX)
123+
124+
125+
# GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main
126+
# TODO could automate smoke tests and gtest unit tests leveraging CTest
127+
find_package(GTest CONFIG REQUIRED)
128+
upsp_add_executable(
129+
run_tests
130+
cpp/test/run_tests.cpp
131+
cpp/test/test_filtering.cpp
132+
cpp/test/test_general_utils.cpp
133+
cpp/test/test_grid_utils.cpp
134+
cpp/test/test_grids.cpp
135+
cpp/test/test_models.cpp
136+
cpp/test/test_mraw.cpp
137+
cpp/test/test_p3dmodel.cpp
138+
cpp/test/test_plot3d.cpp
139+
cpp/test/test_psphdf5.cpp
140+
cpp/test/test_trimodel.cpp
141+
)
142+
target_link_libraries(run_tests GTest::gtest GTest::gtest_main)
143+
target_link_libraries(run_tests OpenMP::OpenMP_CXX)
144+
target_link_libraries(run_tests hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
145+
146+
# Documentation (custom cmake macros from pandocology)
147+
# NOTE: pandoc options ref: https://pandoc.org/MANUAL.html
148+
string(TIMESTAMP TODAY "%Y-%m-%d")
149+
function(upsp_add_document TARGET FILENAME)
150+
list(APPEND UPSP_ADD_DOCUMENT_TARGETS ${TARGET})
151+
set(UPSP_ADD_DOCUMENT_TARGETS ${UPSP_ADD_DOCUMENT_TARGETS} PARENT_SCOPE)
152+
get_filename_component(BASENAME_WE ${FILENAME} NAME_WE)
153+
add_document(
154+
TARGET ${TARGET}_docx
155+
OUTPUT_FILE ${BASENAME_WE}.docx
156+
SOURCES ${FILENAME}
157+
RESOURCE_DIRS docs/md/static
158+
PANDOC_DIRECTIVES --to docx
159+
--from markdown+pandoc_title_block+table_captions+simple_tables+yaml_metadata_block
160+
--filter pandoc-xnos
161+
--mathjax
162+
--standalone
163+
--toc
164+
--number-sections
165+
--metadata date=${TODAY}
166+
NO_EXPORT_PRODUCT
167+
)
168+
169+
add_document(
170+
TARGET ${TARGET}_html
171+
OUTPUT_FILE ${BASENAME_WE}.html
172+
SOURCES ${FILENAME}
173+
RESOURCE_DIRS docs/md/static
174+
PANDOC_DIRECTIVES --to html
175+
--from markdown+pandoc_title_block+table_captions+simple_tables+yaml_metadata_block
176+
--filter pandoc-xnos
177+
--mathjax
178+
--standalone
179+
--toc
180+
--number-sections
181+
--metadata date=${TODAY}
182+
-c static/upsp-styles.css
183+
-A static/upsp-footer.html
184+
NO_EXPORT_PRODUCT
185+
)
186+
187+
add_dependencies(${TARGET}_html ${TARGET}_docx)
188+
endfunction()
189+
190+
function(upsp_serialize_document_depends)
191+
list(LENGTH UPSP_ADD_DOCUMENT_TARGETS NUMBER_TARGETS)
192+
if (${NUMBER_TARGETS} LESS_EQUAL 1)
193+
return()
194+
endif()
195+
math(EXPR START "1")
196+
math(EXPR STOP "${NUMBER_TARGETS} - 1")
197+
foreach(THIS_IDX RANGE ${START} ${STOP})
198+
math(EXPR PREV_IDX "${THIS_IDX} - 1")
199+
list(GET UPSP_ADD_DOCUMENT_TARGETS ${THIS_IDX} THIS_TGT)
200+
list(GET UPSP_ADD_DOCUMENT_TARGETS ${PREV_IDX} PREV_TGT)
201+
add_dependencies(${THIS_TGT}_docx ${PREV_TGT}_html)
202+
endforeach()
203+
endfunction()
204+
205+
upsp_add_document(upsp_user_manual docs/md/upsp-user-manual.md)
206+
upsp_add_document(upsp_swdd docs/md/upsp-swdd.md)
207+
upsp_add_document(upsp_third_party_dependencies docs/md/upsp-third-party-dependencies.md)
208+
upsp_serialize_document_depends()
209+
210+
# INSTALLATION TARGETS
211+
212+
# Documentation install targets
213+
# A bit hacky but it works. Grab outputs from the build directory
214+
# after pandoc has been run (pandoc configured by the various
215+
# cmake pandocology macros) and copy them "by hand" to install location.
216+
install(
217+
FILES
218+
${CMAKE_CURRENT_BINARY_DIR}/upsp-swdd.docx
219+
${CMAKE_CURRENT_BINARY_DIR}/upsp-swdd.html
220+
${CMAKE_CURRENT_BINARY_DIR}/upsp-third-party-dependencies.docx
221+
${CMAKE_CURRENT_BINARY_DIR}/upsp-third-party-dependencies.html
222+
${CMAKE_CURRENT_BINARY_DIR}/upsp-user-manual.docx
223+
${CMAKE_CURRENT_BINARY_DIR}/upsp-user-manual.html
224+
DESTINATION docs
225+
)
226+
install(
227+
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/static
228+
DESTINATION docs
229+
)
230+
231+
install(
232+
TARGETS
233+
add_field
234+
psp_process
235+
upsp
236+
upsp-extract-frames
237+
upsp_kdtree
238+
upsp_utils
239+
upsp_video
240+
xyz_scalar_to_tbl
241+
LIBRARY DESTINATION lib
242+
RUNTIME DESTINATION bin
243+
)
244+
245+
install(
246+
PROGRAMS
247+
scripts/upsp-external-calibration
248+
scripts/upsp-make-processing-tree
249+
scripts/upsp-kulite-comparison
250+
scripts/upsp-plotting
251+
scripts/upsp-unity-export
252+
DESTINATION
253+
bin
254+
)
255+
256+
# Python install process could be a bit cleaner.
257+
# - Ideally we would make use of setuputils.
258+
# - However, there are a couple modules built with
259+
# pybind11 (e.g., raycast.so) that rely on other
260+
# solibs built by the project. If a user wants
261+
# to import them in Python, then either
262+
# a) raycast.so has to have its RPATH populated with
263+
# the path to the folder containing the solib
264+
# dependencies, or
265+
# b) the user has to have their LD_LIBRARY_PATH set.
266+
# Clearly, option (a) is preferred for Python
267+
# development, and option (b) is an annoying
268+
# workaround.
269+
# - By using the CMake install() command on the pybind11
270+
# CMake targets, their RPATH's are updated correctly
271+
# so option (a) works. However, this precludes using
272+
# setuputils.
273+
# - There is probably a way to configure CMake via
274+
# setuputils calls to properly replicate the behavior
275+
# but I haven't figured it out yet.
276+
install(TARGETS cine raycast LIBRARY DESTINATION python/upsp)
277+
278+
# The rest of the non-pybind11 Python modules are then
279+
# just manually copied here. We explicitly list out all files
280+
# for safety (in general, globs in build scripts aren't best
281+
# practice).
282+
install(
283+
FILES
284+
python/upsp/__init__.py
285+
DESTINATION
286+
python/upsp
287+
)
288+
289+
install(
290+
FILES
291+
python/upsp/processing/context.py
292+
python/upsp/processing/grids.py
293+
python/upsp/processing/io.py
294+
python/upsp/processing/kulite_processing.py
295+
python/upsp/processing/kulite_utilities.py
296+
python/upsp/processing/p3d_conversions.py
297+
python/upsp/processing/p3d_utilities.py
298+
python/upsp/processing/plot3d.py
299+
python/upsp/processing/tree.py
300+
python/upsp/processing/unity_conversions.py
301+
DESTINATION
302+
python/upsp/processing
303+
)
304+
305+
install(
306+
FILES
307+
python/upsp/cam_cal_utils/external_calibrate.py
308+
python/upsp/cam_cal_utils/img_utils.py
309+
python/upsp/cam_cal_utils/parsers.py
310+
python/upsp/cam_cal_utils/photogrammetry.py
311+
python/upsp/cam_cal_utils/target_bumping.py
312+
python/upsp/cam_cal_utils/visibility.py
313+
python/upsp/cam_cal_utils/visualization.py
314+
DESTINATION
315+
python/upsp/cam_cal_utils
316+
)
317+
318+
install(
319+
FILES
320+
python/upsp/target_localization/blob_detector_methods.py
321+
python/upsp/target_localization/gaussian_fitting_methods.py
322+
DESTINATION
323+
python/upsp/target_localization
324+
)
325+
326+
install(
327+
FILES
328+
python/upsp/kulite_comparison/plotting.py
329+
python/upsp/kulite_comparison/selection.py
330+
python/upsp/kulite_comparison/spatial_queries.py
331+
DESTINATION
332+
python/upsp/kulite_comparison
333+
)
334+
335+
install(
336+
FILES
337+
python/upsp/processing/templates/add-field.sh.template
338+
python/upsp/processing/templates/gltf-viewer.html.template
339+
python/upsp/processing/templates/launcher.sh.template
340+
python/upsp/processing/templates/run-step-parallel.sh.template
341+
python/upsp/processing/templates/run-step-serial.sh.template
342+
DESTINATION
343+
python/upsp/processing/templates
344+
)
345+
346+
# Define the two required variables before including
347+
# the source code for watching a git repository.
348+
set(PRE_CONFIGURE_FILE "scripts/version")
349+
set(POST_CONFIGURE_FILE "${CMAKE_BINARY_DIR}/version")
350+
include(cmake/git_watcher.cmake)
351+
352+
install(
353+
PROGRAMS
354+
${CMAKE_BINARY_DIR}/version
355+
DESTINATION
356+
${CMAKE_INSTALL_PREFIX}
357+
)
358+
359+
install(
360+
FILES
361+
scripts/activate.sh
362+
scripts/activate.csh
363+
RELEASE.md
364+
DESTINATION
365+
${CMAKE_INSTALL_PREFIX}
366+
)
367+

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# UNDER CONSTRUCTION
2+
3+

0 commit comments

Comments
 (0)