Depth to color image registration fails in OpenNI


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!


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


2 thoughts on “Depth to color image registration fails in OpenNI

  1. Hi, I am facing problem while registering the color_depth image by Primesense. I had used following snippet.

    def Depth(self):
    self.depth_stream =
    c_api.OniVideoMode(pixelFormat=c_api.OniPixelFormat.ONI_PIXEL_FORMAT_DEPTH_1_MM, resolutionX=640, resolutionY=480,
    self.depthFrame = self.depth_stream.read_frame()
    self.depthData = self.depthFrame.get_buffer_as_uint16()
    self.imgDepth = np.frombuffer(self.depthData, dtype=np.uint16)
    self.depthMat = np.reshape(self.imgDepth, (480, 640))“Regi_cam2_depth”, self.depthMat)

    When I apply above code, the depth values with registration image and without registration image(when I comment ) is not same. Depth values are scaled down. Some depth values are lost. What is the issue. Kindly advice.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.