Getting strange width, height and size from the grabber callback [closed]

asked 2011-11-06 19:59:37 -0500

plpatric gravatar image

Hi there

I'm trying to get the simple OpenNI grabber tutorial (http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber) to work within ros, but somehow the cloud I receive from the callback is garbage. The cloud claims to have the following properties:

  • width 0, height 0, size 18446744009285042156

But when I compile it without ros the tutorial works just fine. Does ros set some compile options which could cause that?

(Running on Ubuntu 10.04 64Bit)

Source code:

     class SimpleOpenNIViewer
     {
       public:
     SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}

     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud) { 
        static unsigned count = 0;
        static double last = pcl::getTime ();

        std::cout << "1 -> width " << cloud->width << ", height " << cloud->height << ", size " << cloud->points.size() << std::endl;

        if (!viewer.wasStopped()) {
         viewer.showCloud (cloud);
        }
     }

     void run () {
       pcl::Grabber* interface = new pcl::OpenNIGrabber();

       boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> f =
         boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

       interface->registerCallback (f);

       interface->start ();

       while (!viewer.wasStopped()) {
         sleep (1);
       }

       interface->stop ();
     }

     pcl::visualization::CloudViewer viewer;
     };

     int main (int argc, char** argv) {
       ros::init(argc, argv, "openni_grabber");
       ros::NodeHandle n;

   SimpleOpenNIViewer v;
   v.run ();
   return 0;
 }

CMakeLists.txt

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()
find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})


set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_add_executable(openni_grabber src/openni_grabber.cpp)

target_link_libraries(openni_grabber ${PCL_LIBRARIES})
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by tfoote
close date 2012-06-09 10:41:34

Comments

For PCL questions please ask on the pcl-users mailing list.

tfoote gravatar image tfoote  ( 2012-06-09 10:41:22 -0500 )edit

I really wonder the answer though. Could you find an answer?

mary gravatar image mary  ( 2013-08-08 01:47:45 -0500 )edit