Multiple Cameras

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Multiple Cameras

Nico Riecker
Hey there,

I try to visualize the image of my two cameras: Creative Senz3d and a SoftKinetic.

For connecting I use the PXCGrabber from PCL . That works for both cameras.

But if I connect both the same time and create 2 grabbers, both grabbers connect to the same camera (Senz3d).

Heres my code:

pcl::visualization::PCLVisualizer viewer("PCL Viewer");
pcl::visualization::PCLVisualizer viewer2("PCL Viewer2");

void cloud_cb_ (const PointCloudT::ConstPtr &callback_cloud, PointCloudT::Ptr& cloud, bool* new_cloud_available_flag)
{
  *cloud = *callback_cloud;
  *new_cloud_available_flag = true;
}

void cloud_cb2_ (const PointCloudT::ConstPtr &callback_cloud, PointCloudT::Ptr& cloud, bool* new_cloud_available_flag)
{
  *cloud = *callback_cloud;
  *new_cloud_available_flag = true;
}

int main(int argc, char** argv)
{
    PointCloudT::Ptr cloud (new PointCloudT);
    PointCloudT::Ptr cloud2 (new PointCloudT);
    bool new_cloud_available_flag = false;
    bool new_cloud_available_flag2 = false;

    boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f = boost::bind(&cloud_cb_, _1, cloud, &new_cloud_available_flag);
    boost::function<void (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr&)> f2 = boost::bind(&cloud_cb2_, _1, cloud2, &new_cloud_available_flag2
);

    pcl::PXCGrabber* interface = new pcl::PXCGrabber();
    interface->registerCallback(f);
    interface->start();

    while(!new_cloud_available_flag)
    {
        boost::this_thread::sleep(boost::posix_time::milliseconds(1));
    }

    pcl::PXCGrabber* interface2 = new pcl::PXCGrabber();
    interface2->registerCallback(f2);
    interface2->start();

    while(!new_cloud_available_flag2)
    {
        boost::this_thread::sleep(boost::posix_time::milliseconds(1));
    }

    new_cloud_available_flag = false;
    new_cloud_available_flag2 = false;

    pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cloud);
    pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb2(cloud2);

    viewer.addPointCloud<PointT>(cloud, rgb, "input_cloud");
    viewer2.addPointCloud<PointT>(cloud2, rgb2, "input_cloud2");

    while(!viewer.wasStopped() && !viewer2.wasStopped())
    {
        if(new_cloud_available_flag)
        {
            new_cloud_available_flag = false;
            viewer.removeAllPointClouds();
            viewer.removeAllShapes();
            pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cloud);
            viewer.addPointCloud<PointT> (cloud, rgb, "input_cloud");
            viewer.spinOnce();
        }

        if(new_cloud_available_flag2)
        {
            new_cloud_available_flag2 = false;
            viewer2.removeAllPointClouds();
            viewer2.removeAllShapes();
            pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb2(cloud2);
            viewer2.addPointCloud<PointT> (cloud2, rgb2, "input_cloud2");
            viewer2.spinOnce();
        }
    }

    return 0;
}

The viewers open 2 windows ... everything ok except that the datas are the same

Regards,
Nico


_______________________________________________
PCL-developers mailing list
[hidden email]
http://pointclouds.org/mailman/listinfo/pcl-developers
http://pointclouds.org