From b8f0413fd85603e0d4a93bc232ef098339250f2d Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Tue, 23 Mar 2021 04:31:07 -0700 Subject: [PATCH 01/23] some fix to build but linking still fails --- 3DReconDemo.cpp | 2 +- SegmentedMesh.cpp | 8 ++++---- include/SegmentedMesh.h | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/3DReconDemo.cpp b/3DReconDemo.cpp index 2f73faf7..b0dad27b 100644 --- a/3DReconDemo.cpp +++ b/3DReconDemo.cpp @@ -200,7 +200,7 @@ int main(int argc, char **argv) slam.AddKeyFrameAvailableHandler(saveFrameHandler, "saveframe"); } - SegmentedMesh * mesh = new SegmentedMesh(voxel_size, voxel_size * 5, open3d::integration::TSDFVolumeColorType::RGB8, block_size); + SegmentedMesh * mesh = new SegmentedMesh(voxel_size, voxel_size * 5, open3d::pipelines::integration::TSDFVolumeColorType::RGB8, block_size); std::vector intrinsics = camera.getColorIntrinsics(); auto intr = open3d::camera::PinholeCameraIntrinsic(640, 480, intrinsics[0], intrinsics[1], intrinsics[2], intrinsics[3]); diff --git a/SegmentedMesh.cpp b/SegmentedMesh.cpp index 7c203753..5cfec3f6 100644 --- a/SegmentedMesh.cpp +++ b/SegmentedMesh.cpp @@ -4,7 +4,7 @@ namespace ark { SegmentedMesh::SegmentedMesh(double voxel_length, double sdf_trunc, - open3d::integration::TSDFVolumeColorType color_type, + open3d::pipelines::integration::TSDFVolumeColorType color_type, double block_length) : block_length_(block_length), voxel_length_(voxel_length), @@ -12,7 +12,7 @@ namespace ark { color_type_(color_type){ Eigen::Vector3i * temp = ¤t_block; temp = NULL; - active_volume = new open3d::integration::ScalableTSDFVolume(voxel_length_, + active_volume = new open3d::pipelines::integration::ScalableTSDFVolume(voxel_length_, sdf_trunc_, color_type_); } @@ -98,7 +98,7 @@ namespace ark { completed_meshes.push_back(completed_mesh); - active_volume = new open3d::integration::ScalableTSDFVolume(voxel_length_, sdf_trunc_, color_type_); + active_volume = new open3d::pipelines::integration::ScalableTSDFVolume(voxel_length_, sdf_trunc_, color_type_); active_volume_keyframe = latest_keyframe; active_volume_map_index = active_map_index; @@ -326,4 +326,4 @@ namespace ark { } -} +} \ No newline at end of file diff --git a/include/SegmentedMesh.h b/include/SegmentedMesh.h index 1f88bf0e..4247a3e2 100644 --- a/include/SegmentedMesh.h +++ b/include/SegmentedMesh.h @@ -1,12 +1,12 @@ #pragma once -#include "Open3D/Integration/ScalableTSDFVolume.h" -#include "Open3D/Visualization/Utility/DrawGeometry.h" -#include "Open3D/IO/ClassIO/TriangleMeshIO.h" -#include "Open3D/IO/ClassIO/ImageIO.h" -#include "Open3D/Geometry/PointCloud.h" -#include "Open3D/Geometry/TriangleMesh.h" -#include "Open3D/Camera/PinholeCameraIntrinsic.h" +#include "open3d/pipelines/integration/ScalableTSDFVolume.h" +#include "open3d/visualization/utility/DrawGeometry.h" +#include "open3d/io/TriangleMeshIO.h" +#include "open3d/io/ImageIO.h" +#include "open3d/geometry/PointCloud.h" +#include "open3d/geometry/TriangleMesh.h" +#include "open3d/camera/PinholeCameraIntrinsic.h" #include "Types.h" #include #include @@ -21,7 +21,7 @@ namespace ark { public: SegmentedMesh(double voxel_length, double sdf_trunc, - open3d::integration::TSDFVolumeColorType color_type, + open3d::pipelines::integration::TSDFVolumeColorType color_type, double block_length); //~SegmentedMesh(); @@ -63,7 +63,7 @@ namespace ark { double block_length_; double sdf_trunc_; double voxel_length_; - open3d::integration::TSDFVolumeColorType color_type_; + open3d::pipelines::integration::TSDFVolumeColorType color_type_; private: @@ -82,7 +82,7 @@ namespace ark { //stores current scalable tsdf volume - open3d::integration::ScalableTSDFVolume * active_volume; + open3d::pipelines::integration::ScalableTSDFVolume * active_volume; MapKeyFrame::Ptr active_volume_keyframe; int active_volume_map_index = 0; @@ -104,4 +104,4 @@ namespace ark { std::mutex keyFrameLock; std::mutex meshLock; }; -} +} \ No newline at end of file From c625e77098540f847cb733e7849b403cb610f6fd Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Wed, 24 Mar 2021 03:05:52 -0700 Subject: [PATCH 02/23] no open3d, segmentedMesh, only replaying --- CMakeLists.txt | 274 +++++++++++------------------------------- SlamReplaying.cpp | 129 ++++++++++---------- glfwManager.cpp | 91 +++++++------- include/glfwManager.h | 54 ++++----- 4 files changed, 204 insertions(+), 344 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d68601d0..298771fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required( VERSION 3.5 ) -cmake_policy( VERSION 3.5 ) +cmake_minimum_required( VERSION 3.18.4 ) +cmake_policy( VERSION 3.18.4 ) project( OpenARK ) @@ -16,29 +16,11 @@ if( NOT CMAKE_BUILD_TYPE ) endif() set( LIB_NAME "OpenARK" ) -set( DEMO_NAME "OpenARK_hand_demo" ) -set( AVATAR_DEMO_NAME "OpenARK_avatar_demo") -set( SLAM_DEMO_NAME "OpenARK_SLAM_demo") -set( 3DRECON_DATA_NAME "3dRecon_Data_Recording") -set( DATA_RECORDING_NAME "OpenARK_data_recording") -set( SLAM_RECORDING_NAME "OpenARK_slam_recording") +set( SLAM_DEMO_NAME "OpenARK_slam_demo") set( SLAM_REPLAYING_NAME "OpenARK_slam_replaying") -set( TEST_NAME "OpenARK_test" ) -set( UNITY_PLUGIN_NAME "UnityPlugin" ) -option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" OFF ) -option( BUILD_AVATAR_DEMO "BUILD_AVATAR_DEMO" OFF) option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" ON) -option( BUILD_3DRECON_DEMO "BUILD_3DRECON_DEMO" ON) -option( BUILD_DATA_RECORDING "BUILD_DATA_RECORDING" OFF) -option( BUILD_SLAM_RECORDING "BUILD_SLAM_RECORDING" ON) option( BUILD_SLAM_REPLAYING "BUILD_SLAM_REPLAYING" ON) -option( BUILD_TESTS "BUILD_TESTS" OFF ) -option( BUILD_UNITY_PLUGIN "BUILD_UNITY_PLUGIN" ON ) -option( USE_AZURE_KINECT_SDK "USE_AZURE_KINECT_SDK" OFF ) -option( USE_RSSDK2 "USE_RSSDK2" ON ) -option( USE_RSSDK "USE_RSSDK" OFF ) -option( USE_PMDSDK "USE_PMDSDK" OFF ) include( CheckCXXCompilerFlag ) CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 ) @@ -54,7 +36,6 @@ else() message( STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler." ) endif() -message(STATUS "using c++17") add_definitions(-DEIGEN_DONT_ALIGN=1) add_definitions(-DEIGEN_DONT_VECTORIZE=1) @@ -70,6 +51,12 @@ endif( DEFINED ENV{ARK_DEPS_DIR} ) set( Boost_USE_STATIC_LIBS ON ) set( Boost_USE_STATIC ON ) +#flag +FIND_PACKAGE(Boost REQUIRED) +include_directories(${Boost_INCLUDE_DIR}) +IF(Boost_FOUND) + MESSAGE(STATUS "Found Boost: ${Boost_LIBRARIES}") +ENDIF(Boost_FOUND) # require Eigen if( NOT DEFINED EIGEN_INCLUDE_DIRS ) @@ -145,7 +132,6 @@ else() include_directories($ENV{DLoopDetector_INCLUDE_DIRS}) endif( DEFINED ENV{ARK_DEPS_DIR} ) - # require Okvis find_package( okvis REQUIRED ) include_directories(${OKVIS_INCLUDE_DIRS}) @@ -187,11 +173,11 @@ find_package( brisk REQUIRED ) include_directories(${BRISK_INCLUDE_DIRS}) message(STATUS "Found Brisk: ${BRISK_INCLUDE_DIRS} ${BRISK_LIBRARIES}") -# require Open3D -find_package( Open3D REQUIRED ) -include_directories(${Open3D_INCLUDE_DIRS}) -link_directories(${Open3D_LIBRARY_DIRS}) -message(STATUS "Found Open3D: ${Open3D_INCLUDE_DIRS} ${Open3D_LIBRARIES}") +# # require Open3D +# find_package( Open3D REQUIRED ) +# include_directories(${Open3D_INCLUDE_DIRS}) +# link_directories(${Open3D_LIBRARY_DIRS}) +# message(STATUS "Found Open3D: ${Open3D_INCLUDE_DIRS} ${Open3D_LIBRARIES}") set( _FOUND_CAMERA_LIB OFF ) set( k4a_FOUND OFF ) @@ -212,24 +198,6 @@ if( USE_RSSDK2 OR NOT _FOUND_CAMERA_LIB ) set( _FOUND_CAMERA_LIB ON ) endif() -set( RSSDK_FOUND OFF ) -if( USE_RSSDK OR NOT _FOUND_CAMERA_LIB ) - find_package( RSSDK ) - if( RSSDK_FOUND ) - message( STATUS "Found RSSDK: ${RSSDK_INCLUDE_DIR}" ) - endif( RSSDK_FOUND ) - set( _FOUND_CAMERA_LIB ON ) -endif() - -set( PMDSDK_FOUND OFF ) -if( USE_PMDSDK OR NOT _FOUND_CAMERA_LIB ) - find_package( PMDSDK REQUIRED ) - if( PMDSDK_FOUND ) - message( STATUS "Found PMDSDK: ${PMDSDK_INCLUDE_DIR}" ) - endif( PMDSDK_FOUND ) - set( _FOUND_CAMERA_LIB ON ) -endif() - include_directories( ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} @@ -248,7 +216,7 @@ set( ${DBoW2_LIBRARIES} ${OPENGV_LIBRARIES} ${Boost_LIBRARIES} - ${Open3D_LIBRARIES} + #${Open3D_LIBRARIES} ) add_definitions( @@ -282,7 +250,7 @@ set( glfwManager.cpp OkvisSLAMSystem.cpp SaveFrame.cpp - SegmentedMesh.cpp + #SegmentedMesh.cpp ) set( @@ -320,7 +288,7 @@ set( ${INCLUDE_DIR}/CorrespondenceRansac.h ${INCLUDE_DIR}/UKF.h ${INCLUDE_DIR}/SaveFrame.h - ${INCLUDE_DIR}/SegmentedMesh.h + #${INCLUDE_DIR}/SegmentedMesh.h stdafx.h ) @@ -352,14 +320,6 @@ else() include_directories(${GLFW_INCLUDE_DIR}) endif() -if( NOT k4a_FOUND ) - set( _AZURE_KINECT_SDK_ "//" ) -else() - set( SOURCES ${SOURCES} AzureKinectCamera.cpp ) - set( HEADERS ${HEADERS} ${INCLUDE_DIR}/AzureKinectCamera.h ) - set( DEPENDENCIES ${DEPENDENCIES} k4a::k4a ) -endif( NOT k4a_FOUND ) - if( NOT realsense2_FOUND ) set( _RSSDK2_ "//" ) else() @@ -369,22 +329,6 @@ else() set( DEPENDENCIES ${DEPENDENCIES} ${realsense2_LIBRARY} ) endif( NOT realsense2_FOUND ) -if( NOT RSSDK_FOUND ) - set( _RSSDK_ "//" ) -else() - include_directories( ${RSSDK_INCLUDE_DIR} ) - set( SOURCES ${SOURCES} SR300Camera.cpp Converter.cpp ) - set( HEADERS ${HEADERS} ${INCLUDE_DIR}/SR300Camera.h ${INCLUDE_DIR}/Converter.h ) -endif( NOT RSSDK_FOUND ) - -if( NOT PMDSDK_FOUND ) - set( _PMDSDK_ "//" ) -else() - include_directories( ${PMDSDK_INCLUDE_DIR} ) - set( SOURCES ${SOURCES} PMDCamera.cpp ) - set( HEADERS ${HEADERS} ${INCLUDE_DIR}/PMDCamera.h ) - set( DEPENDENCIES ${DEPENDENCIES} ${PMDSDK_LIBRARIES} ) -endif( NOT PMDSDK_FOUND ) if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) set( _DEBUG_ "//" ) @@ -393,124 +337,69 @@ endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) configure_file( Version.h.in ${INCLUDE_DIR}/Version.h ) set( HEADERS ${HEADERS} ${INCLUDE_DIR}/Version.h ) -# MSVC special options -if ( MSVC ) - # MSVC precompiled header - set( PRECOMPILED_BINARY "$(IntDir)/stdafx.pch" ) - set( PRECOMPILED_HEADER "stdafx.h" ) - set( PRECOMPILED_SOURCE "stdafx.cpp" ) - - set_source_files_properties( ${PRECOMPILED_SOURCE} - PROPERTIES COMPILE_FLAGS "/Yc\"${PRECOMPILED_HEADER}\" /Fp\"${PRECOMPILED_BINARY}\"" - OBJECT_OUTPUTS "${PRECOMPILED_HEADER}" ) - set_source_files_properties( ${SOURCES} - PROPERTIES COMPILE_FLAGS "/Yu\"${PRECOMPILED_HEADER}\" /FI\"${PRECOMPILED_HEADER}\" /Fp\"${PRECOMPILED_BINARY}\"" - OBJECT_DEPENDS "${PRECOMPILED_HEADER}" ) - set( SOURCES ${SOURCES} ${PRECOMPILED_SOURCE} ) - add_definitions( -D_CRT_SECURE_NO_WARNINGS ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /Ot /Z7 /Zm1010 /MP" ) - set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT /DEBUG" ) - set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT" ) - set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD" ) -endif ( MSVC ) - # download required files if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") message( STATUS "Downloading Brisk vocab to config/brisk_vocab.bn..." ) file(DOWNLOAD "https://github.com/sxyu/OpenARK-Deps/releases/download/0.0.1/brisk_vocab.bn" "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") endif() -if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/face/lbfmodel.yaml") - message( STATUS "Downloading face landmarks model to config/face/lbfmodel.yaml..." ) - file(DOWNLOAD "https://raw.githubusercontent.com/kurnianggoro/GSOC2017/master/data/lbfmodel.yaml" "${PROJECT_SOURCE_DIR}/config/face/lbfmodel.yaml") -endif() - -if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/pose-net/pose.caffemodel") - message( STATUS "Downloading pose net model to config/pose-net/pose.caffemodel..." ) - file(DOWNLOAD "https://github.com/sxyu/OpenARK-Deps/releases/download/0.0.1/pose.caffemodel" "${PROJECT_SOURCE_DIR}/config/pose-net/pose.caffemodel") -endif() - -if (NOT EXISTS "${PROJECT_SOURCE_DIR}/data/avatar-model/model.pcd") - message( WARNING "SMPL model files are not present, so the avatar module will not work. To use the avatar module and/or run the avatar demo, you will need to download the SMPL model manually. Please follow the instructions in data/avatar-model/README.md. Note that SMPL is available for non-commercial, academic research purposes only." ) -endif() - add_library( ${LIB_NAME} STATIC "${INCLUDE_DIR}/Core.h" ${SOURCES} ${HEADERS} ) -set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME - "openark_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}" ) + set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME "openark") +# set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME + # "openark_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}" ) set_property( TARGET ${LIB_NAME} PROPERTY DBG_POSTFIX d ) target_link_libraries( ${LIB_NAME} ${DEPENDENCIES} ) target_include_directories( ${LIB_NAME} PRIVATE ${INCLUDE_DIR} ) -if ( MSVC ) - set_target_properties( ${LIB_NAME} PROPERTIES COMPILE_FLAGS "/MD" ) -endif() -if( ${BUILD_HAND_DEMO} ) - add_executable( ${DEMO_NAME} HandDemo.cpp ) - target_include_directories( ${DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) - target_link_libraries( ${DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - set_target_properties( ${DEMO_NAME} PROPERTIES OUTPUT_NAME ${DEMO_NAME} ) - set_target_properties( ${DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -endif( ${BUILD_HAND_DEMO} ) - -if( ${BUILD_AVATAR_DEMO} ) - add_executable( ${AVATAR_DEMO_NAME} AvatarDemo.cpp ) - target_include_directories( ${AVATAR_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) - target_link_libraries( ${AVATAR_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - set_target_properties( ${AVATAR_DEMO_NAME} PROPERTIES OUTPUT_NAME ${AVATAR_DEMO_NAME} ) - set_target_properties( ${AVATAR_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -endif( ${BUILD_AVATAR_DEMO} ) - -if( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) - add_executable( ${SLAM_DEMO_NAME} SlamDemo435i.cpp ) - target_include_directories( ${SLAM_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) - set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES OUTPUT_NAME ${SLAM_DEMO_NAME} ) - set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) - if ( MSVC ) - target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - else() - target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) - endif ( MSVC ) - add_executable( d435i_intrinsics_writer D435iCalibWriter.cpp ) - target_include_directories( d435i_intrinsics_writer PRIVATE ${INCLUDE_DIR} ) - target_link_libraries( d435i_intrinsics_writer ${DEPENDENCIES} ${LIB_NAME} ) - #set_target_properties( d435i_intrinsics_writer PROPERTIES OUTPUT_NAME d435i_intrinsics_writer ) - set_target_properties( d435i_intrinsics_writer PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -endif( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) - -if( ${BUILD_3DRECON_DEMO} AND realsense2_FOUND ) - add_executable( ${3DRECON_DATA_NAME} 3DReconDemo.cpp ) - target_include_directories( ${3DRECON_DATA_NAME} PRIVATE ${INCLUDE_DIR} ) - set_target_properties( ${3DRECON_DATA_NAME} PROPERTIES OUTPUT_NAME ${3DRECON_DATA_NAME} ) - set_target_properties( ${3DRECON_DATA_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) - if ( MSVC ) - target_link_libraries( ${3DRECON_DATA_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - else() - target_link_libraries( ${3DRECON_DATA_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) - endif ( MSVC ) -endif( ${BUILD_3DRECON_DEMO} AND realsense2_FOUND ) - - -if( ${BUILD_DATA_RECORDING} ) - add_executable( ${DATA_RECORDING_NAME} DataRecording.cpp ) - target_include_directories( ${DATA_RECORDING_NAME} PRIVATE ${INCLUDE_DIR} ) - target_link_libraries( ${DATA_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - set_target_properties( ${DATA_RECORDING_NAME} PROPERTIES OUTPUT_NAME ${DATA_RECORDING_NAME} ) - set_target_properties( ${DATA_RECORDING_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -endif( ${BUILD_DATA_RECORDING} ) - -if( ${BUILD_SLAM_RECORDING} ) - add_executable( ${SLAM_RECORDING_NAME} SlamRecording.cpp ) - target_include_directories( ${SLAM_RECORDING_NAME} PRIVATE ${INCLUDE_DIR} ) - set_target_properties( ${SLAM_RECORDING_NAME} PROPERTIES OUTPUT_NAME ${SLAM_RECORDING_NAME} ) - set_target_properties( ${SLAM_RECORDING_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) - if ( MSVC ) - target_link_libraries( ${SLAM_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - else() - target_link_libraries( ${SLAM_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) - endif ( MSVC ) -endif( ${BUILD_SLAM_RECORDING} ) +# if( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) +# add_executable( ${SLAM_DEMO_NAME} SlamDemo435i.cpp ) +# target_include_directories( ${SLAM_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) +# set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES OUTPUT_NAME ${SLAM_DEMO_NAME} ) +# set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +# if ( MSVC ) +# target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) +# else() +# target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) +# endif ( MSVC ) +# add_executable( d435i_intrinsics_writer D435iCalibWriter.cpp ) +# target_include_directories( d435i_intrinsics_writer PRIVATE ${INCLUDE_DIR} ) +# target_link_libraries( d435i_intrinsics_writer ${DEPENDENCIES} ${LIB_NAME} ) +# #set_target_properties( d435i_intrinsics_writer PROPERTIES OUTPUT_NAME d435i_intrinsics_writer ) +# set_target_properties( d435i_intrinsics_writer PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +# endif( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) + +if(${BUILD_SLAM_REPLAYING} ) + add_executable(moonwon + SlamReplaying.cpp + ${INCLUDE_DIR}/Util.h + ${INCLUDE_DIR}/MockD435iCamera.h + ${INCLUDE_DIR}/OkvisSLAMSystem.h + ${INCLUDE_DIR}/glfwManager.h + ${INCLUDE_DIR}/concurrency.h + ) + target_link_libraries(moonwon + ${OpenCV_LIBRARIES} + ${PCL_LIBRARIES} + ${GLOG_LIBRARIES} #${CXSPARSE_LIBRARIES} + ${SuiteSparse_LIBRARIES} + ${OKVIS_LIBRARIES} + ${CERES_LIBRARIES} + ${BRISK_LIBRARIES} + ${DBoW2_LIBRARIES} + ${OPENGV_LIBRARIES} + ${Boost_LIBRARIES} + #${Open3D_LIBRARIES} + ${LIB_NAME} + ) + target_include_directories( moonwon PRIVATE + "${PROJECT_SOURCE_DIR}/include" + ${OKVIS_INCLUDE_DIRS} + ${INCLUDE_DIR} + ) +endif(${BUILD_SLAM_REPLAYING} ) + if( ${BUILD_SLAM_REPLAYING} ) add_executable( ${SLAM_REPLAYING_NAME} SlamReplaying.cpp ) @@ -524,35 +413,6 @@ if( ${BUILD_SLAM_REPLAYING} ) endif ( MSVC ) endif( ${BUILD_SLAM_REPLAYING} ) -# Unity plugin currently only supports Windows -if( ${BUILD_UNITY_PLUGIN} AND MSVC ) - add_library( ${UNITY_PLUGIN_NAME} SHARED "unity/native/UnityInterface.cpp" "unity/native/UnityInterface.h" "unity/README.md" ) - set( HEADERS ${HEADERS} "unity/native/UnityInterface.h" ) - target_link_libraries( ${UNITY_PLUGIN_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - if ( MSVC ) - set_target_properties( ${UNITY_PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "/MD" ) - endif ( MSVC ) - set_property( TARGET ${UNITY_PLUGIN_NAME} PROPERTY DBG_POSTFIX d ) - target_include_directories( ${UNITY_PLUGIN_NAME} PRIVATE ${INCLUDE_DIR} "unity/native" ) - set_target_properties( ${UNITY_PLUGIN_NAME} PROPERTIES OUTPUT_NAME "openark_unity_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}_native" ) -endif( ${BUILD_UNITY_PLUGIN} AND MSVC ) - -if( ${BUILD_TESTS} ) - if( NOT EXISTS ${PROJECT_SOURCE_DIR}/OpenARK_test ) - execute_process( - COMMAND git clone https://github.com/augcog/OpenARK_test.git - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) - endif( NOT EXISTS ${PROJECT_SOURCE_DIR}/OpenARK_test ) - - add_executable( ${TEST_NAME} "OpenARK_test/test.cpp" "OpenARK_test/TestCamera.cpp" "OpenARK_test/TestCamera.h" ) - set( HEADERS ${HEADERS} "OpenARK_test/TestCamera.h" ) - - target_link_libraries( ${TEST_NAME} ${DEPENDENCIES} ${LIB_NAME} ) - set_target_properties( ${TEST_NAME} PROPERTIES - COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) - - target_include_directories( ${TEST_NAME} PRIVATE ${INCLUDE_DIR} ) -endif( ${BUILD_TESTS} ) # Create source group for headers source_group( "Header Files" FILES ${HEADERS} ) diff --git a/SlamReplaying.cpp b/SlamReplaying.cpp index 92427846..a2695e1d 100644 --- a/SlamReplaying.cpp +++ b/SlamReplaying.cpp @@ -74,12 +74,12 @@ int main(int argc, char **argv) vio_parameters_reader.getParameters(parameters); OkvisSLAMSystem slam(vocabFilename, parameters); - //setup display - if (!MyGUI::Manager::init()) - { - fprintf(stdout, "Failed to initialize GLFW\n"); - return -1; - } + // //setup display + // if (!MyGUI::Manager::init()) + // { + // fprintf(stdout, "Failed to initialize GLFW\n"); + // return -1; + // } printf("Camera initialization started...\n"); fflush(stdout); @@ -89,21 +89,21 @@ int main(int argc, char **argv) fflush(stdout); //Window for displaying the path - MyGUI::CameraWindow traj_win("Traj Viewer", 640 * 2, 480 * 2); - MyGUI::ARCameraWindow ar_win("AR Viewer", 640 * 2.5, 480 * 2.5, GL_LUMINANCE, GL_UNSIGNED_BYTE, 6.16403320e+02, 6.16171021e+02, 3.18104584e+02, 2.33643127e+02, 0.01, 100); - traj_win.set_pos(640 * 2.5, 100); - ar_win.set_pos(0, 100); + // MyGUI::CameraWindow traj_win("Traj Viewer", 640 * 2, 480 * 2); + // MyGUI::ARCameraWindow ar_win("AR Viewer", 640 * 2.5, 480 * 2.5, GL_LUMINANCE, GL_UNSIGNED_BYTE, 6.16403320e+02, 6.16171021e+02, 3.18104584e+02, 2.33643127e+02, 0.01, 100); + // traj_win.set_pos(640 * 2.5, 100); + // ar_win.set_pos(0, 100); std::map pathMap; - MyGUI::Axis axis1("axis1", .1); - MyGUI::Axis axis2("axis2", 1); - MyGUI::Grid grid1("grid1", 10, 1); - traj_win.add_object(&axis1); - traj_win.add_object(&axis2); - traj_win.add_object(&grid1); - ar_win.add_object(&axis1); - std::vector cubes; // Moon : Cause 2. b This line might be wrong. MyGUI::Object is also a class having FSVEO.But it's a pointer of that. So not sure. - std::vector> T_K_cubes; // Moon : Cause 2.a - std::vector> K_cubes; // Moon : Cause 2.b. MayKeyFrame is a class having members of FSVEO + // MyGUI::Axis axis1("axis1", .1); + // MyGUI::Axis axis2("axis2", 1); + // MyGUI::Grid grid1("grid1", 10, 1); + // traj_win.add_object(&axis1); + // traj_win.add_object(&axis2); + // traj_win.add_object(&grid1); + // ar_win.add_object(&axis1); + // std::vector cubes; // Moon : Cause 2. b This line might be wrong. MyGUI::Object is also a class having FSVEO.But it's a pointer of that. So not sure. + // std::vector> T_K_cubes; // Moon : Cause 2.a + // std::vector> K_cubes; // Moon : Cause 2.b. MayKeyFrame is a class having members of FSVEO int lastMapIndex_path = 0; //Recieves output from SLAM system and displays to the screen @@ -111,40 +111,40 @@ int main(int argc, char **argv) Eigen::Affine3d transform(frame->T_WC(3)); const auto mapIndex = slam.getActiveMapIndex(); - if (pathMap.find(mapIndex) == pathMap.end()) { - string name = "path"+std::to_string(mapIndex); - pathMap[mapIndex] = new MyGUI::Path{name, Eigen::Vector3d(1, 0, 0)}; // Moon : fine. - traj_win.add_object(pathMap[mapIndex]); - } - if (mapIndex < lastMapIndex_path) { - // pathMap[lastMapIndex_path]->clear(); - auto it = pathMap.cbegin(); - while(it != pathMap.cend()) { - auto curr = it++; - if (it->first > mapIndex) { - it->second->clear(); - } - } - } + // if (pathMap.find(mapIndex) == pathMap.end()) { + // string name = "path"+std::to_string(mapIndex); + // pathMap[mapIndex] = new MyGUI::Path{name, Eigen::Vector3d(1, 0, 0)}; // Moon : fine. + // // traj_win.add_object(pathMap[mapIndex]); + // } + // if (mapIndex < lastMapIndex_path) { + // // pathMap[lastMapIndex_path]->clear(); + // auto it = pathMap.cbegin(); + // while(it != pathMap.cend()) { + // auto curr = it++; + // if (it->first > mapIndex) { + // it->second->clear(); + // } + // } + // } if (lastMapIndex_path != mapIndex) { lastMapIndex_path = mapIndex; } - pathMap[mapIndex]->add_node(transform.translation()); - axis2.set_transform(transform); - ar_win.set_camera(transform); - ar_win.set_image(frame->images_[3]); - if (ar_win.clicked()) - { - - std::string cube_name = std::string("CubeNum") + std::to_string(cubes.size()); - MyGUI::Object *obj = new MyGUI::Cube(cube_name, 0.1, 0.1, 0.1); - obj->set_transform(transform); - cubes.push_back(obj); - T_K_cubes.push_back(frame->T_KS_); - K_cubes.push_back(frame->keyframe_); - std::cout << "Adding cube " << cube_name << std::endl; - ar_win.add_object(obj); //NOTE: this is bad, should change objects to shared_ptr - } + //pathMap[mapIndex]->add_node(transform.translation()); + //axis2.set_transform(transform); + // ar_win.set_camera(transform); + // ar_win.set_image(frame->images_[3]); + // if (ar_win.clicked()) + // { + + // std::string cube_name = std::string("CubeNum") + std::to_string(cubes.size()); + // MyGUI::Object *obj = new MyGUI::Cube(cube_name, 0.1, 0.1, 0.1); + // obj->set_transform(transform); + // cubes.push_back(obj); + // T_K_cubes.push_back(frame->T_KS_); + // K_cubes.push_back(frame->keyframe_); + // std::cout << "Adding cube " << cube_name << std::endl; + // ar_win.add_object(obj); //NOTE: this is bad, should change objects to shared_ptr + // } }); slam.AddFrameAvailableHandler(handler, "mapping"); @@ -157,16 +157,16 @@ int main(int argc, char **argv) std::vector> traj; // Moon : Cause 2.b slam.getTrajectory(traj); const auto mapIndex = slam.getActiveMapIndex(); - pathMap[mapIndex]->clear(); + //pathMap[mapIndex]->clear(); for (size_t i = 0; i < traj.size(); i++) { - pathMap[mapIndex]->add_node(traj[i].block<3, 1>(0, 3)); - } - for (size_t i = 0; i < cubes.size(); i++) - { - if (K_cubes[i] != nullptr) - cubes[i]->set_transform(Eigen::Affine3d(K_cubes[i]->T_WS() * T_K_cubes[i])); // Moon : Cause 3.a. const + & or & might be needed. + //pathMap[mapIndex]->add_node(traj[i].block<3, 1>(0, 3)); } + // for (size_t i = 0; i < cubes.size(); i++) + // { + // if (K_cubes[i] != nullptr) + // cubes[i]->set_transform(Eigen::Affine3d(K_cubes[i]->T_WS() * T_K_cubes[i])); // Moon : Cause 3.a. const + & or & might be needed. + // } }); slam.AddLoopClosureDetectedHandler(loopHandler, "trajectoryUpdate"); //run until display is closed @@ -174,10 +174,11 @@ int main(int argc, char **argv) camera.start(); int lastMapIndex = -1; - while (MyGUI::Manager::running()) + //while (MyGUI::Manager::running()) + while(1) { //Update the display - MyGUI::Manager::update(); + //MyGUI::Manager::update(); try { @@ -195,8 +196,8 @@ int main(int argc, char **argv) const auto &rgb = frame->images_[3]; const auto &depth = frame->images_[4]; - cv::imshow(std::string(camera.getModelName()) + " Infrared", infrared); - cv::imshow(std::string(camera.getModelName()) + " Depth", depth); + // cv::imshow(std::string(camera.getModelName()) + " Infrared", infrared); + // cv::imshow(std::string(camera.getModelName()) + " Depth", depth); std::vector> imuData; camera.getImuToTime(frame->timestamp_, imuData); @@ -223,9 +224,9 @@ int main(int argc, char **argv) } if (isReset) { - traj_win.msg_ = " *Reseting*"; + //traj_win.msg_ = " *Reseting*"; } else { - traj_win.msg_ = " "; + //traj_win.msg_ = " "; } int k = cv::waitKey(1); if (k == 'q' || k == 'Q' || k == 27) diff --git a/glfwManager.cpp b/glfwManager.cpp index 80829b49..9b1dc3f0 100644 --- a/glfwManager.cpp +++ b/glfwManager.cpp @@ -563,78 +563,77 @@ void Path::draw_obj() glEnable(GL_LIGHTING); } -void Mesh::draw_obj() -{ +// void Mesh::draw_obj() +// { - std::lock_guard guard(meshLock_); +// std::lock_guard guard(meshLock_); - Eigen::Matrix4d scene_mat; - glGetDoublev(GL_MODELVIEW_MATRIX, scene_mat.data()); - scene_mat = scene_mat*pose.matrix().inverse(); - glLoadMatrixd(scene_mat.data()); +// Eigen::Matrix4d scene_mat; +// glGetDoublev(GL_MODELVIEW_MATRIX, scene_mat.data()); +// scene_mat = scene_mat*pose.matrix().inverse(); +// glLoadMatrixd(scene_mat.data()); - for (int i = 0; i < mesh_vertices.size(); ++i) { +// for (int i = 0; i < mesh_vertices.size(); ++i) { - if (!mesh_enabled[i]) { - continue; - } +// if (!mesh_enabled[i]) { +// continue; +// } - std::vector vertices = mesh_vertices[i]; - std::vector colors = mesh_colors[i]; - std::vector triangles = mesh_triangles[i]; - Eigen::Affine3d transform(mesh_transforms[i]); +// std::vector vertices = mesh_vertices[i]; +// std::vector colors = mesh_colors[i]; +// std::vector triangles = mesh_triangles[i]; +// Eigen::Affine3d transform(mesh_transforms[i]); - transform = pose * transform; - //mesh_transforms[i] is c->w, we need w->c +// transform = pose * transform; +// //mesh_transforms[i] is c->w, we need w->c - glPushMatrix(); +// glPushMatrix(); - Eigen::AngleAxis R(transform.rotation()); - Eigen::Translation3d T(transform.translation()); +// Eigen::AngleAxis R(transform.rotation()); +// Eigen::Translation3d T(transform.translation()); - glRotated(180, 0, 1, 0); - glRotated(180, 0, 0, 1); +// glRotated(180, 0, 1, 0); +// glRotated(180, 0, 0, 1); - glTranslated(T.x(), T.y(), T.z()); - glRotated(R.angle() * 180 / 3.14159, R.axis().x(), R.axis().y(), R.axis().z()); +// glTranslated(T.x(), T.y(), T.z()); +// glRotated(R.angle() * 180 / 3.14159, R.axis().x(), R.axis().y(), R.axis().z()); - glDisable(GL_LIGHTING); +// glDisable(GL_LIGHTING); - glBegin(GL_TRIANGLES); +// glBegin(GL_TRIANGLES); - for (int i = 0; i < triangles.size(); i++) { +// for (int i = 0; i < triangles.size(); i++) { - Eigen::Vector3d vertex1 = vertices[triangles[i][0]]; - Eigen::Vector3d vertex2 = vertices[triangles[i][1]]; - Eigen::Vector3d vertex3 = vertices[triangles[i][2]]; +// Eigen::Vector3d vertex1 = vertices[triangles[i][0]]; +// Eigen::Vector3d vertex2 = vertices[triangles[i][1]]; +// Eigen::Vector3d vertex3 = vertices[triangles[i][2]]; - Eigen::Vector3d color1 = colors[triangles[i][0]]; - Eigen::Vector3d color2 = colors[triangles[i][1]]; - Eigen::Vector3d color3 = colors[triangles[i][2]]; +// Eigen::Vector3d color1 = colors[triangles[i][0]]; +// Eigen::Vector3d color2 = colors[triangles[i][1]]; +// Eigen::Vector3d color3 = colors[triangles[i][2]]; - glColor3f((color1[0] + color2[0] + color3[0]) / 3.0f, - (color1[1] + color2[1] + color3[1]) / 3.0f, - (color1[2] + color2[2] + color3[2]) / 3.0f); +// glColor3f((color1[0] + color2[0] + color3[0]) / 3.0f, +// (color1[1] + color2[1] + color3[1]) / 3.0f, +// (color1[2] + color2[2] + color3[2]) / 3.0f); - glVertex3f(vertex1[0], vertex1[1], vertex1[2]); - glVertex3f(vertex2[0], vertex2[1], vertex2[2]); - glVertex3f(vertex3[0], vertex3[1], vertex3[2]); - } +// glVertex3f(vertex1[0], vertex1[1], vertex1[2]); +// glVertex3f(vertex2[0], vertex2[1], vertex2[2]); +// glVertex3f(vertex3[0], vertex3[1], vertex3[2]); +// } - glEnd(); +// glEnd(); - glEnable(GL_LIGHTING); +// glEnable(GL_LIGHTING); - glPopMatrix(); +// glPopMatrix(); - } +// } -} +// } }//MyGUI - diff --git a/include/glfwManager.h b/include/glfwManager.h index 6da203d2..544ab47c 100644 --- a/include/glfwManager.h +++ b/include/glfwManager.h @@ -17,7 +17,7 @@ #include #include #include -#include "SegmentedMesh.h" +//#include "SegmentedMesh.h" #include @@ -350,43 +350,43 @@ class Path : public Object { } }; -class Mesh : public Object { -public: +// class Mesh : public Object { +// public: - EIGEN_MAKE_ALIGNED_OPERATOR_NEW +// EIGEN_MAKE_ALIGNED_OPERATOR_NEW - std::vector> mesh_vertices; - std::vector> mesh_colors; - std::vector> mesh_triangles; - std::vector> mesh_transforms; // Moon : Cause 2.a - std::vector mesh_enabled; +// std::vector> mesh_vertices; +// std::vector> mesh_colors; +// std::vector> mesh_triangles; +// std::vector> mesh_transforms; // Moon : Cause 2.a +// std::vector mesh_enabled; - // //threadsafe? - // int current_active_map; - // int archive_index; - // std::set enabled_meshes; +// // //threadsafe? +// // int current_active_map; +// // int archive_index; +// // std::set enabled_meshes; - ark::SegmentedMesh * mesh_; +// ark::SegmentedMesh * mesh_; - void draw_obj(); +// void draw_obj(); - Mesh(std::string name, ark::SegmentedMesh * mesh) - : Object(name) { - mesh_ = mesh; - } +// Mesh(std::string name, ark::SegmentedMesh * mesh) +// : Object(name) { +// mesh_ = mesh; +// } - void update_meshes() { - std::lock_guard guard(meshLock_); +// void update_meshes() { +// std::lock_guard guard(meshLock_); - mesh_->Render(mesh_vertices, mesh_colors, mesh_triangles, mesh_transforms, mesh_enabled); // Moon : Render is deprecated in the Master branch of OpenARK. This line might be wrong. +// mesh_->Render(mesh_vertices, mesh_colors, mesh_triangles, mesh_transforms, mesh_enabled); // Moon : Render is deprecated in the Master branch of OpenARK. This line might be wrong. - } +// } -protected: - std::mutex meshLock_; +// protected: +// std::mutex meshLock_; -}; +// }; -} //MyGUI +} //MyGUI \ No newline at end of file From 4230b93c9e4e0aa949bfaac1cdc039cd6872a9c4 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Wed, 24 Mar 2021 08:39:04 -0700 Subject: [PATCH 03/23] libSegmentedMesh.a --- CMakeLists.txt | 181 +++++++++++++++---------------------------------- 1 file changed, 55 insertions(+), 126 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 298771fa..04e5eca5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required( VERSION 3.18.4 ) -cmake_policy( VERSION 3.18.4 ) +cmake_minimum_required( VERSION 3.5 ) +cmake_policy( VERSION 3.5 ) project( OpenARK ) @@ -16,11 +16,29 @@ if( NOT CMAKE_BUILD_TYPE ) endif() set( LIB_NAME "OpenARK" ) -set( SLAM_DEMO_NAME "OpenARK_slam_demo") +set( DEMO_NAME "OpenARK_hand_demo" ) +set( AVATAR_DEMO_NAME "OpenARK_avatar_demo") +set( SLAM_DEMO_NAME "OpenARK_SLAM_demo") +set( 3DRECON_DATA_NAME "3dRecon_Data_Recording") +set( DATA_RECORDING_NAME "OpenARK_data_recording") +set( SLAM_RECORDING_NAME "OpenARK_slam_recording") set( SLAM_REPLAYING_NAME "OpenARK_slam_replaying") - -option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" ON) +set( TEST_NAME "OpenARK_test" ) +set( UNITY_PLUGIN_NAME "UnityPlugin" ) + +option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" OFF ) +option( BUILD_AVATAR_DEMO "BUILD_AVATAR_DEMO" OFF) +option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" OFF) +option( BUILD_3DRECON_DEMO "BUILD_3DRECON_DEMO" OFF) +option( BUILD_DATA_RECORDING "BUILD_DATA_RECORDING" OFF) +option( BUILD_SLAM_RECORDING "BUILD_SLAM_RECORDING" OFF) option( BUILD_SLAM_REPLAYING "BUILD_SLAM_REPLAYING" ON) +option( BUILD_TESTS "BUILD_TESTS" OFF ) +option( BUILD_UNITY_PLUGIN "BUILD_UNITY_PLUGIN" OFF ) +option( USE_AZURE_KINECT_SDK "USE_AZURE_KINECT_SDK" OFF ) +option( USE_RSSDK2 "USE_RSSDK2" OFF ) +option( USE_RSSDK "USE_RSSDK" OFF ) +option( USE_PMDSDK "USE_PMDSDK" OFF ) include( CheckCXXCompilerFlag ) CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 ) @@ -36,6 +54,7 @@ else() message( STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler." ) endif() +message(STATUS "using c++17") add_definitions(-DEIGEN_DONT_ALIGN=1) add_definitions(-DEIGEN_DONT_VECTORIZE=1) @@ -51,12 +70,6 @@ endif( DEFINED ENV{ARK_DEPS_DIR} ) set( Boost_USE_STATIC_LIBS ON ) set( Boost_USE_STATIC ON ) -#flag -FIND_PACKAGE(Boost REQUIRED) -include_directories(${Boost_INCLUDE_DIR}) -IF(Boost_FOUND) - MESSAGE(STATUS "Found Boost: ${Boost_LIBRARIES}") -ENDIF(Boost_FOUND) # require Eigen if( NOT DEFINED EIGEN_INCLUDE_DIRS ) @@ -132,6 +145,7 @@ else() include_directories($ENV{DLoopDetector_INCLUDE_DIRS}) endif( DEFINED ENV{ARK_DEPS_DIR} ) + # require Okvis find_package( okvis REQUIRED ) include_directories(${OKVIS_INCLUDE_DIRS}) @@ -173,21 +187,12 @@ find_package( brisk REQUIRED ) include_directories(${BRISK_INCLUDE_DIRS}) message(STATUS "Found Brisk: ${BRISK_INCLUDE_DIRS} ${BRISK_LIBRARIES}") -# # require Open3D -# find_package( Open3D REQUIRED ) -# include_directories(${Open3D_INCLUDE_DIRS}) -# link_directories(${Open3D_LIBRARY_DIRS}) -# message(STATUS "Found Open3D: ${Open3D_INCLUDE_DIRS} ${Open3D_LIBRARIES}") - -set( _FOUND_CAMERA_LIB OFF ) -set( k4a_FOUND OFF ) -if( USE_AZURE_KINECT_SDK ) - find_package( k4a ) - if( k4a_FOUND) - message( STATUS "Found k4a (Azure Kinect SDK)" ) - endif( k4a_FOUND ) - set( _FOUND_CAMERA_LIB ON ) -endif() +# require Open3D +find_package( Open3D REQUIRED ) +include_directories(${Open3D_INCLUDE_DIRS}) +#link_directories(${Open3D_LIBRARY_DIRS}) +message(STATUS "Found Open3D: ${Open3D_INCLUDE_DIRS} ${Open3D_LIBRARIES}") + set( realsense2_FOUND OFF ) if( USE_RSSDK2 OR NOT _FOUND_CAMERA_LIB ) @@ -198,6 +203,7 @@ if( USE_RSSDK2 OR NOT _FOUND_CAMERA_LIB ) set( _FOUND_CAMERA_LIB ON ) endif() + include_directories( ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} @@ -246,7 +252,7 @@ set( MockD435iCamera.cpp HumanDetector.cpp HumanBody.cpp - Avatar.cpp + #Avatar.cpp glfwManager.cpp OkvisSLAMSystem.cpp SaveFrame.cpp @@ -275,7 +281,7 @@ set( ${INCLUDE_DIR}/MockD435iCamera.h ${INCLUDE_DIR}/HumanDetector.h ${INCLUDE_DIR}/HumanBody.h - ${INCLUDE_DIR}/Avatar.h + #${INCLUDE_DIR}/Avatar.h ${INCLUDE_DIR}/nanoflann.hpp ${INCLUDE_DIR}/SLAMSystem.h ${INCLUDE_DIR}/OkvisSLAMSystem.h @@ -292,43 +298,6 @@ set( stdafx.h ) -if(WIN32) - add_subdirectory(third_party/glfw) - list(APPEND DEPENDENCIES glfw3) -else() - # Find glfw header - find_path(GLFW_INCLUDE_DIR NAMES GLFW/glfw3.h - PATHS /usr/X11R6/include - /usr/include/X11 - /opt/graphics/OpenGL/include - /opt/graphics/OpenGL/contrib/libglfw - /usr/local/include - /usr/include/GL - /usr/include - ) - # Find glfw library - find_library(GLFW_LIBRARIES NAMES glfw glfw3 - PATHS /usr/lib64 - /usr/lib - /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} - /usr/local/lib64 - /usr/local/lib - /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} - /usr/X11R6/lib - ) - list(APPEND DEPENDENCIES m ${GLFW_LIBRARIES} ${LIBUSB1_LIBRARIES}) - include_directories(${GLFW_INCLUDE_DIR}) -endif() - -if( NOT realsense2_FOUND ) - set( _RSSDK2_ "//" ) -else() - include_directories( ${realsense2_INCLUDE_DIR} ) - set( SOURCES ${SOURCES} RS2Camera.cpp D435iCamera.cpp ) - set( HEADERS ${HEADERS} ${INCLUDE_DIR}/RS2Camera.h ${INCLUDE_DIR}/D435iCamera.h ${INCLUDE_DIR}/D435iCalibWriter.h ) - set( DEPENDENCIES ${DEPENDENCIES} ${realsense2_LIBRARY} ) -endif( NOT realsense2_FOUND ) - if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) set( _DEBUG_ "//" ) @@ -337,70 +306,31 @@ endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) configure_file( Version.h.in ${INCLUDE_DIR}/Version.h ) set( HEADERS ${HEADERS} ${INCLUDE_DIR}/Version.h ) -# download required files -if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") - message( STATUS "Downloading Brisk vocab to config/brisk_vocab.bn..." ) - file(DOWNLOAD "https://github.com/sxyu/OpenARK-Deps/releases/download/0.0.1/brisk_vocab.bn" "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") -endif() -add_library( ${LIB_NAME} STATIC "${INCLUDE_DIR}/Core.h" ${SOURCES} ${HEADERS} ) - set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME "openark") -# set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME - # "openark_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}" ) +# build the SegmentedMesh library +add_library( SegmentedMesh STATIC + SegmentedMesh.cpp + include/SegmentedMesh.h +) -set_property( TARGET ${LIB_NAME} PROPERTY DBG_POSTFIX d ) -target_link_libraries( ${LIB_NAME} ${DEPENDENCIES} ) -target_include_directories( ${LIB_NAME} PRIVATE ${INCLUDE_DIR} ) +# and link it +target_link_libraries(SegmentedMesh + #${Open3D_LIBRARY_DIRS} + ${Open3D_LIBRARIES} +) +target_include_directories( SegmentedMesh PRIVATE ${Open3D_INCLUDE_DIRS} ) -# if( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) -# add_executable( ${SLAM_DEMO_NAME} SlamDemo435i.cpp ) -# target_include_directories( ${SLAM_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) -# set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES OUTPUT_NAME ${SLAM_DEMO_NAME} ) -# set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -# if ( MSVC ) -# target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) -# else() -# target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) -# endif ( MSVC ) -# add_executable( d435i_intrinsics_writer D435iCalibWriter.cpp ) -# target_include_directories( d435i_intrinsics_writer PRIVATE ${INCLUDE_DIR} ) -# target_link_libraries( d435i_intrinsics_writer ${DEPENDENCIES} ${LIB_NAME} ) -# #set_target_properties( d435i_intrinsics_writer PROPERTIES OUTPUT_NAME d435i_intrinsics_writer ) -# set_target_properties( d435i_intrinsics_writer PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) -# endif( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) - -if(${BUILD_SLAM_REPLAYING} ) - add_executable(moonwon - SlamReplaying.cpp - ${INCLUDE_DIR}/Util.h - ${INCLUDE_DIR}/MockD435iCamera.h - ${INCLUDE_DIR}/OkvisSLAMSystem.h - ${INCLUDE_DIR}/glfwManager.h - ${INCLUDE_DIR}/concurrency.h - ) - target_link_libraries(moonwon - ${OpenCV_LIBRARIES} - ${PCL_LIBRARIES} - ${GLOG_LIBRARIES} #${CXSPARSE_LIBRARIES} - ${SuiteSparse_LIBRARIES} - ${OKVIS_LIBRARIES} - ${CERES_LIBRARIES} - ${BRISK_LIBRARIES} - ${DBoW2_LIBRARIES} - ${OPENGV_LIBRARIES} - ${Boost_LIBRARIES} - #${Open3D_LIBRARIES} - ${LIB_NAME} - ) - target_include_directories( moonwon PRIVATE - "${PROJECT_SOURCE_DIR}/include" - ${OKVIS_INCLUDE_DIRS} - ${INCLUDE_DIR} - ) -endif(${BUILD_SLAM_REPLAYING} ) +# Making OpenARK Library +add_library( ${LIB_NAME} STATIC "${INCLUDE_DIR}/Core.h" ${SOURCES} ${HEADERS}) +set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME + "openark_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}" ) +set_property( TARGET ${LIB_NAME} PROPERTY DBG_POSTFIX d ) +target_link_libraries( ${LIB_NAME} ${DEPENDENCIES} SegmentedMesh) +target_include_directories( ${LIB_NAME} PRIVATE ${INCLUDE_DIR} ) +# Making slam_replaying if( ${BUILD_SLAM_REPLAYING} ) add_executable( ${SLAM_REPLAYING_NAME} SlamReplaying.cpp ) target_include_directories( ${SLAM_REPLAYING_NAME} PRIVATE ${INCLUDE_DIR} ) @@ -409,10 +339,9 @@ if( ${BUILD_SLAM_REPLAYING} ) if ( MSVC ) target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) else() - target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) + target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) endif ( MSVC ) endif( ${BUILD_SLAM_REPLAYING} ) - # Create source group for headers -source_group( "Header Files" FILES ${HEADERS} ) +source_group( "Header Files" FILES ${HEADERS} ) \ No newline at end of file From 8d004ef2522f34ab5b0639b96fa6d834be016faf Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Wed, 24 Mar 2021 08:45:54 -0700 Subject: [PATCH 04/23] libSegmentedMesh.a --- SegmentedMesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SegmentedMesh.cpp b/SegmentedMesh.cpp index 5cfec3f6..d8712053 100644 --- a/SegmentedMesh.cpp +++ b/SegmentedMesh.cpp @@ -1,4 +1,4 @@ -#include "SegmentedMesh.h" +#include "include/SegmentedMesh.h" namespace ark { From 3f206fce5cae9ed6f2d240ad039e91c3306a6e63 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Sun, 11 Apr 2021 23:44:48 -0700 Subject: [PATCH 05/23] OpenARK Support for Nvidia Jetson Xavier NX --- CMakeLists.txt | 275 +++++++++++++-- documentation/Jetson-NX-build-instructions.md | 314 ++++++++++++++++++ 2 files changed, 558 insertions(+), 31 deletions(-) create mode 100644 documentation/Jetson-NX-build-instructions.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e5eca5..0277ad6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required( VERSION 3.5 ) cmake_policy( VERSION 3.5 ) - project( OpenARK ) set( OpenARK_VERSION_MAJOR 0 ) set( OpenARK_VERSION_MINOR 9 ) @@ -26,6 +25,8 @@ set( SLAM_REPLAYING_NAME "OpenARK_slam_replaying") set( TEST_NAME "OpenARK_test" ) set( UNITY_PLUGIN_NAME "UnityPlugin" ) +# Options. +option( EIGEN_HACK "EIGEN_HACK" ON) option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" OFF ) option( BUILD_AVATAR_DEMO "BUILD_AVATAR_DEMO" OFF) option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" OFF) @@ -40,9 +41,15 @@ option( USE_RSSDK2 "USE_RSSDK2" OFF ) option( USE_RSSDK "USE_RSSDK" OFF ) option( USE_PMDSDK "USE_PMDSDK" OFF ) -include( CheckCXXCompilerFlag ) -CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 ) -CHECK_CXX_COMPILER_FLAG( "-std=c++0x" COMPILER_SUPPORTS_CXX0X ) +# Eigen hack for OpenARK Ubuntu version. +if( ${EIGEN_HACK} ) + add_definitions(-DEIGEN_DONT_ALIGN=1) + add_definitions(-DEIGEN_DONT_VECTORIZE=1) + +# NVIDIA Jetson Xavier NX +if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm*") + message(STATUS "ARM processor detected, will attempt to use NEON.") + add_definitions(-D__ARM_NEON__) if( COMPILER_SUPPORTS_CXX11 ) message(STATUS "c++11 supported") @@ -54,11 +61,6 @@ else() message( STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler." ) endif() -message(STATUS "using c++17") -add_definitions(-DEIGEN_DONT_ALIGN=1) -add_definitions(-DEIGEN_DONT_VECTORIZE=1) - - if ( CMAKE_COMPILER_IS_GNUCXX ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-deprecated-declarations -O3 -g" ) endif ( CMAKE_COMPILER_IS_GNUCXX ) @@ -190,9 +192,18 @@ message(STATUS "Found Brisk: ${BRISK_INCLUDE_DIRS} ${BRISK_LIBRARIES}") # require Open3D find_package( Open3D REQUIRED ) include_directories(${Open3D_INCLUDE_DIRS}) -#link_directories(${Open3D_LIBRARY_DIRS}) +link_directories(${Open3D_LIBRARY_DIRS}) message(STATUS "Found Open3D: ${Open3D_INCLUDE_DIRS} ${Open3D_LIBRARIES}") +set( _FOUND_CAMERA_LIB OFF ) +set( k4a_FOUND OFF ) +if( USE_AZURE_KINECT_SDK ) + find_package( k4a ) + if( k4a_FOUND) + message( STATUS "Found k4a (Azure Kinect SDK)" ) + endif( k4a_FOUND ) + set( _FOUND_CAMERA_LIB ON ) +endif() set( realsense2_FOUND OFF ) if( USE_RSSDK2 OR NOT _FOUND_CAMERA_LIB ) @@ -203,6 +214,23 @@ if( USE_RSSDK2 OR NOT _FOUND_CAMERA_LIB ) set( _FOUND_CAMERA_LIB ON ) endif() +set( RSSDK_FOUND OFF ) +if( USE_RSSDK OR NOT _FOUND_CAMERA_LIB ) + find_package( RSSDK ) + if( RSSDK_FOUND ) + message( STATUS "Found RSSDK: ${RSSDK_INCLUDE_DIR}" ) + endif( RSSDK_FOUND ) + set( _FOUND_CAMERA_LIB ON ) +endif() + +set( PMDSDK_FOUND OFF ) +if( USE_PMDSDK OR NOT _FOUND_CAMERA_LIB ) + find_package( PMDSDK REQUIRED ) + if( PMDSDK_FOUND ) + message( STATUS "Found PMDSDK: ${PMDSDK_INCLUDE_DIR}" ) + endif( PMDSDK_FOUND ) + set( _FOUND_CAMERA_LIB ON ) +endif() include_directories( ${OpenCV_INCLUDE_DIRS} @@ -222,7 +250,7 @@ set( ${DBoW2_LIBRARIES} ${OPENGV_LIBRARIES} ${Boost_LIBRARIES} - #${Open3D_LIBRARIES} + ${Open3D_LIBRARIES} ) add_definitions( @@ -252,11 +280,11 @@ set( MockD435iCamera.cpp HumanDetector.cpp HumanBody.cpp - #Avatar.cpp + Avatar.cpp glfwManager.cpp OkvisSLAMSystem.cpp SaveFrame.cpp - #SegmentedMesh.cpp + SegmentedMesh.cpp ) set( @@ -281,7 +309,7 @@ set( ${INCLUDE_DIR}/MockD435iCamera.h ${INCLUDE_DIR}/HumanDetector.h ${INCLUDE_DIR}/HumanBody.h - #${INCLUDE_DIR}/Avatar.h + ${INCLUDE_DIR}/Avatar.h ${INCLUDE_DIR}/nanoflann.hpp ${INCLUDE_DIR}/SLAMSystem.h ${INCLUDE_DIR}/OkvisSLAMSystem.h @@ -294,10 +322,71 @@ set( ${INCLUDE_DIR}/CorrespondenceRansac.h ${INCLUDE_DIR}/UKF.h ${INCLUDE_DIR}/SaveFrame.h - #${INCLUDE_DIR}/SegmentedMesh.h + ${INCLUDE_DIR}/SegmentedMesh.h stdafx.h ) +if(WIN32) + add_subdirectory(third_party/glfw) + list(APPEND DEPENDENCIES glfw3) +else() + # Find glfw header + find_path(GLFW_INCLUDE_DIR NAMES GLFW/glfw3.h + PATHS /usr/X11R6/include + /usr/include/X11 + /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/contrib/libglfw + /usr/local/include + /usr/include/GL + /usr/include + ) + # Find glfw library + find_library(GLFW_LIBRARIES NAMES glfw glfw3 + PATHS /usr/lib64 + /usr/lib + /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/local/lib64 + /usr/local/lib + /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} + /usr/X11R6/lib + ) + list(APPEND DEPENDENCIES m ${GLFW_LIBRARIES} ${LIBUSB1_LIBRARIES}) + include_directories(${GLFW_INCLUDE_DIR}) +endif() + +if( NOT k4a_FOUND ) + set( _AZURE_KINECT_SDK_ "//" ) +else() + set( SOURCES ${SOURCES} AzureKinectCamera.cpp ) + set( HEADERS ${HEADERS} ${INCLUDE_DIR}/AzureKinectCamera.h ) + set( DEPENDENCIES ${DEPENDENCIES} k4a::k4a ) +endif( NOT k4a_FOUND ) + +if( NOT realsense2_FOUND ) + set( _RSSDK2_ "//" ) +else() + include_directories( ${realsense2_INCLUDE_DIR} ) + set( SOURCES ${SOURCES} RS2Camera.cpp D435iCamera.cpp ) + set( HEADERS ${HEADERS} ${INCLUDE_DIR}/RS2Camera.h ${INCLUDE_DIR}/D435iCamera.h ${INCLUDE_DIR}/D435iCalibWriter.h ) + set( DEPENDENCIES ${DEPENDENCIES} ${realsense2_LIBRARY} ) +endif( NOT realsense2_FOUND ) + +if( NOT RSSDK_FOUND ) + set( _RSSDK_ "//" ) +else() + include_directories( ${RSSDK_INCLUDE_DIR} ) + set( SOURCES ${SOURCES} SR300Camera.cpp Converter.cpp ) + set( HEADERS ${HEADERS} ${INCLUDE_DIR}/SR300Camera.h ${INCLUDE_DIR}/Converter.h ) +endif( NOT RSSDK_FOUND ) + +if( NOT PMDSDK_FOUND ) + set( _PMDSDK_ "//" ) +else() + include_directories( ${PMDSDK_INCLUDE_DIR} ) + set( SOURCES ${SOURCES} PMDCamera.cpp ) + set( HEADERS ${HEADERS} ${INCLUDE_DIR}/PMDCamera.h ) + set( DEPENDENCIES ${DEPENDENCIES} ${PMDSDK_LIBRARIES} ) +endif( NOT PMDSDK_FOUND ) if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) set( _DEBUG_ "//" ) @@ -306,31 +395,125 @@ endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) configure_file( Version.h.in ${INCLUDE_DIR}/Version.h ) set( HEADERS ${HEADERS} ${INCLUDE_DIR}/Version.h ) +# MSVC special options +if ( MSVC ) + # MSVC precompiled header + set( PRECOMPILED_BINARY "$(IntDir)/stdafx.pch" ) + set( PRECOMPILED_HEADER "stdafx.h" ) + set( PRECOMPILED_SOURCE "stdafx.cpp" ) + + set_source_files_properties( ${PRECOMPILED_SOURCE} + PROPERTIES COMPILE_FLAGS "/Yc\"${PRECOMPILED_HEADER}\" /Fp\"${PRECOMPILED_BINARY}\"" + OBJECT_OUTPUTS "${PRECOMPILED_HEADER}" ) + set_source_files_properties( ${SOURCES} + PROPERTIES COMPILE_FLAGS "/Yu\"${PRECOMPILED_HEADER}\" /FI\"${PRECOMPILED_HEADER}\" /Fp\"${PRECOMPILED_BINARY}\"" + OBJECT_DEPENDS "${PRECOMPILED_HEADER}" ) + set( SOURCES ${SOURCES} ${PRECOMPILED_SOURCE} ) + add_definitions( -D_CRT_SECURE_NO_WARNINGS ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /Ot /Z7 /Zm1010 /MP" ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT /DEBUG" ) + set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT" ) + set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD" ) +endif ( MSVC ) + +# download required files +if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") + message( STATUS "Downloading Brisk vocab to config/brisk_vocab.bn..." ) + file(DOWNLOAD "https://github.com/sxyu/OpenARK-Deps/releases/download/0.0.1/brisk_vocab.bn" "${PROJECT_SOURCE_DIR}/config/brisk_vocab.bn") +endif() -# build the SegmentedMesh library -add_library( SegmentedMesh STATIC - SegmentedMesh.cpp - include/SegmentedMesh.h -) +if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/face/lbfmodel.yaml") + message( STATUS "Downloading face landmarks model to config/face/lbfmodel.yaml..." ) + file(DOWNLOAD "https://raw.githubusercontent.com/kurnianggoro/GSOC2017/master/data/lbfmodel.yaml" "${PROJECT_SOURCE_DIR}/config/face/lbfmodel.yaml") +endif() -# and link it -target_link_libraries(SegmentedMesh - #${Open3D_LIBRARY_DIRS} - ${Open3D_LIBRARIES} -) -target_include_directories( SegmentedMesh PRIVATE ${Open3D_INCLUDE_DIRS} ) +if (NOT EXISTS "${PROJECT_SOURCE_DIR}/config/pose-net/pose.caffemodel") + message( STATUS "Downloading pose net model to config/pose-net/pose.caffemodel..." ) + file(DOWNLOAD "https://github.com/sxyu/OpenARK-Deps/releases/download/0.0.1/pose.caffemodel" "${PROJECT_SOURCE_DIR}/config/pose-net/pose.caffemodel") +endif() +if (NOT EXISTS "${PROJECT_SOURCE_DIR}/data/avatar-model/model.pcd") + message( WARNING "SMPL model files are not present, so the avatar module will not work. To use the avatar module and/or run the avatar demo, you will need to download the SMPL model manually. Please follow the instructions in data/avatar-model/README.md. Note that SMPL is available for non-commercial, academic research purposes only." ) +endif() -# Making OpenARK Library -add_library( ${LIB_NAME} STATIC "${INCLUDE_DIR}/Core.h" ${SOURCES} ${HEADERS}) +add_library( ${LIB_NAME} STATIC "${INCLUDE_DIR}/Core.h" ${SOURCES} ${HEADERS} ) set_target_properties( ${LIB_NAME} PROPERTIES OUTPUT_NAME "openark_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}" ) set_property( TARGET ${LIB_NAME} PROPERTY DBG_POSTFIX d ) -target_link_libraries( ${LIB_NAME} ${DEPENDENCIES} SegmentedMesh) +target_link_libraries( ${LIB_NAME} ${DEPENDENCIES} ) target_include_directories( ${LIB_NAME} PRIVATE ${INCLUDE_DIR} ) -# Making slam_replaying +if ( MSVC ) + set_target_properties( ${LIB_NAME} PROPERTIES COMPILE_FLAGS "/MD" ) +endif() + +if( ${BUILD_HAND_DEMO} ) + add_executable( ${DEMO_NAME} HandDemo.cpp ) + target_include_directories( ${DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) + target_link_libraries( ${DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + set_target_properties( ${DEMO_NAME} PROPERTIES OUTPUT_NAME ${DEMO_NAME} ) + set_target_properties( ${DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +endif( ${BUILD_HAND_DEMO} ) + +if( ${BUILD_AVATAR_DEMO} ) + add_executable( ${AVATAR_DEMO_NAME} AvatarDemo.cpp ) + target_include_directories( ${AVATAR_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) + target_link_libraries( ${AVATAR_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + set_target_properties( ${AVATAR_DEMO_NAME} PROPERTIES OUTPUT_NAME ${AVATAR_DEMO_NAME} ) + set_target_properties( ${AVATAR_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +endif( ${BUILD_AVATAR_DEMO} ) + +if( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) + add_executable( ${SLAM_DEMO_NAME} SlamDemo435i.cpp ) + target_include_directories( ${SLAM_DEMO_NAME} PRIVATE ${INCLUDE_DIR} ) + set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES OUTPUT_NAME ${SLAM_DEMO_NAME} ) + set_target_properties( ${SLAM_DEMO_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) + if ( MSVC ) + target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + else() + target_link_libraries( ${SLAM_DEMO_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) + endif ( MSVC ) + add_executable( d435i_intrinsics_writer D435iCalibWriter.cpp ) + target_include_directories( d435i_intrinsics_writer PRIVATE ${INCLUDE_DIR} ) + target_link_libraries( d435i_intrinsics_writer ${DEPENDENCIES} ${LIB_NAME} ) + #set_target_properties( d435i_intrinsics_writer PROPERTIES OUTPUT_NAME d435i_intrinsics_writer ) + set_target_properties( d435i_intrinsics_writer PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +endif( ${BUILD_SLAM_DEMO} AND realsense2_FOUND ) + +if( ${BUILD_3DRECON_DEMO} AND realsense2_FOUND ) + add_executable( ${3DRECON_DATA_NAME} 3DReconDemo.cpp ) + target_include_directories( ${3DRECON_DATA_NAME} PRIVATE ${INCLUDE_DIR} ) + set_target_properties( ${3DRECON_DATA_NAME} PROPERTIES OUTPUT_NAME ${3DRECON_DATA_NAME} ) + set_target_properties( ${3DRECON_DATA_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) + if ( MSVC ) + target_link_libraries( ${3DRECON_DATA_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + else() + target_link_libraries( ${3DRECON_DATA_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) + endif ( MSVC ) +endif( ${BUILD_3DRECON_DEMO} AND realsense2_FOUND ) + + +if( ${BUILD_DATA_RECORDING} ) + add_executable( ${DATA_RECORDING_NAME} DataRecording.cpp ) + target_include_directories( ${DATA_RECORDING_NAME} PRIVATE ${INCLUDE_DIR} ) + target_link_libraries( ${DATA_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + set_target_properties( ${DATA_RECORDING_NAME} PROPERTIES OUTPUT_NAME ${DATA_RECORDING_NAME} ) + set_target_properties( ${DATA_RECORDING_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) +endif( ${BUILD_DATA_RECORDING} ) + +if( ${BUILD_SLAM_RECORDING} ) + add_executable( ${SLAM_RECORDING_NAME} SlamRecording.cpp ) + target_include_directories( ${SLAM_RECORDING_NAME} PRIVATE ${INCLUDE_DIR} ) + set_target_properties( ${SLAM_RECORDING_NAME} PROPERTIES OUTPUT_NAME ${SLAM_RECORDING_NAME} ) + set_target_properties( ${SLAM_RECORDING_NAME} PROPERTIES COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) + if ( MSVC ) + target_link_libraries( ${SLAM_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + else() + target_link_libraries( ${SLAM_RECORDING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) + endif ( MSVC ) +endif( ${BUILD_SLAM_RECORDING} ) + if( ${BUILD_SLAM_REPLAYING} ) add_executable( ${SLAM_REPLAYING_NAME} SlamReplaying.cpp ) target_include_directories( ${SLAM_REPLAYING_NAME} PRIVATE ${INCLUDE_DIR} ) @@ -339,9 +522,39 @@ if( ${BUILD_SLAM_REPLAYING} ) if ( MSVC ) target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} ) else() - target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) + target_link_libraries( ${SLAM_REPLAYING_NAME} ${DEPENDENCIES} ${LIB_NAME} GLU GL glut ) endif ( MSVC ) endif( ${BUILD_SLAM_REPLAYING} ) +# Unity plugin currently only supports Windows +if( ${BUILD_UNITY_PLUGIN} AND MSVC ) + add_library( ${UNITY_PLUGIN_NAME} SHARED "unity/native/UnityInterface.cpp" "unity/native/UnityInterface.h" "unity/README.md" ) + set( HEADERS ${HEADERS} "unity/native/UnityInterface.h" ) + target_link_libraries( ${UNITY_PLUGIN_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + if ( MSVC ) + set_target_properties( ${UNITY_PLUGIN_NAME} PROPERTIES COMPILE_FLAGS "/MD" ) + endif ( MSVC ) + set_property( TARGET ${UNITY_PLUGIN_NAME} PROPERTY DBG_POSTFIX d ) + target_include_directories( ${UNITY_PLUGIN_NAME} PRIVATE ${INCLUDE_DIR} "unity/native" ) + set_target_properties( ${UNITY_PLUGIN_NAME} PROPERTIES OUTPUT_NAME "openark_unity_${OpenARK_VERSION_MAJOR}_${OpenARK_VERSION_MINOR}_${OpenARK_VERSION_PATCH}_native" ) +endif( ${BUILD_UNITY_PLUGIN} AND MSVC ) + +if( ${BUILD_TESTS} ) + if( NOT EXISTS ${PROJECT_SOURCE_DIR}/OpenARK_test ) + execute_process( + COMMAND git clone https://github.com/augcog/OpenARK_test.git + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) + endif( NOT EXISTS ${PROJECT_SOURCE_DIR}/OpenARK_test ) + + add_executable( ${TEST_NAME} "OpenARK_test/test.cpp" "OpenARK_test/TestCamera.cpp" "OpenARK_test/TestCamera.h" ) + set( HEADERS ${HEADERS} "OpenARK_test/TestCamera.h" ) + + target_link_libraries( ${TEST_NAME} ${DEPENDENCIES} ${LIB_NAME} ) + set_target_properties( ${TEST_NAME} PROPERTIES + COMPILE_FLAGS ${TARGET_COMPILE_FLAGS} ) + + target_include_directories( ${TEST_NAME} PRIVATE ${INCLUDE_DIR} ) +endif( ${BUILD_TESTS} ) + # Create source group for headers source_group( "Header Files" FILES ${HEADERS} ) \ No newline at end of file diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md new file mode 100644 index 00000000..233af407 --- /dev/null +++ b/documentation/Jetson-NX-build-instructions.md @@ -0,0 +1,314 @@ +# Installing OpenARK for NVIDIA Jetson Xavier NX + +OpenARK provides support for Nvidia Jetson Xavier NX. +CPU : (6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64) +OS : L4T = {Linux Kernel 4.9, bootloader, NVIDIA drivers, flashing utilities, sample filesystem based on Ubuntu 18.04} + +## Preliminaries + +1. Install basic tools, dependencies: + +```sh +sudo apt update +sudo apt -y install g++ build-essential cmake cmake-gui git-core +sudo apt -y install pkg-config unzip ffmpeg qtbase5-dev python-dev python3-dev python-numpy python3-numpy +sudo apt -y install mpi-default-dev openmpi-bin openmpi-common libusb-1.0-0-dev libqhull* libusb-dev libgtest-dev +sudo apt -y install freeglut3-dev pkg-config libxmu-dev libxi-dev libphonon-dev libphonon-dev phonon-backend-gstreamer +sudo apt -y install phonon-backend-vlc graphviz mono-complete libflann-dev +``` + +2. `g++ --version` to check the g++ version. If it is less than 5, use the below commands to update GCC to version 5: + +```sh +sudo add-apt-repository ppa:ubuntu-toolchain-r/test +sudo apt update +sudo apt install gcc-5 g++-5 +sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 +sudo update-alternatives --set gcc "/usr/bin/gcc-5" +``` + +## Note: CMake Builds +For conciseness, in all sections below "build with CMake" will mean ... + +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j4 +sudo make install +``` +or a one-liner for cmake build is ... +```sh +mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=RELEASE .. && make -j4 && sudo make install +``` +Note that this installs the library. You may replace '4' in step 3 with any number of threads. The build process should not take too long. + +## Installing PCL, [Package: libpcl-dev (1.8.1+dfsg1-2ubuntu2)](https://packages.ubuntu.com/bionic/libpcl-dev) + +```sh +sudo apt -y install libpcl-* +``` + +## Installing OpenCV with Contrib, NVIDIA Jetson Xavier NX (ARM®v8.2 64-bit CPU) + +OpenCV 3.4.6, OpenCV_Contrib 3.4.6 and [Package: libopencv-dev (3.2.0+dfsg-4ubuntu0.1 and others)](https://packages.ubuntu.com/bionic/libopencv-dev) + +1. Install prerequisites +```sh +sudo apt -y install libopencv-dev libdc1394-22 libdc1394-22-dev libjpeg-dev libtiff5-dev libpng-dev +sudo apt -y install libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev +sudo apt -y install libv4l-dev libtbb-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev +sudo apt -y install libvorbis-dev libxvidcore-dev v4l-utils +sudo apt -y install liblapacke-dev libopenblas-dev libgdal-dev checkinstall +sudo apt -y install libssl-dev libopenexr-dev openexr +sudo apt -y install libprotobuf-dev protobuf-compiler +sudo apt -y install libgoogle-glog-dev libgflags-dev +sudo apt -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen +sudo apt -y install libgtk2.0-dev +sudo apt -y install libglfw3 libglfw3-dev +sudo apt -y libx264-dev libx265-dev libgtk2.0-dev libgtk-3-dev libatlas-base-dev gfortran python3-devsudo +sudo apt -y apt install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly +sudo apt -y gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 +sudo apt -ygstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev +``` + +Note that we add the Ubuntu 16 (Xenial) repo since some packages have been removed in later versions of Ubuntu. + +2. Download OpenCV and OpenCV_contrib sources: +```sh +wget -O opencv346.tar.gz https://github.com/opencv/opencv/archive/3.4.6.tar.gz +tar -xf opencv346.tar.gz +cd opencv-3.4.6 +wget -O contrib.tar.gz https://github.com/opencv/opencv_contrib/archive/3.4.6.tar.gz +tar -xf contrib.tar.gz +``` + +3. Build: + +``` sh +mkdir build && cd build +cmake -D CMAKE_BUILD_TYPE=RELEASE -DWITH_TBB=ON -DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-3.4.6/modules" -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF .. +make -j4 +sudo make install +``` +Again, -j4 may be replaced with any number of threads. + +## Eigen Hack for OpenARK Ubuntu Version. +The following sections directly have Eigen as a depenendency: +1. Ceres 1.14.0 +2. OpenGV +3. Okvis +4. OpenARK Ubuntu. + +In order to get Eigen working for OpenARK Ubuntu, the following lines of code must be added into the top level CMakesList.txt: +``` +add_definitions(-DEIGEN_DONT_ALIGN=1) +add_definitions(-DEIGEN_DONT_VECTORIZE=1) +``` +This will disable alignment as well as force the compiler to use c++17 standard. + +When it comes to OpenARK, make sure that the EIGEN_HACK option is ON. +`option( EIGEN_HACK "EIGEN_HACK" ON)` + +Now run the CMake instructions to build each library. + +## Continued Dependencies +### Installing Ceres 1.14.0 from source + +#### Installing [SuiteSparse 5.1.2](https://packages.ubuntu.com/bionic/libsuitesparse-dev) +SuiteSparse speeds up some of Ceres functions. However, if you want to prevent Suitesparse from crashing, you can skip downloading Suitesparse. You can still download Suitesparse and opt it out during the Ceres build process. +```sh +sudo apt install libsuitesparse-dev +``` +Download Ceres1.14.0 from source and build as follows. +1. `wget -O ceres114.tar.gz https://github.com/ceres-solver/ceres-solver/archive/1.14.0.tar.gz && tar -xf ceres114.tar.gz && cd ceres-solver-1.14.0` +2. Comment out lines 434-439 of the top level CMakeLists.txt +It should look like: (notice the #[[ open comment and ]] close comment) +``` +#[[if (CXX11 AND COMPILER_HAS_CXX11_FLAG) + # Update CMAKE_REQUIRED_FLAGS used by CheckCXXSourceCompiles to include + # -std=c++11 s/t we will detect the C++11 versions of unordered_map & + # shared_ptr if they exist. + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") +endif (CXX11 AND COMPILER_HAS_CXX11_FLAG)]] +``` +3. Apply the Fixing Eigen changes. +4. Build with CMake and install + +## Intalling OpenGV 1.0 +1. `git clone https://github.com/laurentkneip/opengv && cd opengv` +2. Apply the Fixing Eigen changes. +3. Build with CMake and install + +## Installing Brisk, Nvidia Jetson Xavier NX Version. +1. `git clone https://github.com/moonwonlee/brisk.git && cd brisk` +2. Build with CMake and install + +## Installing DBoW2 with Brisk Descriptors, Nvidia Jetson Xavier NX Version. +1. `git clone https://github.com/moonwonlee/DBoW2_Mod.git && cd DBoW2_Mod`. Note that this repository is a modified version of DBoW2_Mod to support Brisk descriptors. +2. Build with CMake and install + +## Installing DLoopDetector, Custom Version + +1. `git clone https://github.com/joemenke/DLoopDetector && cd DLoopDetector` +Note that this repository is a modified version of DLoopDetector. +2. Build with CMake and install + +## Installing Open3D (0.12.0), Nvidia Jetson Xavier NX Version. +### Install system dependencies +``` +sudo apt-get update -y +sudo apt-get install -y apt-utils build-essential git cmake +sudo apt-get install -y python3 python3-dev python3-pip +sudo apt-get install -y xorg-dev libglu1-mesa-dev +sudo apt-get install -y libblas-dev liblapack-dev liblapacke-dev +sudo apt-get install -y libsdl2-dev libc++-7-dev libc++abi-7-dev libxi-dev +sudo apt-get install -y clang-7 +``` +### Build. +``` +# Clone +git clone --recursive https://github.com/moonwonlee/Open3D.git +git checkout v12 +Install dependencies for Open3D. `./util/install_deps_ubuntu.sh assume-yes` +cd Open3D +mkdir build +cd build + +# Configure +# > Set -DBUILD_CUDA_MODULE=ON if CUDA is available (e.g. on Nvidia Jetson) +# > Set -DBUILD_GUI=ON if OpenGL is available (e.g. on Nvidia Jetson) +# > We don't support TensorFlow and PyTorch on ARM officially +cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_CUDA_MODULE=OFF \ + -DBUILD_GUI=OFF \ + -DBUILD_TENSORFLOW_OPS=OFF \ + -DBUILD_PYTORCH_OPS=OFF \ + -DBUILD_UNIT_TESTS=ON \ + -DCMAKE_INSTALL_PREFIX=~/open3d_install \ + -DPYTHON_EXECUTABLE=$(which python) \ + -DBUILD_PYTHON_MODULE=OFF \ + -DGLIBCXX_USE_CXX11_ABI=ON + .. + +# Build C++ library +make -j$(nproc) + +# Install C++ package (optional) +sudo make install + +# You can compile Open3D with -DBUILD_CUDA_MODULE=ON and -DBUILD_GUI=ON and the Open3D GUI app should be functional. We support CUDA v10.x, but other versions should work as well. + +# Run Open3D GUI (optional, available on when -DBUILD_GUI=ON) +./bin/Open3D/Open3D +``` +If the Open3D build system complains about CMake xxx or higher is required, get a CMake version higher than 3.18. +Follow this => Compile CMake from source : https://cmake.org/install/ + +## Installing Okvis+, NVIDIA Jetson Xavier NX Version. +1. `git clone https://github.com/moonwonlee/okvis.git && cd okvis` +2. Apply the Fixing Eigen changes. +3. To run okvis demo, turn on the demo option in the CMakeListst.txt. +`option (BUILD_APPS "Builds a demo app (which requires boost)" ON)` +4. Build with CMake and install. +5. Verify Okvis+ by running the demo application. +You will find a demo application in okvis_apps. It can process datasets in the ASL/ETH format. +https://github.com/ceres-solver/ceres-solver/releases/tag/1.14.0 +In order to run a minimal working example, follow the steps below: + +6. Download a dataset of your choice from http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets. Assuming you downloaded MH_01_easy/. You will find a corresponding calibration / estimator configuration in the config folder. + +7. Run the app as + `./okvis_app_synchronous path/to/okvis/config/config_fpga_p2_euroc.yaml path/to/mav0/` + +## Installing librealsense2, Nvidia Jetson Xavier NX Version. +Follow this : https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md + +### Optional: As a sanity check for librealsense2, +1. Connect the Intel RealSense depth camera and run: `realsense-viewer` to verify the installation. +2. plugin your RealSense camera (SR300 or D400) and run `rs-capture` to see if streams appear. +3. Verify that the kernel is updated : +`modinfo uvcvideo | grep "version:" should include realsense string` + +## Installing and Building OpenARK +1. Clone our repository: `git clone https://github.com/augcog/OpenARK`, or download the latest release. +2. `git checkout jetson-nx` +This already has the Eigen changes. Make sure that the EIGEN_HACK option is ON. +`option( EIGEN_HACK "EIGEN_HACK" ON)` + +Also make sure that add_definitions(-D__ARM_NEON__) is applied for ARM support. + +3. `cd OpenARK && mkdir build && cd build` to create build directory. + +4. `cmake .. -DCMAKE_BUILD_TYPE=Release` to run CMake. librealsense2 will be enabled by default. You can add `-DBUILD_AVATAR_DEMO` to build the avatar demo in addition to hand and SLAM, `-DBUILD_DATA_RECORDING` to build the data recording tool, and `-BUILD_TESTS` to build hand tests. `-DBUILD_UNITY_PLUGIN` is not available on Linux at the moment. + +5. `make -j4` to build. + +## Running the OpenARK demo applications +- These applications will show you how core functionalities of OpenARK work +- These applications will also help you to verify successful installation of OpenARK. +- The demos apps are in `build` directory. +- If you do not want to create these demo files, you can do turn off building them in `CMakeLists.txt`. +`option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" OFF )` + +### OpenARK_hand_demo +As a final sanity check, try running the demo executable in the build directory: +`./OpenARK-Hand-Demo` +You should see the hand detection and depth image windows. If you only see one window, drag it and see if the other is behind it. The static library is named: `libopenark_0_9_3.a`. + +### OpenARK_slam_demo +Run as `./OpenARK_SLAM_demo "/path/to/camera_intr.yaml" "../config/brisk_vocab.bn" "0.0"` + +Example `./OpenARK_SLAM_demo "../mycam_intr.yaml" "../config/brisk_vocab.bn" "0.0"` + +### OpenARK_slam_recording +#### Data Collected + depth + infrared + infrared2 + timestamp.txt + imu.txt + rgb + intrin.bin + meta.txt + +Run as `./OpenARK_slam_recording "/path/to/save/data" "/path/to/camera_yaml_file"` + +Example `sudo ./OpenARK_slam_recording "../data" "../mycam_intr.yaml"` + +### OpenARK_slam_replaying +Run as `./OpenARK_slam_replaying "/path/to/camera_yaml_file path/to/brisk_vocab.bn" "0.0" "/path/to/data/collected/by/openark_slam_recording"` + +Example `./OpenARK_slam_replaying "../mycam_intr.yaml" "../config/brisk_vocab.bn" "0.0" "../myroom4"` + +### 3dRecon_data_recording + +## Yaml File Explained +Please read the documentation of the individual parameters in the yaml file carefully. You have various options to trade-off accuracy and computational expense as well as to enable online calibration. + +## Installation Errors +Linux/Ubuntu is case-sensitive. + +## Debugging Tips +#### [Valgrind](https://www.valgrind.org/docs/manual/manual-core.html): +This tool can help you to locate segfaults and invalid write/reads + +Run as `G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=valgrind.log > output.txt 2>&1` + +Example `G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=valgrind.log ./OpenARK_SLAM_demo > output.txt 2>&1` + +#### gdb + gdb OpenARK_SLAM_DEMO + r + bt + + gdb --args okvis_app_synchronous ../config/config_fpga_p2_euroc.yaml /home/moon/Desktop/mav0/ + r + bt + +#### Debugging with print statements + printf("debug"); + fflush(stdout); + + From c2f1f4097d387d8a037d28bf56ff58676c1746a6 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:06:01 -0700 Subject: [PATCH 06/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index 233af407..ce43e279 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -1,13 +1,12 @@ # Installing OpenARK for NVIDIA Jetson Xavier NX -OpenARK provides support for Nvidia Jetson Xavier NX. -CPU : (6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64) -OS : L4T = {Linux Kernel 4.9, bootloader, NVIDIA drivers, flashing utilities, sample filesystem based on Ubuntu 18.04} +OpenARK provides support for Nvidia Jetson Xavier NX. +CPU : (6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64). +OS : L4T = {sample filesystem based on Ubuntu 18.04, Linux Kernel 4.9, bootloader, NVIDIA drivers, flashing utilities} ## Preliminaries 1. Install basic tools, dependencies: - ```sh sudo apt update sudo apt -y install g++ build-essential cmake cmake-gui git-core @@ -48,7 +47,7 @@ Note that this installs the library. You may replace '4' in step 3 with any numb sudo apt -y install libpcl-* ``` -## Installing OpenCV with Contrib, NVIDIA Jetson Xavier NX (ARM®v8.2 64-bit CPU) +## Installing OpenCV with Contrib, for Jetson NX. OpenCV 3.4.6, OpenCV_Contrib 3.4.6 and [Package: libopencv-dev (3.2.0+dfsg-4ubuntu0.1 and others)](https://packages.ubuntu.com/bionic/libopencv-dev) @@ -83,7 +82,6 @@ tar -xf contrib.tar.gz ``` 3. Build: - ``` sh mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -DWITH_TBB=ON -DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-3.4.6/modules" -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF .. @@ -92,21 +90,21 @@ sudo make install ``` Again, -j4 may be replaced with any number of threads. -## Eigen Hack for OpenARK Ubuntu Version. +## Eigen Hack for OpenARK Ubuntu and Jetson NX. The following sections directly have Eigen as a depenendency: 1. Ceres 1.14.0 2. OpenGV 3. Okvis 4. OpenARK Ubuntu. -In order to get Eigen working for OpenARK Ubuntu, the following lines of code must be added into the top level CMakesList.txt: +In order to get Eigen working for OpenARK Ubuntu and Jetson NX, the following lines of code must be added into the top level CMakesList.txt: ``` add_definitions(-DEIGEN_DONT_ALIGN=1) add_definitions(-DEIGEN_DONT_VECTORIZE=1) ``` This will disable alignment as well as force the compiler to use c++17 standard. -When it comes to OpenARK, make sure that the EIGEN_HACK option is ON. +When it comes to OpenARK, make sure that the EIGEN_HACK option is ON. This will apply the same Eigen hack above. `option( EIGEN_HACK "EIGEN_HACK" ON)` Now run the CMake instructions to build each library. @@ -139,21 +137,20 @@ endif (CXX11 AND COMPILER_HAS_CXX11_FLAG)]] 2. Apply the Fixing Eigen changes. 3. Build with CMake and install -## Installing Brisk, Nvidia Jetson Xavier NX Version. +## Installing Brisk, for Jetson NX. 1. `git clone https://github.com/moonwonlee/brisk.git && cd brisk` 2. Build with CMake and install -## Installing DBoW2 with Brisk Descriptors, Nvidia Jetson Xavier NX Version. +## Installing DBoW2 with Brisk Descriptors, for Jetson NX. 1. `git clone https://github.com/moonwonlee/DBoW2_Mod.git && cd DBoW2_Mod`. Note that this repository is a modified version of DBoW2_Mod to support Brisk descriptors. 2. Build with CMake and install ## Installing DLoopDetector, Custom Version - 1. `git clone https://github.com/joemenke/DLoopDetector && cd DLoopDetector` Note that this repository is a modified version of DLoopDetector. 2. Build with CMake and install -## Installing Open3D (0.12.0), Nvidia Jetson Xavier NX Version. +## Installing Open3D (0.12.0), for Jetson NX. ### Install system dependencies ``` sudo apt-get update -y @@ -206,7 +203,7 @@ sudo make install If the Open3D build system complains about CMake xxx or higher is required, get a CMake version higher than 3.18. Follow this => Compile CMake from source : https://cmake.org/install/ -## Installing Okvis+, NVIDIA Jetson Xavier NX Version. +## Installing Okvis+, for Jetson NX. 1. `git clone https://github.com/moonwonlee/okvis.git && cd okvis` 2. Apply the Fixing Eigen changes. 3. To run okvis demo, turn on the demo option in the CMakeListst.txt. @@ -214,7 +211,6 @@ Follow this => Compile CMake from source : https://cmake.org/install/ 4. Build with CMake and install. 5. Verify Okvis+ by running the demo application. You will find a demo application in okvis_apps. It can process datasets in the ASL/ETH format. -https://github.com/ceres-solver/ceres-solver/releases/tag/1.14.0 In order to run a minimal working example, follow the steps below: 6. Download a dataset of your choice from http://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets. Assuming you downloaded MH_01_easy/. You will find a corresponding calibration / estimator configuration in the config folder. @@ -222,7 +218,7 @@ In order to run a minimal working example, follow the steps below: 7. Run the app as `./okvis_app_synchronous path/to/okvis/config/config_fpga_p2_euroc.yaml path/to/mav0/` -## Installing librealsense2, Nvidia Jetson Xavier NX Version. +## Installing librealsense2, for Jetson NX. Follow this : https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md ### Optional: As a sanity check for librealsense2, @@ -231,13 +227,13 @@ Follow this : https://github.com/IntelRealSense/librealsense/blob/master/doc/ins 3. Verify that the kernel is updated : `modinfo uvcvideo | grep "version:" should include realsense string` -## Installing and Building OpenARK +## Installing and Building OpenARK, for Jetson NX. 1. Clone our repository: `git clone https://github.com/augcog/OpenARK`, or download the latest release. -2. `git checkout jetson-nx` -This already has the Eigen changes. Make sure that the EIGEN_HACK option is ON. -`option( EIGEN_HACK "EIGEN_HACK" ON)` - -Also make sure that add_definitions(-D__ARM_NEON__) is applied for ARM support. +2. `git checkout jetson-nx`. +This already has the Eigen changes. Make sure that the EIGEN_HACK option is ON. +`option( EIGEN_HACK "EIGEN_HACK" ON)`. +Also make sure that the following is applied for ARM support, in case it is not applied automatically. +`add_definitions(-D__ARM_NEON__)` 3. `cd OpenARK && mkdir build && cd build` to create build directory. From 50e7547ebe3381906c8207c7faef028f9b317621 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:06:37 -0700 Subject: [PATCH 07/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index ce43e279..de41fbcf 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -206,7 +206,7 @@ Follow this => Compile CMake from source : https://cmake.org/install/ ## Installing Okvis+, for Jetson NX. 1. `git clone https://github.com/moonwonlee/okvis.git && cd okvis` 2. Apply the Fixing Eigen changes. -3. To run okvis demo, turn on the demo option in the CMakeListst.txt. +3. To run okvis demo, turn on the demo option in the CMakeListst.txt. `option (BUILD_APPS "Builds a demo app (which requires boost)" ON)` 4. Build with CMake and install. 5. Verify Okvis+ by running the demo application. From cc871adcaa4cab3368fa9866e92c177dc6bad7d5 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:07:11 -0700 Subject: [PATCH 08/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index de41fbcf..1777a74a 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -166,7 +166,8 @@ sudo apt-get install -y clang-7 # Clone git clone --recursive https://github.com/moonwonlee/Open3D.git git checkout v12 -Install dependencies for Open3D. `./util/install_deps_ubuntu.sh assume-yes` +#Install dependencies for Open3D. +./util/install_deps_ubuntu.sh assume-yes cd Open3D mkdir build cd build From 2c392cee8409a1ec8faf666e32b7a92445bef718 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:08:09 -0700 Subject: [PATCH 09/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index 1777a74a..b67448e7 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -166,7 +166,7 @@ sudo apt-get install -y clang-7 # Clone git clone --recursive https://github.com/moonwonlee/Open3D.git git checkout v12 -#Install dependencies for Open3D. +# Install dependencies for Open3D. ./util/install_deps_ubuntu.sh assume-yes cd Open3D mkdir build From 747e188a9572e43f43df7a6bdf92df80fd1e4ce9 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:28:20 -0700 Subject: [PATCH 10/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index b67448e7..622685b9 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -95,7 +95,8 @@ The following sections directly have Eigen as a depenendency: 1. Ceres 1.14.0 2. OpenGV 3. Okvis -4. OpenARK Ubuntu. +4. OpenARK Ubuntu +5. OpenARK Jetson NX In order to get Eigen working for OpenARK Ubuntu and Jetson NX, the following lines of code must be added into the top level CMakesList.txt: ``` From 8e9d29f38e789d0cd417a5df44b3c9939f501c2a Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:35:43 -0700 Subject: [PATCH 11/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index 622685b9..35f61af6 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -232,7 +232,8 @@ Follow this : https://github.com/IntelRealSense/librealsense/blob/master/doc/ins ## Installing and Building OpenARK, for Jetson NX. 1. Clone our repository: `git clone https://github.com/augcog/OpenARK`, or download the latest release. 2. `git checkout jetson-nx`. -This already has the Eigen changes. Make sure that the EIGEN_HACK option is ON. +This already has the Eigen changes. +But make sure that the EIGEN_HACK option is ON. `option( EIGEN_HACK "EIGEN_HACK" ON)`. Also make sure that the following is applied for ARM support, in case it is not applied automatically. `add_definitions(-D__ARM_NEON__)` From 9b38d23e2e15dcafa503a9d7a0f26cb8eca883a8 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:47:51 -0700 Subject: [PATCH 12/23] Update CMakeLists.txt --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0277ad6b..c12adb66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,10 @@ if( ${EIGEN_HACK} ) if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm*") message(STATUS "ARM processor detected, will attempt to use NEON.") add_definitions(-D__ARM_NEON__) + +include( CheckCXXCompilerFlag ) +CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 ) +CHECK_CXX_COMPILER_FLAG( "-std=c++0x" COMPILER_SUPPORTS_CXX0X ) if( COMPILER_SUPPORTS_CXX11 ) message(STATUS "c++11 supported") @@ -557,4 +561,4 @@ if( ${BUILD_TESTS} ) endif( ${BUILD_TESTS} ) # Create source group for headers -source_group( "Header Files" FILES ${HEADERS} ) \ No newline at end of file +source_group( "Header Files" FILES ${HEADERS} ) From e8c780f970630870c5796557b38a54468761deeb Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 00:52:02 -0700 Subject: [PATCH 13/23] Update CMakeLists.txt --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c12adb66..b45fb694 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,12 +27,12 @@ set( UNITY_PLUGIN_NAME "UnityPlugin" ) # Options. option( EIGEN_HACK "EIGEN_HACK" ON) -option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" OFF ) -option( BUILD_AVATAR_DEMO "BUILD_AVATAR_DEMO" OFF) -option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" OFF) -option( BUILD_3DRECON_DEMO "BUILD_3DRECON_DEMO" OFF) -option( BUILD_DATA_RECORDING "BUILD_DATA_RECORDING" OFF) -option( BUILD_SLAM_RECORDING "BUILD_SLAM_RECORDING" OFF) +option( BUILD_HAND_DEMO "BUILD_HAND_DEMO" ON ) +option( BUILD_AVATAR_DEMO "BUILD_AVATAR_DEMO" ON) +option( BUILD_SLAM_DEMO "BUILD_SLAM_DEMO" ON) +option( BUILD_3DRECON_DEMO "BUILD_3DRECON_DEMO" ON) +option( BUILD_DATA_RECORDING "BUILD_DATA_RECORDING" ON) +option( BUILD_SLAM_RECORDING "BUILD_SLAM_RECORDING" ON) option( BUILD_SLAM_REPLAYING "BUILD_SLAM_REPLAYING" ON) option( BUILD_TESTS "BUILD_TESTS" OFF ) option( BUILD_UNITY_PLUGIN "BUILD_UNITY_PLUGIN" OFF ) @@ -50,7 +50,7 @@ if( ${EIGEN_HACK} ) if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm*") message(STATUS "ARM processor detected, will attempt to use NEON.") add_definitions(-D__ARM_NEON__) - + include( CheckCXXCompilerFlag ) CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 ) CHECK_CXX_COMPILER_FLAG( "-std=c++0x" COMPILER_SUPPORTS_CXX0X ) From 15c7a8c400adb2a2c94c3ce2fa47a52faa630986 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:06:48 -0700 Subject: [PATCH 14/23] Update SlamReplaying.cpp --- SlamReplaying.cpp | 131 +++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 66 deletions(-) diff --git a/SlamReplaying.cpp b/SlamReplaying.cpp index a2695e1d..0517b1b1 100644 --- a/SlamReplaying.cpp +++ b/SlamReplaying.cpp @@ -74,12 +74,12 @@ int main(int argc, char **argv) vio_parameters_reader.getParameters(parameters); OkvisSLAMSystem slam(vocabFilename, parameters); - // //setup display - // if (!MyGUI::Manager::init()) - // { - // fprintf(stdout, "Failed to initialize GLFW\n"); - // return -1; - // } + //setup display + if (!MyGUI::Manager::init()) + { + fprintf(stdout, "Failed to initialize GLFW\n"); + return -1; + } printf("Camera initialization started...\n"); fflush(stdout); @@ -89,21 +89,21 @@ int main(int argc, char **argv) fflush(stdout); //Window for displaying the path - // MyGUI::CameraWindow traj_win("Traj Viewer", 640 * 2, 480 * 2); - // MyGUI::ARCameraWindow ar_win("AR Viewer", 640 * 2.5, 480 * 2.5, GL_LUMINANCE, GL_UNSIGNED_BYTE, 6.16403320e+02, 6.16171021e+02, 3.18104584e+02, 2.33643127e+02, 0.01, 100); - // traj_win.set_pos(640 * 2.5, 100); - // ar_win.set_pos(0, 100); + MyGUI::CameraWindow traj_win("Traj Viewer", 640 * 2, 480 * 2); + MyGUI::ARCameraWindow ar_win("AR Viewer", 640 * 2.5, 480 * 2.5, GL_LUMINANCE, GL_UNSIGNED_BYTE, 6.16403320e+02, 6.16171021e+02, 3.18104584e+02, 2.33643127e+02, 0.01, 100); + traj_win.set_pos(640 * 2.5, 100); + ar_win.set_pos(0, 100); std::map pathMap; - // MyGUI::Axis axis1("axis1", .1); - // MyGUI::Axis axis2("axis2", 1); - // MyGUI::Grid grid1("grid1", 10, 1); - // traj_win.add_object(&axis1); - // traj_win.add_object(&axis2); - // traj_win.add_object(&grid1); - // ar_win.add_object(&axis1); - // std::vector cubes; // Moon : Cause 2. b This line might be wrong. MyGUI::Object is also a class having FSVEO.But it's a pointer of that. So not sure. - // std::vector> T_K_cubes; // Moon : Cause 2.a - // std::vector> K_cubes; // Moon : Cause 2.b. MayKeyFrame is a class having members of FSVEO + MyGUI::Axis axis1("axis1", .1); + MyGUI::Axis axis2("axis2", 1); + MyGUI::Grid grid1("grid1", 10, 1); + traj_win.add_object(&axis1); + traj_win.add_object(&axis2); + traj_win.add_object(&grid1); + ar_win.add_object(&axis1); + std::vector cubes; // Moon : Cause 2. b This line might be wrong. MyGUI::Object is also a class having FSVEO.But it's a pointer of that. So not sure. + std::vector> T_K_cubes; // Moon : Cause 2.a + std::vector> K_cubes; // Moon : Cause 2.b. MayKeyFrame is a class having members of FSVEO int lastMapIndex_path = 0; //Recieves output from SLAM system and displays to the screen @@ -111,47 +111,47 @@ int main(int argc, char **argv) Eigen::Affine3d transform(frame->T_WC(3)); const auto mapIndex = slam.getActiveMapIndex(); - // if (pathMap.find(mapIndex) == pathMap.end()) { - // string name = "path"+std::to_string(mapIndex); - // pathMap[mapIndex] = new MyGUI::Path{name, Eigen::Vector3d(1, 0, 0)}; // Moon : fine. - // // traj_win.add_object(pathMap[mapIndex]); - // } - // if (mapIndex < lastMapIndex_path) { - // // pathMap[lastMapIndex_path]->clear(); - // auto it = pathMap.cbegin(); - // while(it != pathMap.cend()) { - // auto curr = it++; - // if (it->first > mapIndex) { - // it->second->clear(); - // } - // } - // } + if (pathMap.find(mapIndex) == pathMap.end()) { + string name = "path"+std::to_string(mapIndex); + pathMap[mapIndex] = new MyGUI::Path{name, Eigen::Vector3d(1, 0, 0)}; // Moon : fine. + // traj_win.add_object(pathMap[mapIndex]); + } + if (mapIndex < lastMapIndex_path) { + // pathMap[lastMapIndex_path]->clear(); + auto it = pathMap.cbegin(); + while(it != pathMap.cend()) { + auto curr = it++; + if (it->first > mapIndex) { + it->second->clear(); + } + } + } if (lastMapIndex_path != mapIndex) { lastMapIndex_path = mapIndex; } - //pathMap[mapIndex]->add_node(transform.translation()); - //axis2.set_transform(transform); - // ar_win.set_camera(transform); - // ar_win.set_image(frame->images_[3]); - // if (ar_win.clicked()) - // { - - // std::string cube_name = std::string("CubeNum") + std::to_string(cubes.size()); - // MyGUI::Object *obj = new MyGUI::Cube(cube_name, 0.1, 0.1, 0.1); - // obj->set_transform(transform); - // cubes.push_back(obj); - // T_K_cubes.push_back(frame->T_KS_); - // K_cubes.push_back(frame->keyframe_); - // std::cout << "Adding cube " << cube_name << std::endl; - // ar_win.add_object(obj); //NOTE: this is bad, should change objects to shared_ptr - // } + pathMap[mapIndex]->add_node(transform.translation()); + axis2.set_transform(transform); + ar_win.set_camera(transform); + ar_win.set_image(frame->images_[3]); + if (ar_win.clicked()) + { + + std::string cube_name = std::string("CubeNum") + std::to_string(cubes.size()); + MyGUI::Object *obj = new MyGUI::Cube(cube_name, 0.1, 0.1, 0.1); + obj->set_transform(transform); + cubes.push_back(obj); + T_K_cubes.push_back(frame->T_KS_); + K_cubes.push_back(frame->keyframe_); + std::cout << "Adding cube " << cube_name << std::endl; + ar_win.add_object(obj); //NOTE: this is bad, should change objects to shared_ptr + } }); slam.AddFrameAvailableHandler(handler, "mapping"); KeyFrameAvailableHandler kfHandler([](MultiCameraFrame::Ptr frame) { frame->saveSimple("map_images/"); }); - //slam.AddKeyFrameAvailableHandler(kfHandler, "saving"); + slam.AddKeyFrameAvailableHandler(kfHandler, "saving"); LoopClosureDetectedHandler loopHandler([&](void) { std::vector> traj; // Moon : Cause 2.b @@ -160,13 +160,13 @@ int main(int argc, char **argv) //pathMap[mapIndex]->clear(); for (size_t i = 0; i < traj.size(); i++) { - //pathMap[mapIndex]->add_node(traj[i].block<3, 1>(0, 3)); + pathMap[mapIndex]->add_node(traj[i].block<3, 1>(0, 3)); + } + for (size_t i = 0; i < cubes.size(); i++) + { + if (K_cubes[i] != nullptr) + cubes[i]->set_transform(Eigen::Affine3d(K_cubes[i]->T_WS() * T_K_cubes[i])); // Moon : Cause 3.a. const + & or & might be needed. } - // for (size_t i = 0; i < cubes.size(); i++) - // { - // if (K_cubes[i] != nullptr) - // cubes[i]->set_transform(Eigen::Affine3d(K_cubes[i]->T_WS() * T_K_cubes[i])); // Moon : Cause 3.a. const + & or & might be needed. - // } }); slam.AddLoopClosureDetectedHandler(loopHandler, "trajectoryUpdate"); //run until display is closed @@ -174,11 +174,10 @@ int main(int argc, char **argv) camera.start(); int lastMapIndex = -1; - //while (MyGUI::Manager::running()) - while(1) + while (MyGUI::Manager::running()) { //Update the display - //MyGUI::Manager::update(); + MyGUI::Manager::update(); try { @@ -196,8 +195,8 @@ int main(int argc, char **argv) const auto &rgb = frame->images_[3]; const auto &depth = frame->images_[4]; - // cv::imshow(std::string(camera.getModelName()) + " Infrared", infrared); - // cv::imshow(std::string(camera.getModelName()) + " Depth", depth); + cv::imshow(std::string(camera.getModelName()) + " Infrared", infrared); + cv::imshow(std::string(camera.getModelName()) + " Depth", depth); std::vector> imuData; camera.getImuToTime(frame->timestamp_, imuData); @@ -224,9 +223,9 @@ int main(int argc, char **argv) } if (isReset) { - //traj_win.msg_ = " *Reseting*"; + traj_win.msg_ = " *Reseting*"; } else { - //traj_win.msg_ = " "; + traj_win.msg_ = " "; } int k = cv::waitKey(1); if (k == 'q' || k == 'Q' || k == 27) @@ -237,4 +236,4 @@ int main(int argc, char **argv) slam.ShutDown(); printf("\nExiting...\n"); return 0; -} \ No newline at end of file +} From ca868277e3a3d9e4ee73a33b60ca9c229c2731d6 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:07:27 -0700 Subject: [PATCH 15/23] Update glfwManager.cpp --- glfwManager.cpp | 90 ++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/glfwManager.cpp b/glfwManager.cpp index 9b1dc3f0..f0b5bdab 100644 --- a/glfwManager.cpp +++ b/glfwManager.cpp @@ -563,77 +563,77 @@ void Path::draw_obj() glEnable(GL_LIGHTING); } -// void Mesh::draw_obj() -// { +void Mesh::draw_obj() +{ -// std::lock_guard guard(meshLock_); + std::lock_guard guard(meshLock_); -// Eigen::Matrix4d scene_mat; -// glGetDoublev(GL_MODELVIEW_MATRIX, scene_mat.data()); -// scene_mat = scene_mat*pose.matrix().inverse(); -// glLoadMatrixd(scene_mat.data()); + Eigen::Matrix4d scene_mat; + glGetDoublev(GL_MODELVIEW_MATRIX, scene_mat.data()); + scene_mat = scene_mat*pose.matrix().inverse(); + glLoadMatrixd(scene_mat.data()); -// for (int i = 0; i < mesh_vertices.size(); ++i) { + for (int i = 0; i < mesh_vertices.size(); ++i) { -// if (!mesh_enabled[i]) { -// continue; -// } + if (!mesh_enabled[i]) { + continue; + } -// std::vector vertices = mesh_vertices[i]; -// std::vector colors = mesh_colors[i]; -// std::vector triangles = mesh_triangles[i]; -// Eigen::Affine3d transform(mesh_transforms[i]); + std::vector vertices = mesh_vertices[i]; + std::vector colors = mesh_colors[i]; + std::vector triangles = mesh_triangles[i]; + Eigen::Affine3d transform(mesh_transforms[i]); -// transform = pose * transform; -// //mesh_transforms[i] is c->w, we need w->c + transform = pose * transform; + //mesh_transforms[i] is c->w, we need w->c -// glPushMatrix(); + glPushMatrix(); -// Eigen::AngleAxis R(transform.rotation()); -// Eigen::Translation3d T(transform.translation()); + Eigen::AngleAxis R(transform.rotation()); + Eigen::Translation3d T(transform.translation()); -// glRotated(180, 0, 1, 0); -// glRotated(180, 0, 0, 1); + glRotated(180, 0, 1, 0); + glRotated(180, 0, 0, 1); -// glTranslated(T.x(), T.y(), T.z()); -// glRotated(R.angle() * 180 / 3.14159, R.axis().x(), R.axis().y(), R.axis().z()); + glTranslated(T.x(), T.y(), T.z()); + glRotated(R.angle() * 180 / 3.14159, R.axis().x(), R.axis().y(), R.axis().z()); -// glDisable(GL_LIGHTING); + glDisable(GL_LIGHTING); -// glBegin(GL_TRIANGLES); + glBegin(GL_TRIANGLES); -// for (int i = 0; i < triangles.size(); i++) { + for (int i = 0; i < triangles.size(); i++) { -// Eigen::Vector3d vertex1 = vertices[triangles[i][0]]; -// Eigen::Vector3d vertex2 = vertices[triangles[i][1]]; -// Eigen::Vector3d vertex3 = vertices[triangles[i][2]]; + Eigen::Vector3d vertex1 = vertices[triangles[i][0]]; + Eigen::Vector3d vertex2 = vertices[triangles[i][1]]; + Eigen::Vector3d vertex3 = vertices[triangles[i][2]]; -// Eigen::Vector3d color1 = colors[triangles[i][0]]; -// Eigen::Vector3d color2 = colors[triangles[i][1]]; -// Eigen::Vector3d color3 = colors[triangles[i][2]]; + Eigen::Vector3d color1 = colors[triangles[i][0]]; + Eigen::Vector3d color2 = colors[triangles[i][1]]; + Eigen::Vector3d color3 = colors[triangles[i][2]]; -// glColor3f((color1[0] + color2[0] + color3[0]) / 3.0f, -// (color1[1] + color2[1] + color3[1]) / 3.0f, -// (color1[2] + color2[2] + color3[2]) / 3.0f); + glColor3f((color1[0] + color2[0] + color3[0]) / 3.0f, + (color1[1] + color2[1] + color3[1]) / 3.0f, + (color1[2] + color2[2] + color3[2]) / 3.0f); -// glVertex3f(vertex1[0], vertex1[1], vertex1[2]); -// glVertex3f(vertex2[0], vertex2[1], vertex2[2]); -// glVertex3f(vertex3[0], vertex3[1], vertex3[2]); -// } + glVertex3f(vertex1[0], vertex1[1], vertex1[2]); + glVertex3f(vertex2[0], vertex2[1], vertex2[2]); + glVertex3f(vertex3[0], vertex3[1], vertex3[2]); + } -// glEnd(); + glEnd(); -// glEnable(GL_LIGHTING); + glEnable(GL_LIGHTING); -// glPopMatrix(); + glPopMatrix(); -// } + } -// } +} }//MyGUI From 29bb01d1f667c4252e78fb26611d41b133be938f Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:08:41 -0700 Subject: [PATCH 16/23] Update glfwManager.h --- include/glfwManager.h | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/glfwManager.h b/include/glfwManager.h index 544ab47c..6da203d2 100644 --- a/include/glfwManager.h +++ b/include/glfwManager.h @@ -17,7 +17,7 @@ #include #include #include -//#include "SegmentedMesh.h" +#include "SegmentedMesh.h" #include @@ -350,43 +350,43 @@ class Path : public Object { } }; -// class Mesh : public Object { -// public: +class Mesh : public Object { +public: -// EIGEN_MAKE_ALIGNED_OPERATOR_NEW + EIGEN_MAKE_ALIGNED_OPERATOR_NEW -// std::vector> mesh_vertices; -// std::vector> mesh_colors; -// std::vector> mesh_triangles; -// std::vector> mesh_transforms; // Moon : Cause 2.a -// std::vector mesh_enabled; + std::vector> mesh_vertices; + std::vector> mesh_colors; + std::vector> mesh_triangles; + std::vector> mesh_transforms; // Moon : Cause 2.a + std::vector mesh_enabled; -// // //threadsafe? -// // int current_active_map; -// // int archive_index; -// // std::set enabled_meshes; + // //threadsafe? + // int current_active_map; + // int archive_index; + // std::set enabled_meshes; -// ark::SegmentedMesh * mesh_; + ark::SegmentedMesh * mesh_; -// void draw_obj(); + void draw_obj(); -// Mesh(std::string name, ark::SegmentedMesh * mesh) -// : Object(name) { -// mesh_ = mesh; -// } + Mesh(std::string name, ark::SegmentedMesh * mesh) + : Object(name) { + mesh_ = mesh; + } -// void update_meshes() { -// std::lock_guard guard(meshLock_); + void update_meshes() { + std::lock_guard guard(meshLock_); -// mesh_->Render(mesh_vertices, mesh_colors, mesh_triangles, mesh_transforms, mesh_enabled); // Moon : Render is deprecated in the Master branch of OpenARK. This line might be wrong. + mesh_->Render(mesh_vertices, mesh_colors, mesh_triangles, mesh_transforms, mesh_enabled); // Moon : Render is deprecated in the Master branch of OpenARK. This line might be wrong. -// } + } -// protected: -// std::mutex meshLock_; +protected: + std::mutex meshLock_; -// }; +}; -} //MyGUI \ No newline at end of file +} //MyGUI From 97667120f3c4c21d0263d2468efda199d435b1c8 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:10:47 -0700 Subject: [PATCH 17/23] Update SlamReplaying.cpp --- SlamReplaying.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SlamReplaying.cpp b/SlamReplaying.cpp index 0517b1b1..60857bd7 100644 --- a/SlamReplaying.cpp +++ b/SlamReplaying.cpp @@ -157,7 +157,7 @@ int main(int argc, char **argv) std::vector> traj; // Moon : Cause 2.b slam.getTrajectory(traj); const auto mapIndex = slam.getActiveMapIndex(); - //pathMap[mapIndex]->clear(); + pathMap[mapIndex]->clear(); for (size_t i = 0; i < traj.size(); i++) { pathMap[mapIndex]->add_node(traj[i].block<3, 1>(0, 3)); From 5898189edd6f5cb42f4d97fef0e11df1ca27f4a7 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:11:26 -0700 Subject: [PATCH 18/23] Update SlamReplaying.cpp --- SlamReplaying.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlamReplaying.cpp b/SlamReplaying.cpp index 60857bd7..c081f06e 100644 --- a/SlamReplaying.cpp +++ b/SlamReplaying.cpp @@ -114,10 +114,10 @@ int main(int argc, char **argv) if (pathMap.find(mapIndex) == pathMap.end()) { string name = "path"+std::to_string(mapIndex); pathMap[mapIndex] = new MyGUI::Path{name, Eigen::Vector3d(1, 0, 0)}; // Moon : fine. - // traj_win.add_object(pathMap[mapIndex]); + traj_win.add_object(pathMap[mapIndex]); } if (mapIndex < lastMapIndex_path) { - // pathMap[lastMapIndex_path]->clear(); + pathMap[lastMapIndex_path]->clear(); auto it = pathMap.cbegin(); while(it != pathMap.cend()) { auto curr = it++; From 63862c9ec9f4bc4f04d58b711d65fa35179791e8 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Mon, 12 Apr 2021 01:13:55 -0700 Subject: [PATCH 19/23] Update SlamReplaying.cpp --- SlamReplaying.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SlamReplaying.cpp b/SlamReplaying.cpp index c081f06e..cb19fae1 100644 --- a/SlamReplaying.cpp +++ b/SlamReplaying.cpp @@ -117,7 +117,7 @@ int main(int argc, char **argv) traj_win.add_object(pathMap[mapIndex]); } if (mapIndex < lastMapIndex_path) { - pathMap[lastMapIndex_path]->clear(); + // pathMap[lastMapIndex_path]->clear(); auto it = pathMap.cbegin(); while(it != pathMap.cend()) { auto curr = it++; @@ -151,7 +151,7 @@ int main(int argc, char **argv) KeyFrameAvailableHandler kfHandler([](MultiCameraFrame::Ptr frame) { frame->saveSimple("map_images/"); }); - slam.AddKeyFrameAvailableHandler(kfHandler, "saving"); + //slam.AddKeyFrameAvailableHandler(kfHandler, "saving"); LoopClosureDetectedHandler loopHandler([&](void) { std::vector> traj; // Moon : Cause 2.b From 2ce1bc6c3a0817da4ae2b9c6d2a3582dcae65098 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Tue, 13 Apr 2021 05:07:25 -0700 Subject: [PATCH 20/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index 35f61af6..f28d3b89 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -1,12 +1,14 @@ # Installing OpenARK for NVIDIA Jetson Xavier NX OpenARK provides support for Nvidia Jetson Xavier NX. +``` CPU : (6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64). OS : L4T = {sample filesystem based on Ubuntu 18.04, Linux Kernel 4.9, bootloader, NVIDIA drivers, flashing utilities} - +``` ## Preliminaries 1. Install basic tools, dependencies: + ```sh sudo apt update sudo apt -y install g++ build-essential cmake cmake-gui git-core @@ -26,21 +28,6 @@ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /u sudo update-alternatives --set gcc "/usr/bin/gcc-5" ``` -## Note: CMake Builds -For conciseness, in all sections below "build with CMake" will mean ... - -```sh -mkdir build && cd build -cmake -DCMAKE_BUILD_TYPE=Release .. -make -j4 -sudo make install -``` -or a one-liner for cmake build is ... -```sh -mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=RELEASE .. && make -j4 && sudo make install -``` -Note that this installs the library. You may replace '4' in step 3 with any number of threads. The build process should not take too long. - ## Installing PCL, [Package: libpcl-dev (1.8.1+dfsg1-2ubuntu2)](https://packages.ubuntu.com/bionic/libpcl-dev) ```sh @@ -69,7 +56,6 @@ sudo apt -y apt install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0 sudo apt -y gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 sudo apt -ygstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev ``` - Note that we add the Ubuntu 16 (Xenial) repo since some packages have been removed in later versions of Ubuntu. 2. Download OpenCV and OpenCV_contrib sources: @@ -85,30 +71,28 @@ tar -xf contrib.tar.gz ``` sh mkdir build && cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -DWITH_TBB=ON -DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-3.4.6/modules" -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF .. -make -j4 +make -j$(nproc) sudo make install ``` -Again, -j4 may be replaced with any number of threads. -## Eigen Hack for OpenARK Ubuntu and Jetson NX. +## Fixing Eigen The following sections directly have Eigen as a depenendency: 1. Ceres 1.14.0 2. OpenGV 3. Okvis -4. OpenARK Ubuntu -5. OpenARK Jetson NX +4. OpenARK -In order to get Eigen working for OpenARK Ubuntu and Jetson NX, the following lines of code must be added into the top level CMakesList.txt: +In order to get Eigen working for OpenARK Ubuntu and Jetson NX, the following lines of code must be added into the top level CMakesList.txt: ``` add_definitions(-DEIGEN_DONT_ALIGN=1) add_definitions(-DEIGEN_DONT_VECTORIZE=1) ``` This will disable alignment as well as force the compiler to use c++17 standard. -When it comes to OpenARK, make sure that the EIGEN_HACK option is ON. This will apply the same Eigen hack above. +When it comes to OpenARK, you can easily add the Eigen hack above by setting EIGEN_HACK option as ON in the CMakeLists.txt `option( EIGEN_HACK "EIGEN_HACK" ON)` -Now run the CMake instructions to build each library. +Then follow the CMake instructions to build each library. ## Continued Dependencies ### Installing Ceres 1.14.0 from source @@ -132,24 +116,54 @@ endif (CXX11 AND COMPILER_HAS_CXX11_FLAG)]] ``` 3. Apply the Fixing Eigen changes. 4. Build with CMake and install +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` ## Intalling OpenGV 1.0 1. `git clone https://github.com/laurentkneip/opengv && cd opengv` 2. Apply the Fixing Eigen changes. 3. Build with CMake and install +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` ## Installing Brisk, for Jetson NX. 1. `git clone https://github.com/moonwonlee/brisk.git && cd brisk` 2. Build with CMake and install +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` ## Installing DBoW2 with Brisk Descriptors, for Jetson NX. 1. `git clone https://github.com/moonwonlee/DBoW2_Mod.git && cd DBoW2_Mod`. Note that this repository is a modified version of DBoW2_Mod to support Brisk descriptors. 2. Build with CMake and install +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` ## Installing DLoopDetector, Custom Version 1. `git clone https://github.com/joemenke/DLoopDetector && cd DLoopDetector` Note that this repository is a modified version of DLoopDetector. 2. Build with CMake and install +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` ## Installing Open3D (0.12.0), for Jetson NX. ### Install system dependencies @@ -163,6 +177,9 @@ sudo apt-get install -y libsdl2-dev libc++-7-dev libc++abi-7-dev libxi-dev sudo apt-get install -y clang-7 ``` ### Build. +The minimum CMake version required is 3.18. You can check your CMake version with +`cmake --version` +For Ubuntu 18.04, we suggest you install the latest CMake from the official repository https://apt.kitware.com/. CMake 3.18+ is required to allow linking with OBJECT libraries, to prevent erroneous -gencode option deduplication with CUDA, and to simplify generator expressions for selecting compile flags and setting global hardened link flags. ``` # Clone git clone --recursive https://github.com/moonwonlee/Open3D.git @@ -211,6 +228,12 @@ Follow this => Compile CMake from source : https://cmake.org/install/ 3. To run okvis demo, turn on the demo option in the CMakeListst.txt. `option (BUILD_APPS "Builds a demo app (which requires boost)" ON)` 4. Build with CMake and install. +```sh +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +sudo make install +``` 5. Verify Okvis+ by running the demo application. You will find a demo application in okvis_apps. It can process datasets in the ASL/ETH format. In order to run a minimal working example, follow the steps below: @@ -235,14 +258,16 @@ Follow this : https://github.com/IntelRealSense/librealsense/blob/master/doc/ins This already has the Eigen changes. But make sure that the EIGEN_HACK option is ON. `option( EIGEN_HACK "EIGEN_HACK" ON)`. -Also make sure that the following is applied for ARM support, in case it is not applied automatically. +Also make sure that the following is applied for ARM support, just in case it is not applied automatically. `add_definitions(-D__ARM_NEON__)` 3. `cd OpenARK && mkdir build && cd build` to create build directory. -4. `cmake .. -DCMAKE_BUILD_TYPE=Release` to run CMake. librealsense2 will be enabled by default. You can add `-DBUILD_AVATAR_DEMO` to build the avatar demo in addition to hand and SLAM, `-DBUILD_DATA_RECORDING` to build the data recording tool, and `-BUILD_TESTS` to build hand tests. `-DBUILD_UNITY_PLUGIN` is not available on Linux at the moment. +4. Run CMake. +`cmake .. -DCMAKE_BUILD_TYPE=Release` +librealsense2 will be enabled by default. You can add `-DBUILD_AVATAR_DEMO` to build the avatar demo in addition to hand and SLAM, `-DBUILD_DATA_RECORDING` to build the data recording tool, and `-BUILD_TESTS` to build hand tests. `-DBUILD_UNITY_PLUGIN` is not available on Linux at the moment. -5. `make -j4` to build. +5. `make -j4` ## Running the OpenARK demo applications - These applications will show you how core functionalities of OpenARK work From c35c7a3425c14d695a1ec875c3aae53d2d748f77 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Tue, 13 Apr 2021 05:11:05 -0700 Subject: [PATCH 21/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index f28d3b89..1e45e5ae 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -2,7 +2,7 @@ OpenARK provides support for Nvidia Jetson Xavier NX. ``` -CPU : (6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64). +CPU : 6-core NVIDIA Carmel ARM®v8.2 64-bit CPU (arm64 or aarch64). OS : L4T = {sample filesystem based on Ubuntu 18.04, Linux Kernel 4.9, bootloader, NVIDIA drivers, flashing utilities} ``` ## Preliminaries From ed760a9256f299ba5e18dbc772c72cd276857486 Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Tue, 13 Apr 2021 05:13:34 -0700 Subject: [PATCH 22/23] Update Jetson-NX-build-instructions.md --- documentation/Jetson-NX-build-instructions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/Jetson-NX-build-instructions.md b/documentation/Jetson-NX-build-instructions.md index 1e45e5ae..408def4a 100644 --- a/documentation/Jetson-NX-build-instructions.md +++ b/documentation/Jetson-NX-build-instructions.md @@ -95,14 +95,14 @@ When it comes to OpenARK, you can easily add the Eigen hack above by setting EIG Then follow the CMake instructions to build each library. ## Continued Dependencies -### Installing Ceres 1.14.0 from source +## Installing Ceres 1.14.0 from source -#### Installing [SuiteSparse 5.1.2](https://packages.ubuntu.com/bionic/libsuitesparse-dev) +### Installing [SuiteSparse 5.1.2](https://packages.ubuntu.com/bionic/libsuitesparse-dev) SuiteSparse speeds up some of Ceres functions. However, if you want to prevent Suitesparse from crashing, you can skip downloading Suitesparse. You can still download Suitesparse and opt it out during the Ceres build process. ```sh sudo apt install libsuitesparse-dev ``` -Download Ceres1.14.0 from source and build as follows. +### Download Ceres1.14.0 from source and build as follows. 1. `wget -O ceres114.tar.gz https://github.com/ceres-solver/ceres-solver/archive/1.14.0.tar.gz && tar -xf ceres114.tar.gz && cd ceres-solver-1.14.0` 2. Comment out lines 434-439 of the top level CMakeLists.txt It should look like: (notice the #[[ open comment and ]] close comment) From 0c7279a2fdff48ac5360e313b728520f3b5674ed Mon Sep 17 00:00:00 2001 From: Moonwon Lee Date: Tue, 13 Apr 2021 20:49:31 -0700 Subject: [PATCH 23/23] Update CMakeLists.txt --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b45fb694..4c34bb69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,13 @@ option( USE_PMDSDK "USE_PMDSDK" OFF ) if( ${EIGEN_HACK} ) add_definitions(-DEIGEN_DONT_ALIGN=1) add_definitions(-DEIGEN_DONT_VECTORIZE=1) +endif() # NVIDIA Jetson Xavier NX if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm*") message(STATUS "ARM processor detected, will attempt to use NEON.") add_definitions(-D__ARM_NEON__) +endif() include( CheckCXXCompilerFlag ) CHECK_CXX_COMPILER_FLAG( "-std=c++11" COMPILER_SUPPORTS_CXX11 )