如需安装运行环境或远程调试,可加QQ905733049, 或QQ2945218359由专业技术人员远程协助!
运行结果如下:
代码如下:
#include
#include "open3d/Open3D.h"
using namespace open3d;
void SingleObject() {
// No colors, no normals, should appear unlit black
auto cube = geometry::TriangleMesh::CreateBox(1, 2, 4);
}
void MultiObjects() {
const double pc_rad = 1.0;
auto pc_nocolor = MakePointCloud(100, {0.0, -2.0, 0.0}, pc_rad, false);
auto pc_color = MakePointCloud(100, {3.0, -2.0, 0.0}, pc_rad, true);
const double r = 0.4;
auto sphere_unlit = geometry::TriangleMesh::CreateSphere(r);
sphere_unlit->Translate({0.0, 1.0, 0.0});
auto sphere_colored_unlit = geometry::TriangleMesh::CreateSphere(r);
sphere_colored_unlit->PaintUniformColor({1.0, 0.0, 0.0});
sphere_colored_unlit->Translate({2.0, 1.0, 0.0});
auto sphere_lit = geometry::TriangleMesh::CreateSphere(r);
sphere_lit->ComputeVertexNormals();
sphere_lit->Translate({4, 1, 0});
auto sphere_colored_lit = geometry::TriangleMesh::CreateSphere(r);
sphere_colored_lit->ComputeVertexNormals();
sphere_colored_lit->PaintUniformColor({0.0, 1.0, 0.0});
sphere_colored_lit->Translate({6, 1, 0});
auto big_bbox = std::make_shared(
Eigen::Vector3d{-pc_rad, -3, -pc_rad},
Eigen::Vector3d{6.0 + r, 1.0 + r, pc_rad});
auto bbox = sphere_unlit->GetAxisAlignedBoundingBox();
auto sphere_bbox = std::make_shared(
bbox.min_bound_, bbox.max_bound_);
sphere_bbox->color_ = {1.0, 0.5, 0.0};
auto lines = geometry::LineSet::CreateFromAxisAlignedBoundingBox(
sphere_lit->GetAxisAlignedBoundingBox());
auto lines_colored = geometry::LineSet::CreateFromAxisAlignedBoundingBox(
sphere_colored_lit->GetAxisAlignedBoundingBox());
lines_colored->PaintUniformColor({0.0, 0.0, 1.0});
visualization::Draw({pc_nocolor, pc_color, sphere_unlit,
sphere_colored_unlit, sphere_lit, sphere_colored_lit,
big_bbox, sphere_bbox, lines, lines_colored});
}
void Actions() {
const char *SOURCE_NAME = "Source";
const char *RESULT_NAME = "Result (Poisson reconstruction)";
const char *TRUTH_NAME = "Ground truth";
auto bunny = std::make_shared();
io::ReadTriangleMesh(TEST_DIR + "/Bunny.ply", *bunny);
if (bunny->vertices_.empty()) {
utility::LogError(
"Please download the Standford Bunny dataset using:\n"
" cd /examples/python\n"
" python -c 'from open3d_tutorial import *; "
"get_bunny_mesh()'");
return;
}
bunny->PaintUniformColor({1, 0.75, 0});
bunny->ComputeVertexNormals();
auto cloud = std::make_shared();
cloud->points_ = bunny->vertices_;
cloud->normals_ = bunny->vertex_normals_;
cloud->PaintUniformColor({0, 0.2, 1.0});
auto make_mesh = [SOURCE_NAME, RESULT_NAME](
visualization::visualizer::O3DVisualizer &o3dvis) {
std::shared_ptr source =
std::dynamic_pointer_cast(
o3dvis.GetGeometry(SOURCE_NAME).geometry);
auto mesh = std::get<0>(
geometry::TriangleMesh::CreateFromPointCloudPoisson(*source));
mesh->PaintUniformColor({1, 1, 1});
mesh->ComputeVertexNormals();
o3dvis.AddGeometry(RESULT_NAME, mesh);
o3dvis.ShowGeometry(SOURCE_NAME, false);
};
auto toggle_result =
[TRUTH_NAME,
RESULT_NAME](visualization::visualizer::O3DVisualizer &o3dvis) {
bool truth_vis = o3dvis.GetGeometry(TRUTH_NAME).is_visible;
o3dvis.ShowGeometry(TRUTH_NAME, !truth_vis);
o3dvis.ShowGeometry(RESULT_NAME, truth_vis);
};
visualization::Draw({visualization::DrawObject(SOURCE_NAME, cloud),
visualization::DrawObject(TRUTH_NAME, bunny, false)},
"Open3D: Draw Example: Actions", 1024, 768,
{
{"Create Mesh", make_mesh},
{"Toggle truth/result", toggle_result}});
}
void Selections() {
std::cout << "Selection example:" << std::endl;
std::cout << " One set: pick three points from the source (yellow), "
<< std::endl;
std::cout << " then pick the same three points in the target"
"(blue) cloud"
<< std::endl;
std::cout << " Two sets: pick three points from the source cloud, "
<< std::endl;
std::cout << " then create a new selection set, and pick the"
<< std::endl;
std::cout << " three points from the target." << std::endl;
const auto cloud0_path = TEST_DIR + "/ICP/cloud_bin_0.pcd";
const auto cloud1_path = TEST_DIR + "/ICP/cloud_bin_2.pcd";
auto source = std::make_shared();
io::ReadPointCloud(cloud0_path, *source);
if (source->points_.empty()) {
utility::LogError("Could not open {}", cloud0_path);
return;
}
auto target = std::make_shared();
io::ReadPointCloud(cloud1_path, *target);
if (target->points_.empty()) {
utility::LogError("Could not open {}", cloud1_path);
return;
}
source->PaintUniformColor({1.000, 0.706, 0.000});
target->PaintUniformColor({0.000, 0.651, 0.929});
const char *source_name = "Source (yellow)";
const char *target_name = "Target (blue)";
auto DoICPOneSet =
[source, target, source_name,
target_name](visualization::visualizer::O3DVisualizer &o3dvis) {
auto sets = o3dvis.GetSelectionSets();
if (sets.empty()) {
utility::LogWarning(
"You must select points for correspondence before "
"running ICP!");
return;
}
auto &source_picked_set = sets[0][source_name];
auto &target_picked_set = sets[0][target_name];
std::vector
source_picked(source_picked_set.begin(),
source_picked_set.end());
std::vector
target_picked(target_picked_set.begin(),
target_picked_set.end());
std::sort(source_picked.begin(), source_picked.end());
std::sort(target_picked.begin(), target_picked.end());
auto t = GetICPTransform(*source, *target, source_picked,
target_picked);
source->Transform(t);
// Update the source geometry
o3dvis.RemoveGeometry(source_name);
o3dvis.AddGeometry(source_name, source);
};
int main(int argc, char **argv) {
if (!utility::filesystem::DirectoryExists(TEST_DIR)) {
utility::LogError(
"directory");
}
SingleObject();
}
运行结果:
C++学习参考实例:
C++实现图形界面五子棋游戏源码:
https://blog.csdn.net/alicema1111/article/details/90035420
C++实现图形界面五子棋游戏源码2:
https://blog.csdn.net/alicema1111/article/details/106479579
C++ OpenCV相片视频人脸识别统计人数:
https://blog.csdn.net/alicema1111/article/details/105833928
VS2017+PCL开发环境配置:
https://blog.csdn.net/alicema1111/article/details/106877145
VS2017+Qt+PCL点云开发环境配置:
https://blog.csdn.net/alicema1111/article/details/105433636
C++ OpenCV汽车检测障碍物与测距:
https://blog.csdn.net/alicema1111/article/details/105833449
Windows VS2017安装配置PCL点云库:
https://blog.csdn.net/alicema1111/article/details/105111110
VS+VTK+Dicom(dcm)+CT影像切片窗体界面显示源码
https://blog.csdn.net/alicema1111/article/details/106994839
Python学习参考实例:
Python相片更换背景颜色qt窗体程序:
https://blog.csdn.net/alicema1111/article/details/106919140
OpenCV汽车识别检测数量统计:
https://blog.csdn.net/alicema1111/article/details/106597260
OpenCV视频识别检测人数跟踪统计:
https://blog.csdn.net/alicema1111/article/details/106113042
OpenCV米粒检测数量统计:
https://blog.csdn.net/alicema1111/article/details/106089697
opencv人脸识别与变形哈哈镜:
https://blog.csdn.net/alicema1111/article/details/105833123
OpenCV人脸检测打卡系统:
https://blog.csdn.net/alicema1111/article/details/105315066
Python+OpenCV摄像头人脸识别:
https://blog.csdn.net/alicema1111/article/details/105107286
Python+Opencv识别视频统计人数:
https://blog.csdn.net/alicema1111/article/details/103804032
Python+OpenCV图像人脸识别人数统计:
https://blog.csdn.net/alicema1111/article/details/105378639
python人脸头发身体部位识别人数统计:
https://blog.csdn.net/alicema1111/article/details/116424942
PHP网页框架:
PHP Laravel框架安装与配置后台管理前台页面显示:
https://blog.csdn.net/alicema1111/article/details/106686523