# how to get coordinate from bounding box

I need to get information about real time coordinates of mobile bounding box? So, the real time coordinates can be showed up in terminals or published to topics.

Here is my snippet code to draw bounding box from PCL:

 while (!viewer.wasStopped())
{
if (new_cloud_available_flag && cloud_mutex.try_lock ())    // if a new cloud is available
{
new_cloud_available_flag = false;

// Perform people detection on the new cloud:
std::vector<pcl::people::PersonCluster<PointT> > clusters;   // vector containing persons clusters
people_detector.setInputCloud(cloud);
people_detector.setGround(ground_coeffs);                    // set floor coefficients
people_detector.compute(clusters);                           // perform people detection

ground_coeffs = people_detector.getGround();                 // get updated floor coefficients

// Draw cloud and people bounding boxes in the viewer:
viewer.removeAllPointClouds();
viewer.removeAllShapes();
pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cloud);
unsigned int k = 0;

for(std::vector<pcl::people::PersonCluster<PointT> >::iterator it = clusters.begin(); it != clusters.end(); ++it)
{
if(it->getPersonConfidence() > min_confidence)             // draw only people with confidence above a threshold
{
// draw theoretical person bounding box in the PCL viewer:
it->drawTBoundingBox(viewer, k);
k++;
}
}
cout << k << " people found" << endl;

viewer.spinOnce();


I need to display the bounding box in x,y,z coordinates (real time) or another parameters to set the robot forward, turn left or right. I think the x,y,z is much better, remember this node is always need to set the ground plane in early and weak parameter (no significant value whether bounding box is in the middle or not) although it is real time too.

when i try to use this code:

  for (size_t i = 0; i < 2; ++i)
std::cout << "    " << cloud->points[i].x
<< " "    << cloud->points[i].y
<< " "    << cloud->points[i].z << std::endl;


the node shows nan (maybe, no available number?) thank your for your helping :)

edit retag close merge delete