xxorde / librekinect

Depth data from a kinect sensor! Small and fast kernel driver. Also for embedded devices like the raspberry pi!
407 stars 68 forks source link

Getting 10bit depth image from the Kinect #24

Closed packoman closed 9 years ago

packoman commented 9 years ago

Hi. This is not so much an issue as a question: I have successfully gotten librekinect working on the Raspberry Pi (version B). Aside from still having issues at initialization, which I will investigate later its working (e.g. I have to reload the driver a couplte of times and disconnect/reconnect the Kinect), it working and that is awesome! So first of all: A HUGE thanks for your work!!!

I am currently trying out Python-OpenCV for development. The issue I am having is that when I read from the Kinect under /dev/video0 using the code shown below below, I only get an 8bit image. From what I could gather using Google this is expected, since OpenCV will not get more bit-depth from webcams. This results in very poor precision on the depth-position.

import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(True):
        ret, frame = cap.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
                break
cap.release()
cv2.destroyAllWindows()

From what I could gather looking at the code of the driver it works with 10bit giving back the full bit-depth of the Kinects depth-image. Is this Correct? If so my question is how I can read it at that precision and idealy get it into a Python Numpy array for further processing(?). BTW: I have found this link: http://www.jayrambhia.com/blog/capture-v4l2/, where it is explained how to use V4L2 in C to capture images from a video-device and it seems that there you can set the bit-depth (if I understand the code correctly - I didn't try it). But I do not know how I would do/integrate this from Python.

Any help is greatly appreciated!

xxorde commented 9 years ago

To be honest, the kinect can also deliver 11 bit images, I hard coded it to 10 bit.

The driver is delivering an 10 bit image. If you have trouble to integrate this in python, it's a bit more promising to ask your question to some experts in that field. (I really like python myself, but can not help you with this.)

You could try here: https://stackoverflow.com/ Looks like there are a lot people around doing image processing with python.