当前位置: 首页 > news >正文

[C++][pcl]pcl安装后测试代码3

测试环境:

vs2019

pcl==1.12.1

代码:

#include<iostream>
#include <thread>#include <pcl/common/common_headers.h>
#include <pcl/features/normal_3d.h>
#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/console/parse.h>
#include <boost/current_function.hpp>using namespace pcl;int main(int argc, char** argv)
{// 1. 创建和设置可视化窗口std::string strWinName = "3D Viewer", strWinTitle = "Point Cloud Viewer";int scnWidth = 1024, scnHeight = 800;visualization::PCLVisualizer::Ptr viewer(new visualization::PCLVisualizer(strWinName));viewer->setWindowName(strWinTitle);viewer->initCameraParameters(); // set camera before set sizeviewer->setPosition(0, 0);viewer->setSize(scnWidth, scnHeight);viewer->setShowFPS(false);// viewportsint vMenu(0), v1(0), v2(0);viewer->createViewPort(0.0, 0.0, 1.0, 0.2, vMenu); // used as interfaceviewer->createViewPort(0.0, 0.2, 0.5, 1.0, v1);viewer->createViewPort(0.5, 0.2, 1.0, 1.0, v2);// Background Colorviewer->setBackgroundColor(0.8, 0.8, 0.8, vMenu); // light greyviewer->setBackgroundColor(0.1, 0.1, 0.1, v1); // dark greyviewer->setBackgroundColor(0.2, 0.2, 0.2, v2); // dark grey// camerasviewer->createViewPortCamera(v1);viewer->createViewPortCamera(v2);double pos[3] = { 6,0,0 }; // camera at X-axisdouble foc[3] = { 0,0,0 }; // viewpoint at orgindouble up[3] = { 0,0,1 };  // up is Z-axisviewer->setCameraPosition(pos[0], pos[1], pos[2], foc[0], foc[1], foc[2], up[0], up[1], up[2]);// check cameras//std::vector<visualization::Camera> cams;//viewer->getCameras(cams);// coordinatesviewer->addCoordinateSystem(1.0, "ref_v1", v1);viewer->addCoordinateSystem(1.0, "ref_v2", v2);// 2. 创建点云数据和添加点云。PointCloud<PointXYZ>::Ptr cloud_ptr(new PointCloud<PointXYZ>);PointCloud<PointXYZRGB>::Ptr cloud_color_ptr(new PointCloud<PointXYZRGB>);std::uint8_t r(255), g(15), b(15);for (float z = -1.0; z <= 1.0; z += 0.05){for (float angle = 0.0; angle <= 360.0; angle += 5.0){pcl::PointXYZ basic_point;basic_point.x = 0.5 * std::cos(pcl::deg2rad(angle));basic_point.y = sinf(pcl::deg2rad(angle));basic_point.z = z;cloud_ptr->points.push_back(basic_point); // 将每个点输入点云pcl::PointXYZRGB point;point.x = basic_point.x;point.y = basic_point.y;point.z = basic_point.z;std::uint32_t rgb = (static_cast<std::uint32_t>(r) << 16 |static_cast<std::uint32_t>(g) << 8 | static_cast<std::uint32_t>(b));point.rgb = *reinterpret_cast<float*>(&rgb);cloud_color_ptr->points.push_back(point); // 将每个点输入点云}if (z < 0.0){r -= 12; // light red at -|z| g += 12; // light green at 0}else{g -= 12; // light green at 0b += 12; // light blue at +|z|}}cloud_ptr->width = cloud_ptr->size(); // 无规则点云的width为点数cloud_ptr->height = 1;cloud_color_ptr->width = cloud_color_ptr->size(); // 无规则点云的width为点数cloud_color_ptr->height = 1;bool ret = viewer->addPointCloud<PointXYZ>(cloud_ptr, "cloud1"); // 白色点云if (ret){double clrR = 0, clrG = 0, clrB = 1, szPoint = 3;viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_COLOR, clrR, clrG, clrB, "cloud1"); // 设置点云颜色viewer->setPointCloudRenderingProperties(visualization::PCL_VISUALIZER_POINT_SIZE, szPoint, "cloud1"); // 设置大小}elseviewer->updatePointCloud<PointXYZ>(cloud_ptr, "cloud1");//3. 进入主循环while (!viewer->wasStopped()){// 如果点云不断更新,在这里添加点云// 如果需要改变视角,在这里设置相机viewer->spinOnce(100, true);Sleep(100);}
}

演示结果:

相关文章:

[C++][pcl]pcl安装后测试代码3

测试环境&#xff1a; vs2019 pcl1.12.1 代码&#xff1a; #include<iostream> #include <thread>#include <pcl/common/common_headers.h> #include <pcl/features/normal_3d.h> #include <pcl/io/pcd_io.h> #include <pcl/visualizatio…...

在WSL下使用makefile运行modelsim进行混合编译

modelsim的图像界面加载缓慢&#xff0c;实际上modelsim可以在纯命令行环境下仿真&#xff0c;使用-c参数:vsim -c。可以在WSL下用makefile运行Windows下的modelsim&#xff1a; HDL_CODE . HDL_CODE ../../rtl/ MODELSIM_ROOT : /mnt/e/exe/modeltech64_10.4/win…...

idea 常用插件和常用快捷键 - 记录

idea 常用插件 记得下载插件完成后&#xff0c;点击 Apply 和 OK Alibaba Java Coding Guidelines 作用&#xff1a;使用该插件可以&#xff0c;自动提示相关的语法格式问题&#xff0c;格式参考 阿里巴巴代码规范 详情链接&#xff1a; 代码规范之Alibaba Java Coding G…...

IDEA报错:Plugin ‘org.springframework.boot:spring-boot-maven-plugin:‘ not found

问题&#xff1a; 使用IDEA新建spring boot项目&#xff0c;报错如下&#xff1a; Plugin org.springframework.boot:spring-boot-maven-plugin: not found解决办法&#xff1a; 1.在本地maven仓库中找到spring-boot-maven-plugin的版本号 2.在pom.xml文件中添加对应的版本…...

C++——Vector:push_back和emplace_back的区别,测试写入1GB大数据时的性能差距

什么是emplace_back emplace_back是C11引入的STL容器成员函数。emplace操作只执行构造而不执行拷贝构造。 如何理解上面这句话&#xff1f;先来看一个场景。 class test { public:test(){}test(int i){ std::cout << "test(int i)" << std::endl; }tes…...

C/C++/QT/Python/MATLAB获取文件行数的示例

1. C获取文件行数 #include <stdio.h>int main() {FILE *file fopen("path/to/your/file.txt", "r");if (file NULL) {printf("Failed to open the file!\n");return 0;}int lineCount 0;char ch;while ((ch fgetc(file)) ! EOF) {if…...

mysql的binlog參數詳解

mysql的binlog參數詳解 1. expire_logs_days expire_logs_days&#xff1a;這個參數用於設置binlog日誌文件的過期時間。默認情況下&#xff0c;binlog文件永不過期。如果將其設置為一個正整數值&#xff0c;則表示binlog文件在指定天數後會被自動刪除。 max_binlog_size m…...

【SpringSecurity】九、Base64与JWT

文章目录 1、base64编码2、Base64Url3、JWT的产生背景4、JWT介绍5、JWT组成5.1 Header5.2 Payload5.3 Signature 6、JWT的使用方式7、JWT的几个特点 1、base64编码 base64是一种编码方式&#xff0c;不是加密方式。 所谓Base64&#xff0c;就是说选出64个字符&#xff1a;小写…...

Python的io模块

io 模块提供了 Python 用于处理各种 I/O 类型的主要工具。三种主要的 I/O类型分别为: 文本 I/O, 二进制 I/O 和 原始 I/O。 io.open() 是内置的 open() 函数的别名. 语法&#xff1a; open(file,moder,buffering-1,encodingNone,errorsNone,newlineNone,closefdTrue,openerN…...

CSS---flex布局

主要记录flex布局的要点以及实例 flex flex父标签的6个属性flex-direction: flex布局的方向flex-wrap: 是否可以换行flex-flow: flex-direction 和 flex-wrap 一起写justify-content&#xff1a;横向对齐方式align-items: 纵向对齐方式align-content: 有换行情况下的纵向对齐方…...

java线程和go协程

一、线程的实现 线程的实现方式主要有三种&#xff1a;内核线程实现、用户线程实现、用户线程加轻量级进程混合实现。因为自己只对java的线程比较熟悉一点&#xff0c;所以主要针对java线程和go的协程之间进行一个对比。 线程模型主要有三种&#xff1a;1、内核级别线程&#…...

JAVA 时间戳

时间戳&#xff08;Timestamp&#xff09;是一个表示特定时间点的数值&#xff0c;通常指的是自某个固定的起始时间&#xff08;如1970年1月1日00:00:00 UTC&#xff09;以来经过的秒数或毫秒数。 在 Java 中&#xff0c;可以使用 System.currentTimeMillis() 方法获取当前的时…...

层次分析法(matlab实现)

1.层次分析法&#xff08;AHP&#xff09; 在决策理论中&#xff0c;层次分析法是一种以数学和心理学为基础&#xff0c;组织和分析复杂决策的结构化技术&#xff0c;它代表了一种量化决策标准权重的准确方法&#xff0c;通过成对比较&#xff0c;利用个别专家的经验来估计因素…...

python selenium 自动化登录页面

去掉自动化标识&#xff0c;绕过js&#xff0c;绕过ip import time from selenium import webdriver from selenium.webdriver.chrome.options import Options# 去掉自动化标识&#xff0c;绕过js option Options() option.add_experimental_option(excludeSwitches, [enable…...

【Linux】高级IO --- 多路转接,select,poll,epoll

所有通过捷径所获取的快乐&#xff0c;无论是金钱、性还是名望&#xff0c;最终都会给自己带来痛苦 文章目录 一、五种IO模型1.什么是高效的IO&#xff1f;&#xff08;降低等待的时间比重&#xff09;2.有哪些IO模型&#xff1f;哪些模型是高效的&#xff1f;3.五种IO模型的特…...

anaconda navigator打不开,一直在loading画面

anaconda navigator打不开&#xff0c;一直在loading画面。百度解决方法&#xff0c;用网上的方法在命令窗口里运行conda update anaconda结果一直显示 solving environment卡在那里。又尝试用管理员身份运行还是不行&#xff0c;打开后出现There in aninstance of Anaconda Na…...

【Java基础】深入理解反射、反射的应用(工厂模式、代理模式)

文章目录 1. Java反射机制是什么&#xff1f;1.2 Java反射例子 2. Java反射机制中获取Class的三种方式及区别&#xff1f;3. Java反射机制的应用场景有哪些&#xff1f;3.1. 优化静态工厂模式&#xff08;解耦&#xff09;3.1.1 优化前&#xff08;工厂类和产品类耦合&#xff…...

VUE 项目 nginx部署

server {listen 80; # 监听的端口号server_name 129.204.189.149; # 服务器的ip或者域名#charset koi8-r;#access_log logs/host.access.log main;# 前端服务反向代理配置location / {proxy_http_version 1.1;proxy_set_header Host $host;proxy_set_header X-Real-…...

Hashtable和HashMap、ConcurrentHashMap 之间的区别

Hashtable和HashMap的区别 HashMap和Hashtable都是哈希表数据结构&#xff0c;但是Hashtable是线程安全的&#xff0c;HashMap是线程不安全的 Hashtable实现线程安全就是简单的把关键方法都加上了synchronized关键字 直接在方法上添加synchronized相当于针对this对象&#xff0…...

包管理工具--》npm的配置及使用(二)

在阅读本篇文章前请先阅读包管理工具--》npm的配置及使用&#xff08;一&#xff09; 目录 &#x1f31f;语义版本 避免还原的差异 npm的差异版本处理 &#x1f31f;npm 脚本 &#xff08;npm scripts&#xff09; &#x1f31f;运行环境配置 在node中读取package.json …...

React Native 开发环境搭建(全平台详解)

React Native 开发环境搭建&#xff08;全平台详解&#xff09; 在开始使用 React Native 开发移动应用之前&#xff0c;正确设置开发环境是至关重要的一步。本文将为你提供一份全面的指南&#xff0c;涵盖 macOS 和 Windows 平台的配置步骤&#xff0c;如何在 Android 和 iOS…...

cf2117E

原题链接&#xff1a;https://codeforces.com/contest/2117/problem/E 题目背景&#xff1a; 给定两个数组a,b&#xff0c;可以执行多次以下操作&#xff1a;选择 i (1 < i < n - 1)&#xff0c;并设置 或&#xff0c;也可以在执行上述操作前执行一次删除任意 和 。求…...

基于Java Swing的电子通讯录设计与实现:附系统托盘功能代码详解

JAVASQL电子通讯录带系统托盘 一、系统概述 本电子通讯录系统采用Java Swing开发桌面应用&#xff0c;结合SQLite数据库实现联系人管理功能&#xff0c;并集成系统托盘功能提升用户体验。系统支持联系人的增删改查、分组管理、搜索过滤等功能&#xff0c;同时可以最小化到系统…...

QT3D学习笔记——圆台、圆锥

类名作用Qt3DWindow3D渲染窗口容器QEntity场景中的实体&#xff08;对象或容器&#xff09;QCamera控制观察视角QPointLight点光源QConeMesh圆锥几何网格QTransform控制实体的位置/旋转/缩放QPhongMaterialPhong光照材质&#xff08;定义颜色、反光等&#xff09;QFirstPersonC…...

C++.OpenGL (20/64)混合(Blending)

混合(Blending) 透明效果核心原理 #mermaid-svg-SWG0UzVfJms7Sm3e {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-icon{fill:#552222;}#mermaid-svg-SWG0UzVfJms7Sm3e .error-text{fill…...

手机平板能效生态设计指令EU 2023/1670标准解读

手机平板能效生态设计指令EU 2023/1670标准解读 以下是针对欧盟《手机和平板电脑生态设计法规》(EU) 2023/1670 的核心解读&#xff0c;综合法规核心要求、最新修正及企业合规要点&#xff1a; 一、法规背景与目标 生效与强制时间 发布于2023年8月31日&#xff08;OJ公报&…...

git: early EOF

macOS报错&#xff1a; Initialized empty Git repository in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/ remote: Enumerating objects: 2691797, done. remote: Counting objects: 100% (1760/1760), done. remote: Compressing objects: 100% (636/636…...

VisualXML全新升级 | 新增数据库编辑功能

VisualXML是一个功能强大的网络总线设计工具&#xff0c;专注于简化汽车电子系统中复杂的网络数据设计操作。它支持多种主流总线网络格式的数据编辑&#xff08;如DBC、LDF、ARXML、HEX等&#xff09;&#xff0c;并能够基于Excel表格的方式生成和转换多种数据库文件。由此&…...

【HarmonyOS 5】鸿蒙中Stage模型与FA模型详解

一、前言 在HarmonyOS 5的应用开发模型中&#xff0c;featureAbility是旧版FA模型&#xff08;Feature Ability&#xff09;的用法&#xff0c;Stage模型已采用全新的应用架构&#xff0c;推荐使用组件化的上下文获取方式&#xff0c;而非依赖featureAbility。 FA大概是API7之…...

倒装芯片凸点成型工艺

UBM&#xff08;Under Bump Metallization&#xff09;与Bump&#xff08;焊球&#xff09;形成工艺流程。我们可以将整张流程图分为三大阶段来理解&#xff1a; &#x1f527; 一、UBM&#xff08;Under Bump Metallization&#xff09;工艺流程&#xff08;黄色区域&#xff…...