写在前面
-
本文内容
- Open3D手动选点配准工具;
- 包含CMakeLists,cpp源码,编译脚本,运行结果可视化,可执行文件;
- 源码、编译好的工具和脚本在这里下载:
本博客资源链接/share_noel/csdn/open3d/open3d_ManuallyAlignPointCloud
-
运行结果
-
平台/环境
Windows10, Ubuntu1804, CMake, Open3D -
转载请注明出处:
https://blog.csdn.net/qq_41102371/article/details/136840171
准备Open3D
参考:各个版本的Open3D、PCL的编译、使用教程
本文使用Open3D0.14.1
代码
源码
找到open3d源码中手动配准的源码,在Open3D0.14.1/Open3D/cpp/tools/ManuallyAlignPointCloud
新建一个文件夹open3d_ManuallyAlignPointCloud/src
mkdir open3d_ManuallyAlignPointCloud
cd open3d_ManuallyAlignPointCloud
mkdir src
将找到的代码复制到src中
编译
vscode打开open3d_ManuallyAlignPointCloud,修改src/CMakeLists.txt,其中"D:/carlos/install/source_code/Open3D/Open3D0.14.1/Open3D/3rdparty/tinyfiledialogs/include"需要改成你本地的open3d源码的对应位置
CMakeLists.txt
cmake_minimum_required(VERSION 3.19.2)
project(ManualAlign)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
# The options need to be the same as Open3D's default
# If Open3D is configured and built with custom options, you'll also need to
# specify the same custom options.
option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" ON)
if(STATIC_WINDOWS_RUNTIME)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
endif()
find_package(Open3D REQUIRED)
message(${Open3D_INCLUDE_DIRS})
include_directories(
${Open3D_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}
${JSONCPP_DIR}/include
"D:/carlos/install/source_code/Open3D/Open3D0.14.1/Open3D/3rdparty/tinyfiledialogs/include"
)
add_executable(ManuallyAlignPointCloud)
target_sources(ManuallyAlignPointCloud PRIVATE
ManuallyAlignPointCloud.cpp
AlignmentSession.cpp
VisualizerForAlignment.cpp
)
target_link_libraries(ManuallyAlignPointCloud PRIVATE
Open3D::Open3D
Open3D::3rdparty_jsoncpp
Open3D::3rdparty_tinyfiledialogs
)
# set_target_properties(ManuallyAlignPointCloud PROPERTIES FOLDER "Tools")
# open3d_show_and_abort_on_warning(ManuallyAlignPointCloud)
# open3d_set_global_properties(ManuallyAlignPointCloud)
添加编译脚本:
compile.bat
rem By carlos_lee 202403
rem rd /s /q .\build
cmake -DOpen3D_DIR="D:/carlos/install/open3d141/CMake" ^
-DJSONCPP_DIR="D:/carlos/install/jsoncpp" ^
-S ./src . -B ./build -DCMAKE_BUILD_TYPE=Release
cmake --build ./build --config Release --target ALL_BUILD
mkdir bin
copy .\build\Release\ManuallyAlignPointCloud.exe .\bin
其中,DOpen3D_DIR是你编译好的open3d的安装路径,json见jsoncpp+cmake使用
编译
使用
具体的操作在代码里都写了,这些就是用来控制键盘回调函数的,在source和target分别按顺序选四个点,然后在alignment窗口点一下,ctrl+a就执行点对的刚体变换计算了,ctrl+r是重置点云位姿
选点操作:如果没用过open3d选点操作的,shift+左键是选一个点,shift+右键是取消上一个点的选择,在可视化窗口中(英文状态下)输入h,就会有cmd输出说明
添加运行脚本run_manualAlign.bat
.\bin\ManuallyAlignPointCloud.exe ^
D:\carlos\my_tools\data\bunny\data\bun045.ply ^
D:\carlos\my_tools\data\bunny\data\bun000.ply ^
--without_scaling --voxel_size 0.01 --max_corres_distance 0.05
其中,第二三行分别是你本地source和target点云的路径
运行
源码、编译好的工具和脚本在这里下载:
本博客资源链接/share_noel/csdn/open3d/open3d_ManuallyAlignPointCloud
下面就是操作示例
参考
文中已列出
完
主要做激光/影像三维重建,配准、分割等常用点云算法,熟悉open3d、pcl等开源点云库,技术交流、咨询可私信