Skip to content

Instantly share code, notes, and snippets.

@jonbinney
Created January 11, 2013 19:10
Show Gist options
  • Save jonbinney/4513125 to your computer and use it in GitHub Desktop.
Save jonbinney/4513125 to your computer and use it in GitHub Desktop.
patch for using openni_camera with oni files
# HG changeset patch
# User ruben.smits@intermodalics.eu
# Date 1354264641 -3600
# Node ID f0a77d69738b2eac0cbcb938280434b53ea0dc5e
# Parent 4ece7c6f00fbda4bd63f2e5d7a1743485e2e2304
Add support to read from oni files. No extra parameters are added. Will always loop and stream.
diff -r 4ece7c6f00fb -r f0a77d69738b src/nodelets/driver.cpp
--- a/src/nodelets/driver.cpp Sun Jun 10 22:38:34 2012 -0500
+++ b/src/nodelets/driver.cpp Fri Nov 30 09:37:21 2012 +0100
@@ -209,7 +209,23 @@
// Initialize the openni device
OpenNIDriver& driver = OpenNIDriver::getInstance ();
- do {
+ string device_id;
+ try {
+ if (getPrivateNodeHandle().getParam("device_id", device_id)){
+ if(device_id.find('.oni') != string::npos){
+ {
+ NODELET_INFO ("Creating virtual device from ONI file = %s",device_id.c_str());
+ device_ = driver.createVirtualDevice(device_id,true,true);
+ }
+ }
+ }
+ }
+ catch (const OpenNIException& exception) {
+ NODELET_ERROR ("No ONI file found: ", exception.what ());
+ exit (-1);
+ }
+
+ while (!device_) {
driver.updateDeviceList ();
if (driver.getNumberDevices () == 0)
@@ -230,7 +246,6 @@
}
try {
- string device_id;
if (!getPrivateNodeHandle().getParam("device_id", device_id))
{
NODELET_WARN ("~device_id is not set! Using first device.");
@@ -270,7 +285,7 @@
exit (-1);
}
}
- } while (!device_);
+ }
NODELET_INFO ("Opened '%s' on bus %d:%d with serial number '%s'", device_->getProductName (),
device_->getBus (), device_->getAddress (), device_->getSerialNumber ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment