Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Depth to color image registration fails in OpenNI

📅 2015-Jan-20 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ image registration, openni, primesense ⬩ 📚 Archive

Problem

I wrote C++ code to read depth and color images from a Primesense camera using OpenNI 2, running on Windows. After initializing OpenNI and opening the Primesense device, I check if depth-to-color image registration mode is supported by calling psense_device.isImageRegistrationModeSupported(openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR). This returns openni::STATUS_OK. So, next I set this image registration mode by calling psense_device.setImageRegistrationMode(openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR). However, this fails!

Solution

I could not actually figure out why OpenNI reports that the device supports this mode, but fails setting it. I suspected that maybe the camera needs to see depth and color video streams being created before this mode is set. So, I set this mode as late as possible, after the depth-color streams are opened and configured. That seemed to work!

Tried with: Primesense camera, OpenNI 2, Visual Studio 2013 and Windows 7 Professional 64-bit