Skip to content

Instantly share code, notes, and snippets.

@chatchavan
Last active August 27, 2015 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatchavan/c073b8b15e2c17ad1dbc to your computer and use it in GitHub Desktop.
Save chatchavan/c073b8b15e2c17ad1dbc to your computer and use it in GitHub Desktop.
PCL manual settings on Raspberry Pi
# These settings are obtained from
# pkg-config --print-variables pcl_common-1.7
# pkg-config --variable=libdir pcl_common-1.7
PCL_INCLUDE_DIRS=/usr/include/pcl-1.7
PCL_LIBRARY_DIRS=/usr/lib/arm-linux-gnueabihf
@chatchavan
Copy link
Author

Manual libraries paths:
/usr/lib/arm-linux-gnueabihf/libpcl_apps.so.1.7
/usr/lib/libOpenNI.so

Path of PCLConfig.cmake:

/usr/lib/arm-linux-gnueabihf/cmake/pcl
/home/pi/pcl-pcl-1.7.2/build/PCLConfig.cmake
/usr/local/share/pcl-1.7/PCLConfig.cmake

@chatchavan
Copy link
Author

Manually adding OpenNI in CMakeLists.txt of each project. Add the following text just below the line starting with set(PCL_BUILD_TYPE

set(OPENNI_INCLUDE_DIRS_HINT "/usr/include/ni")
set(OPENNI_LIBRARY_DIRS "/usr/lib/") 
set(OPENNI_LIBRARY "/usr/lib/libOpenNI.so")

@chatchavan
Copy link
Author

Fixing device not found

Edited sudo nano /usr/etc/primesense/GlobalDefaults.ini and uncommented ;UsbInterface=2 (removing semi colon)

@chatchavan
Copy link
Author

;UsbInterface=2: Python: works, PCL: doesn't work
UsbInterface =2: Python: works, PCL: doesn't work

@chatchavan
Copy link
Author

The depth generator is successfully created, but image generator is not.

  what():  void pcl::OpenNIGrabber::setupDevice(const string&, const pcl::OpenNIGrabber::Mode&, const pcl::OpenNIGrabber::Mode&) in /home/pi/pcl-pcl-1.7.2/io/src/openni_grabber.cpp @ 375 : No matching device found. openni_wrapper::OpenNIDevice::OpenNIDevice(xn::Context&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&, const xn::NodeInfo&) @ /home/pi/pcl-pcl-1.7.2/io/src/openni_camera/openni_device.cpp @ 133 : creating image generator failed. Reason: Failed to set USB interface!

Now testing different modes of image generator.

@chatchavan
Copy link
Author

In the worst case, we can try commenting out line 131-133 in io/src/openni_camera/openni_device.cpp and recompile PCL. :(

@chatchavan
Copy link
Author

Commented out in openni_device.cpp:

// status = context_.CreateProductionTree (const_cast<xn::NodeInfo&>(image_node), image_generator_);
  // if (status != XN_STATUS_OK)
  //   THROW_OPENNI_EXCEPTION ("creating image generator failed. Reason: %s", xnGetStatusString (status));
// image_generator_.RegisterToNewDataAvailable (static_cast<xn::StateChangedHandler> (NewImageDataAvailable), this, image_callback_handle_);

@chatchavan
Copy link
Author

Also

// status = context_.CreateProductionTree (const_cast<xn::NodeInfo&>(ir_node), ir_generator_);
  // if (status != XN_STATUS_OK)
  //   THROW_OPENNI_EXCEPTION ("creating IR generator failed. Reason: %s", xnGetStatusString (status));
// ir_generator_.RegisterToNewDataAvailable (static_cast<xn::StateChangedHandler> (NewIRDataAvailable), this, ir_callback_handle_);

@chatchavan
Copy link
Author

also, make the following methods return 0 always.

openni_wrapper::OpenNIDevice::hasImageStream () const throw ()
openni_wrapper::OpenNIDevice::hasIRStream () const throw ()

@chatchavan
Copy link
Author

Also, make these methods return without doing anything:

openni_wrapper::OpenNIDevice::setIROutputMode (const XnMapOutputMode& output_mode)
openni_wrapper::OpenNIDevice::setImageOutputMode (const XnMapOutputMode& output_mode)

@chatchavan
Copy link
Author

in openni_device_primesense.cpp, comment out lines (commenting out the image_generator_ stuff and ensure that status is declared) :

openni_wrapper::DevicePrimesense::DevicePrimesense (
    xn::Context& context, 
    const xn::NodeInfo& device_node, 
    const xn::NodeInfo& image_node, 
    const xn::NodeInfo& depth_node, 
    const xn::NodeInfo& ir_node) : OpenNIDevice (context, device_node, image_node, depth_node, ir_node)
{
  // setup stream modes
  enumAvailableModes ();
  setDepthOutputMode (getDefaultDepthMode ());
  setImageOutputMode (getDefaultImageMode ());
  setIROutputMode (getDefaultIRMode ());

  boost::unique_lock<boost::mutex> image_lock (image_mutex_);
  // XnStatus status = image_generator_.SetIntProperty ("InputFormat", 5);
  // if (status != XN_STATUS_OK)
  //   THROW_OPENNI_EXCEPTION ("Error setting the image input format to Uncompressed YUV422. Reason: %s", xnGetStatusString (status));

  // status = image_generator_.SetPixelFormat (XN_PIXEL_FORMAT_YUV422);
  // if (status != XN_STATUS_OK)
  //   THROW_OPENNI_EXCEPTION ("Failed to set image pixel format to YUV422. Reason: %s", xnGetStatusString (status));

  image_lock.unlock ();

  boost::lock_guard<boost::mutex> depth_lock (depth_mutex_);
  XnStatus status = depth_generator_.SetIntProperty ("RegistrationType", 1);
  if (status != XN_STATUS_OK)
    THROW_OPENNI_EXCEPTION ("Error setting the registration type. Reason: %s", xnGetStatusString (status));
}

@chatchavan
Copy link
Author

In your program, changed the binding function to use only XYZ. Basically, replace everything with XYZRGBA to XYZ

boost::function<void (const PointCloud<PointXYZ>::ConstPtr&)> f =
            boost::bind(&grabberCallback, _1);

@chatchavan
Copy link
Author

The example in pcl/io/tools/openni_grabber_depth_example.cpp may be a better starting point than the one on the website.

@chatchavan
Copy link
Author

Knowledge in this post is captured in this fork of PCL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment