-
-
Save chatchavan/c073b8b15e2c17ad1dbc to your computer and use it in GitHub Desktop.
# 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 |
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")
Edited sudo nano /usr/etc/primesense/GlobalDefaults.ini
and uncommented ;UsbInterface=2
(removing semi colon)
;UsbInterface=2
: Python: works, PCL: doesn't work
UsbInterface =2
: Python: works, PCL: doesn't work
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.
In the worst case, we can try commenting out line 131-133 in io/src/openni_camera/openni_device.cpp
and recompile PCL. :(
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_);
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_);
also, make the following methods return 0 always.
openni_wrapper::OpenNIDevice::hasImageStream () const throw ()
openni_wrapper::OpenNIDevice::hasIRStream () const throw ()
Also, make these methods return without doing anything:
openni_wrapper::OpenNIDevice::setIROutputMode (const XnMapOutputMode& output_mode)
openni_wrapper::OpenNIDevice::setImageOutputMode (const XnMapOutputMode& output_mode)
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));
}
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);
The example in pcl/io/tools/openni_grabber_depth_example.cpp
may be a better starting point than the one on the website.
Knowledge in this post is captured in this fork of PCL
Manual libraries paths:
/usr/lib/arm-linux-gnueabihf/libpcl_apps.so.1.7
/usr/lib/libOpenNI.so
Path of
PCLConfig.cmake
: