我安装了PCL1.7.2。我正在尝试使用PCL库。
我想通过" const"来显示相机的参数,所以,我想获取相机的参数。但我不明白如何获取相机的参数。
我看到" pcl :: visualization :: Camera Class Reference"。 http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_camera.html
我知道#34;相机"有焦点,位置,视图等。宾语。
现在我已确认以下代码已运行。
但我无法理解如何获得相机会员。 这是设置Camera的成员值的方法。 viewer.setCameraPosition(pos_x,pos_y,pos_z,view_x,view_y,view_z,up_x,up_y,up_z,viewport);
所以,有人请告诉我如何使用以下代码获取相机的参数。
这是现在的道路来源。
#include "stdafx.h"
#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
int user_data=0;
void
viewerOneOff(pcl::visualization::PCLVisualizer& viewer)
{
viewer.setBackgroundColor(1.0, 0.5, 1.0);
pcl::PointXYZ o;
o.x = 1.0;
o.y = 0;
o.z = 0;
viewer.addSphere(o, 0.25, "sphere", 0);
std::cout << "i only run once" << std::endl;
}
void
viewerPsycho(pcl::visualization::PCLVisualizer& viewer)
{
static unsigned count = 0;
std::stringstream ss;
ss << "Once per viewer loop: " << count++;
viewer.removeShape("text", 0);
viewer.addText(ss.str(), 200, 300, "text", 0);
//FIXME: possible race condition here:
user_data++;
}
int _tmain(int argc, const _TCHAR** argv)
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
pcl::io::loadPCDFile("c:\\data\\triceratops\\raw_0.pcd", *cloud);
pcl::visualization::CloudViewer viewer("Cloud Viewer");
//blocks until the cloud is actually rendered
viewer.showCloud(cloud);
//use the following functions to get access to the underlying more advanced/powerful
//PCLVisualizer
//This will only get called once
viewer.runOnVisualizationThreadOnce(viewerOneOff);
//This will get called once per visualization iteration
viewer.runOnVisualizationThread(viewerPsycho);
while (!viewer.wasStopped())
{
//you can also do cool processing here
//FIXME: Note that this is running in a separate thread from viewerPsycho
//and you should guard against race conditions yourself...
user_data++;
}
return 0;
}
答案 0 :(得分:6)
这应该有效:
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
std::vector<pcl::visualization::Camera> cam;
//Save the position of the camera
viewer->getCameras(cam);
//Print recorded points on the screen:
cout << "Cam: " << endl
<< " - pos: (" << cam[0].pos[0] << ", " << cam[0].pos[1] << ", " << cam[0].pos[2] << ")" << endl
<< " - view: (" << cam[0].view[0] << ", " << cam[0].view[1] << ", " << cam[0].view[2] << ")" << endl
<< " - focal: (" << cam[0].focal[0] << ", " << cam[0].focal[1] << ", " << cam[0].focal[2] << ")" << endl;