PCL缩小功能 我对点云库(PCL)和C++编程是新的。我加载多个作为参数给出的.ply文件(比如test0.ply,test1.ply…test99.ply),并将它们一个接一个地可视化,就像它们是视频帧一样
下面是我到目前为止所做的尝试。如何在每一帧(缩小)期间离模型更远?PCL缩小功能 我对点云库(PCL)和C++编程是新的。我加载多个作为参数给出的.ply文件(比如test0.ply,test1.ply…test99.ply),并将它们一个接一个地可视化,就像它们是视频帧一样,c++,point-cloud-library,point-clouds,C++,Point Cloud Library,Point Clouds,下面是我到目前为止所做的尝试。如何在每一帧(缩小)期间离模型更远?setCameraPosition函数看起来相关,但描述令人困惑 更新:我们需要找到相机的当前位置,并使用它。就像放大/缩小一样 #include <iostream> //#include <unistd.h> #include <pcl/io/pcd_io.h> #include <pcl/io/ply_io.h> #include <pcl/point_cloud.h&g
setCameraPosition
函数看起来相关,但描述令人困惑
更新:我们需要找到相机的
当前位置
,并使用它。就像放大/缩小一样
#include <iostream>
//#include <unistd.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_cloud.h>
#include <pcl/console/parse.h>
#include <pcl/common/transforms.h>
#include <pcl/visualization/pcl_visualizer.h>
// This function displays the help
void showHelp(char *program_name)
{
std::cout << std::endl;
std::cout << "Usage: " << program_name << " cloud_filename.[pcd|ply]" << std::endl;
std::cout << "-h: Show this help." << std::endl;
}
// Main function
int main(int argc, char **argv)
{
// Show help
if (pcl::console::find_switch(argc, argv, "-h") || pcl::console::find_switch(argc, argv, "--help"))
{
showHelp(argv[0]);
return 0;
}
// Fetch point cloud filename in arguments | Works with PLY files
std::vector<int> filenames;
filenames = pcl::console::parse_file_extension_argument(argc, argv, ".ply");
// Visualization
printf("\n Point cloud colors :\n"
" \t white \t = \t original point cloud \n");
pcl::visualization::PCLVisualizer viewer(" Point Cloud Visualizer");
viewer.setBackgroundColor(0.05, 0.05, 0.05, 0); // Set background to a dark grey
// Load file | Works with PLY files
pcl::PointCloud<pcl::PointXYZRGB>::Ptr source_cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
int i = 0;
while (1)
{
// int v1(0);
// viewer.createViewPort(0.0, 0.0, 0.5, 1.0, v1);
i++;
cout << argv[filenames[i % 10]] << endl;
if (pcl::io::loadPLYFile(argv[filenames[i % 10]], *source_cloud) < 0)
{
std::cout << "Error loading point cloud " << argv[filenames[(i % 10) + 1]] << std::endl << std::endl;
showHelp(argv[(i % 10) + 1]);
return -1;
}
// Define R,G,B colors for the point cloud
pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(source_cloud);
// We add the point cloud to the viewer and pass the color handler
viewer.addPointCloud(source_cloud, rgb, "original_cloud" + i);
viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "original_cloud" + i);
viewer.spinOnce();
viewer.removePointCloud("original_cloud" + i);
}
return 0;
} // End main()
#包括
//#包括
#包括
#包括
#包括
#包括
#包括
#包括
//此函数显示帮助
void showHelp(字符*程序名)
{
std::cout我认为你的思路是正确的,setCameraPosition()应该是你要寻找的。下面是一些示例代码,它将相机聚焦在特定的点上,并将相机放置在距离y维度5米的地方
pcl::PointXYZI center = centerPoint(cloud);
viewer->setCameraPosition(center.x, center.y - 5, center.z, 0, 0, 1);
std::vector<pcl::visualization::Camera> cams;
viewer->getCameras(cams);
for (auto&& camera : cams)
{
camera.focal[0] = center.x;
camera.focal[1] = center.y;
camera.focal[2] = center.z;
}
viewer->setCameraParameters(cams[0]);
pcl::PointXYZI center=中心点(云);
查看器->设置摄影机位置(center.x,center.y-5,center.z,0,0,1);
矢量凸轮;
查看器->获取摄像头(摄像头);
用于(自动和照相机:凸轮)
{
相机焦距[0]=中心.x;
相机焦距[1]=中心y;
相机焦距[2]=中心点z;
}
查看器->设置摄像机参数(摄像机[0]);
所以只需调用设置摄像机位置(center.x,center.y-5,center.z,0,0,1);
本身不起作用?摄像机的焦距是什么?顺便说一句,标识符“centerPoint”是未定义的
我相信camera.focus设置了相机应该聚焦的位置。这与相机在空间中应该定位的位置是不同的。您可能可以对setCameraPosition()的另一个重载调用执行相同的操作是的,它可以工作。但是它把它放在一个奇怪的位置。我必须玩它。那么这里的指标是什么?还有相对距离的方法吗?(例如,当前视图,在Z轴上只移动-5)我们需要找到相机的当前位置
并玩它。就像放大/缩小一样。