Skip to content

Commit

Permalink
add a simple gui & update the docker file (#42)
Browse files Browse the repository at this point in the history
* Encapsulating feature processor

* add point viewer

* reformat

* index on dev_gui: 2f4fefa reformat

* remove useless code

* remove useless code & add "Open Sparse Model"

* Change file layout

* update readme.txt

* update name

* use XRPRIMER

* update docker file

* update docker image

* use old version cuda for CICD

* update cmake
  • Loading branch information
oneLOH authored May 20, 2024
1 parent 3439677 commit 1cbed85
Show file tree
Hide file tree
Showing 116 changed files with 2,862 additions and 5,409 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run:
shell: bash -l {0}
container:
image: openxrlab/xrsfm_runtime:ubuntu1804_x64_cu116
image: openxrlab/xrsfm_runtime:ubuntu20.04_cu11.6.1
credentials:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_PWD}}
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/SiftGPU/CuTexImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Permission to use, copy, modify and distribute this software and its
// documentation for educational, research and non-profit purposes, without
// fee, and without a written agreement is hereby granted, provided that
// the above copyright notice and the following paragraph appear in all copies.
// the above copyright notice and the following paragraph appear in all copies.
//
// The University of North Carolina at Chapel Hill make no representations
// about the suitability of this software for any purpose. It is provided
Expand Down
21 changes: 0 additions & 21 deletions 3rdparty/apriltag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ if(BUILD_PYTHON_WRAPPER)
endif(BUILD_PYTHON_WRAPPER)

if (NOT Python3_NOT_FOUND AND NOT Numpy_NOT_FOUND AND PYTHONLIBS_FOUND AND BUILD_PYTHON_WRAPPER)
# TODO deal with both python2/3
execute_process(COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/python_build_flags.py OUTPUT_VARIABLE PY_OUT)
set(PY_VARS CFLAGS LDFLAGS LINKER EXT_SUFFIX)
cmake_parse_arguments(PY "" "${PY_VARS}" "" ${PY_OUT})
Expand All @@ -160,23 +159,3 @@ execute_process(COMMAND python3 -m site --user-site OUTPUT_VARIABLE PY_DEST)
string(STRIP ${PY_DEST} PY_DEST)
install(FILES ${PROJECT_BINARY_DIR}/apriltag${PY_EXT_SUFFIX} DESTINATION ${PY_DEST})
endif (NOT Python3_NOT_FOUND AND NOT Numpy_NOT_FOUND AND PYTHONLIBS_FOUND AND BUILD_PYTHON_WRAPPER)


# Examples
# apriltag_demo
# add_executable(apriltag_demo example/apriltag_demo.c)
# target_link_libraries(apriltag_demo apriltag)

# # opencv_demo
# find_package(OpenCV 4.0)
# if(OpenCV_FOUND)
# add_executable(opencv_demo example/opencv_demo.cc)
# target_link_libraries(opencv_demo apriltag ${OpenCV_LIBRARIES} stdc++fs)
# set_target_properties(opencv_demo PROPERTIES CXX_STANDARD 17)
# install(TARGETS opencv_demo RUNTIME DESTINATION bin)
# else()
# message(WARNING "OpenCV not found: Not building demo")
# endif(OpenCV_FOUND)

# # install example programs
# install(TARGETS apriltag_demo RUNTIME DESTINATION bin)
1 change: 0 additions & 1 deletion 3rdparty/apriltag/apriltag.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,6 @@ static void refine_edges(apriltag_detector_t *td, image_u8_t *im_orig,
double Cxy = Mxy / N - Ex * Ey;
double Cyy = Myy / N - Ey * Ey;

// TODO: Can replace this with same code as in fit_line.
double normal_theta = .5 * atan2f(-2 * Cxy, (Cyy - Cxx));
nx = cosf(normal_theta);
ny = sinf(normal_theta);
Expand Down
2 changes: 0 additions & 2 deletions 3rdparty/apriltag/common/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ int getopt_parse(getopt_t *gopt, int argc, char *argv[], int showErrors) {
}

if (goo->type == GOO_STRING_TYPE) {
// TODO: check whether next argument is an option, denoting
// missing argument
if ((i + 1) < zarray_size(toks)) {
char *val = NULL;
Expand Down Expand Up @@ -272,7 +271,6 @@ int getopt_parse(getopt_t *gopt, int argc, char *argv[], int showErrors) {
if ((i + 1) < zarray_size(toks)) {
char *val = NULL;
zarray_get(toks, i + 1, &val);
// TODO: allow negative numerical values for short-name
// options ?
if (val[0] == '-') {
okay = 0;
Expand Down
2 changes: 0 additions & 2 deletions 3rdparty/apriltag/common/homography.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ matd_t *homography_to_model_view(const matd_t *H, double F, double G, double A,
double R12 = R20 * R01 - R00 * R21;
double R22 = R00 * R11 - R10 * R01;

// TODO XXX: Improve rotation matrix by applying polar decomposition.

return matd_create_data(4, 4,
(double[]){R00, R01, R02, TX, R10, R11, R12, TY,
R20, R21, R22, TZ, 0, 0, 0, 1});
Expand Down
9 changes: 0 additions & 9 deletions 3rdparty/apriltag/common/matd.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,6 @@ matd_t *matd_inverse(const matd_t *x) {
return NULL; // unreachable
}

// TODO Optimization: Some operations we could perform in-place,
// saving some memory allocation work. E.g., ADD, SUBTRACT. Just need
// to make sure that we don't do an in-place modification on a matrix
// that was an input argument!

// handle right-associative operators, greedily consuming them. These
// include transpose and inverse. This is called by the main recursion
// method.
static inline matd_t *matd_op_gobble_right(const char *expr, int *pos,
matd_t *acc, matd_t **garb,
int *garbpos) {
Expand Down Expand Up @@ -1091,7 +1083,6 @@ static matd_svd_t matd_svd_tall(matd_t *A, int flags) {
for (int i = 0; i < vlen; i++)
v[i] /= mag;

// TODO: optimize these multiplications
// matd_t *Q = matd_identity(A->ncols);
// for (int i = 0; i < vlen; i++)
// for (int j = 0; j < vlen; j++)
Expand Down
1 change: 0 additions & 1 deletion 3rdparty/apriltag/common/pjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ static inline uint32_t bd_get_offset(struct bit_decoder *bd) {
}

static int pjpeg_decode_buffer(struct pjpeg_decode_state *pjd) {
// XXX TODO Include sanity check that this is actually a JPG

struct bit_decoder bd;
memset(&bd, 0, sizeof(struct bit_decoder));
Expand Down
2 changes: 0 additions & 2 deletions 3rdparty/apriltag/common/time_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ int32_t timeutil_usleep(int64_t useconds) {
Sleep(useconds / 1000);
return 0;
#else
// unistd.h function, but usleep is obsoleted in POSIX.1-2008.
// TODO: Eventually, rewrite this to use nanosleep
return usleep(useconds);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/json/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9888,7 +9888,7 @@ class binary_reader {
*/
bool get_ubjson_string(string_t &result, const bool get_char = true) {
if (get_char) {
get(); // TODO(niels): may we ignore N here?
get();
}

if (JSON_HEDLEY_UNLIKELY(
Expand Down
70 changes: 47 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)

project(xrsfm)

option(XRPRIMER_ENABLED "Buinding based on XRPRIMER, if available" ON)
option(XRPRIMER_ENABLED "Buinding based on XRPRIMER, if available" OFF)
option(CUDA_ENABLED "Whether to enable CUDA, if available" ON)
set(CUDA_ARCHS "Auto" CACHE STRING "List of CUDA architectures for which to \
generate code, e.g., Auto, All, Maxwell, Pascal, ...")
Expand All @@ -28,11 +28,17 @@ find_package(OpenGL REQUIRED)

find_package(GLEW REQUIRED)

find_package(Qt5 5.4 COMPONENTS Core OpenGL Widgets)

set(CUDA_MIN_VERSION "7.0")
if (CUDA_ENABLED)
find_package(CUDA ${CUDA_MIN_VERSION} QUIET)
message(STATUS "found")
find_package(CUDA QUIET)
message(STATUS "Found CUDA ")
message(STATUS " Includes : ${CUDA_INCLUDE_DIRS}")
message(STATUS " Libraries : ${CUDA_LIBRARIES}")
endif ()


################################################################################
# Compiler specific configuration
################################################################################
Expand All @@ -53,10 +59,9 @@ endif ()
if (CUDA_FOUND)
if (CUDA_ENABLED)
add_definitions("-DCUDA_ENABLED")

include(${CMAKE_CURRENT_SOURCE_DIR}/SelectCudaComputeArch.cmake)

CUDA_SELECT_NVCC_ARCH_FLAGS(CUDA_ARCH_FLAGS ${CUDA_ARCHS})
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "native")
endif()

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${CUDA_ARCH_FLAGS}")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -D_FORCE_INLINES")
Expand All @@ -67,7 +72,8 @@ if (CUDA_FOUND)
add_definitions("-D_MWAITXINTRIN_H_INCLUDED")

message(STATUS "Enabling CUDA support (version: ${CUDA_VERSION_STRING},"
" archs: ${CUDA_ARCH_FLAGS_readable})")
" archs: ${CMAKE_CUDA_ARCHITECTURES})")

else ()
set(CUDA_FOUND OFF)
message(STATUS "Disabling CUDA support")
Expand Down Expand Up @@ -98,6 +104,7 @@ add_library(xrsfm
src/base/map.cc

src/feature/sift_extractor.cc
src/feature/feature_processor.cc
src/feature/feature_extraction.cc
src/feature/feature_processing.cc
src/feature/match_expansion.cc
Expand All @@ -108,49 +115,62 @@ add_library(xrsfm

src/geometry/pnp.cc
src/geometry/essential.cc
src/geometry/triangluate_svd.cc
src/geometry/triangulate_light.cc
src/geometry/track_processor.cc

src/geometry/colmap/base/triangulation.cc
src/geometry/colmap/estimators/absolute_pose.cc
src/geometry/colmap/estimators/triangulation.cc
src/geometry/colmap/estimators/polynomial.cc
src/geometry/colmap/estimators/fundamental_matrix.cc
src/geometry/colmap/estimators/utils.cc
src/geometry/colmap/util/random.cc
src/geometry/colmap/optim/random_sampler.cc
src/geometry/colmap/optim/combination_sampler.cc
src/geometry/colmap/optim/support_measurement.cc

src/optimization/ba_solver.cc
src/mapper/incremental_mapper.cc
src/utility/io_ecim.cc

src/colmap/estimators/absolute_pose.cc
src/colmap/estimators/polynomial.cc
src/colmap/estimators/fundamental_matrix.cc
src/colmap/ransac/random_sampler.cc
src/colmap/ransac/combination_sampler.cc
src/colmap/ransac/support_measurement.cc
src/colmap/ransac/random.cc
src/colmap/ui/point_painter.cc
src/colmap/ui/project_widget.cc
src/colmap/ui/model_viewer_widget.cc
src/colmap/ui/resources.qrc
)


qt5_add_resources(RESOURCES src/colmap/ui/resources.qrc)

target_include_directories(xrsfm
PUBLIC
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/geometry/colmap
${CMAKE_SOURCE_DIR}/src/colmap
${CMAKE_SOURCE_DIR}/3rdparty/SiftGPU
${CMAKE_SOURCE_DIR}/3rdparty/apriltag
${EIGEN3_INCLUDE_DIRS}
${Qt5Core_INCLUDE_DIRS}
${Qt5OpenGL_INCLUDE_DIRS}
${Qt5Widgets_INCLUDE_DIRS}
)

if(XRPRIMER_ENABLED)
target_link_libraries(xrsfm
stdc++fs
sift_gpu
XRPrimer::xrprimer
${OpenCV_LIBS}
${GTEST_LIBRARIES}
sift_gpu
${Qt5Core_LIBRARIES}
${Qt5OpenGL_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
else ()
target_link_libraries(xrsfm
stdc++fs
sift_gpu
${OpenCV_LIBS}
${CERES_LIBRARIES}
sift_gpu
${Qt5Core_LIBRARIES}
${Qt5OpenGL_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
endif()

Expand All @@ -174,3 +194,7 @@ target_link_libraries(rec_1dsfm xrsfm)

add_executable(rec_kitti src/rec_kitti.cc)
target_link_libraries(rec_kitti xrsfm)

add_executable(xrsfm_gui src/xrsfm_gui.cc)
target_link_libraries(xrsfm_gui xrsfm)
target_sources(xrsfm_gui PRIVATE ${RESOURCES})
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nvidia/cuda:10.2-devel-ubuntu18.04
FROM nvidia/cuda:11.6.1-devel-ubuntu20.04

ENV DEBIAN_FRONTEND=noninteractive

Expand All @@ -14,6 +14,11 @@ RUN apt-get install -y \
python3-pip \
libglew-dev \
libatlas-base-dev \
libgtest-dev
libgtest-dev \
qtbase5-dev \
libqt5opengl5-dev \
libeigen3-dev \
libceres-dev \
libopencv-dev

Run pip3 install numpy
Loading

0 comments on commit 1cbed85

Please sign in to comment.