|
@@ -86,7 +86,7 @@ int GetOptLong(int argc, char *argv[]) {
|
|
|
|
|
|
pcl::visualization::CloudViewer viewer1("Cloud Viewer");//创建viewer对象
|
|
|
|
|
|
-int user_data;
|
|
|
+int user_data = 0;
|
|
|
|
|
|
void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
{
|
|
@@ -111,7 +111,7 @@ void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsign
|
|
|
point_cloud->height = 1;
|
|
|
point_cloud->width = 0;
|
|
|
pcl::PointXYZI * p;
|
|
|
- std::cout<<" size : "<<nPCount<<std::endl;
|
|
|
+ std::cout<<std::chrono::system_clock::now().time_since_epoch().count()/1000000 <<" size : "<<nPCount<<std::endl;
|
|
|
p = (pcl::PointXYZI *)((char *)strdata + *pHeadSize);
|
|
|
for(i=0;i<nPCount;i++)
|
|
|
{
|
|
@@ -134,6 +134,7 @@ void ListenPointCloud(const char * strdata,const unsigned int nSize,const unsign
|
|
|
user_data++;
|
|
|
viewer1.showCloud(point_cloud);
|
|
|
|
|
|
+
|
|
|
// return;
|
|
|
|
|
|
|
|
@@ -149,6 +150,8 @@ void viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
|
|
|
//设置背景颜色
|
|
|
viewer.setBackgroundColor(0.0,0.0,0.0);
|
|
|
|
|
|
+ viewer.setCameraPosition(0,0,100,0,0,0,0,1,0);
|
|
|
+
|
|
|
// viewer.setCameraPosition(0,0,1.0,0,0,0);
|
|
|
// viewer.setBackgroundColor (1.0, 0.5, 1.0);
|
|
|
//球体坐标
|
|
@@ -160,11 +163,33 @@ void viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
|
|
|
|
|
|
// viewer.addSphere (o, 1, "sphere", 0);
|
|
|
|
|
|
+// pcl::ModelCoefficients line_coeff;
|
|
|
+// line_coeff.values.resize (6); // We need 4 values
|
|
|
+// line_coeff.values[0] = 0;
|
|
|
+// line_coeff.values[1] = 0;
|
|
|
+// line_coeff.values[2] = 0;
|
|
|
+// line_coeff.values[3] = 8;
|
|
|
+// line_coeff.values[4] = 8;
|
|
|
+// line_coeff.values[5] = 8;
|
|
|
+
|
|
|
+
|
|
|
+// viewer.addLine(line_coeff);
|
|
|
+
|
|
|
+
|
|
|
+// pcl::PointXYZ pos;
|
|
|
+// pos.x = 0;
|
|
|
+// pos.y = 10;
|
|
|
+// pos.z = 1;
|
|
|
+// viewer.addText3D("car",pos,0.1,1.0,0.0,0.0);
|
|
|
+
|
|
|
viewer.addCube(-0.9,0.9,9.5,10.5,-1.9,-0.4,0.0,1.0,0.0,"flag",0);
|
|
|
//Draw Car
|
|
|
viewer.addCube(-0.9,0.9,-2.3,2.3,-1.9,-0.4,0.0,0.0,1.0,"car",0);
|
|
|
|
|
|
|
|
|
+ viewer.addCoordinateSystem(1.0);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
std::cout << "i only run once" << std::endl;
|
|
|
|
|
@@ -172,13 +197,31 @@ void viewerOneOff (pcl::visualization::PCLVisualizer& viewer)
|
|
|
|
|
|
void viewerPsycho (pcl::visualization::PCLVisualizer& viewer)
|
|
|
{
|
|
|
- static unsigned count = 0;
|
|
|
+// static unsigned count = 0;
|
|
|
std::stringstream ss;
|
|
|
// ss << "Once per viewer loop: " << count++;
|
|
|
|
|
|
ss << "Point Cloud Count: " << user_data;
|
|
|
viewer.removeShape ("text", 0);
|
|
|
- viewer.addText (ss.str(), 200, 300, "text", 0);
|
|
|
+ viewer.addText (ss.str(), 50, 50, "text", 0);
|
|
|
+
|
|
|
+// static int nview = 1;
|
|
|
+// nview++;
|
|
|
+// std::cout<<" nview: "<<nview<<std::endl;
|
|
|
+// std::cout<<" user_data: "<<user_data<<std::endl;
|
|
|
+ if(user_data == 1)
|
|
|
+ {
|
|
|
+ viewer.setCameraPosition(0,0,100,0,0,0,0,1,0);
|
|
|
+ }
|
|
|
+
|
|
|
+// std::vector<pcl::visualization::Camera> xvectorcam;
|
|
|
+// viewer.getCameras(xvectorcam);
|
|
|
+// std::cout<<"camera size: "<<xvectorcam.size()<<std::endl;
|
|
|
+// if(xvectorcam.size()>0)
|
|
|
+// {
|
|
|
+// std::cout<<" pos: "<<xvectorcam[0].pos[0]<<" "<<xvectorcam[0].pos[1]<<" "<<xvectorcam[0].pos[2]<<" "<<std::endl;
|
|
|
+// }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -206,6 +249,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
//This will only get called once
|
|
|
viewer1.runOnVisualizationThreadOnce (viewerOneOff);
|
|
|
|