2013-01-21 19 views
0

我正在使用Python中的OpenCV。我想從華碩Xtion獲得輸入。 我能夠成功運行PyOpenNI中的樣本。 我想在opencv中使用igen.get_synced_image_map_bgr()獲得的圖像(str格式)。用於OpenCV的PyOpenNI輸入

IGEN-ImageGenerator

我想將其轉換爲IplImage。 我該怎麼做,或者我怎樣才能在Opencv python代碼中使用來自深度傳感器的輸入。

回答

0

我最近在PyOpenNI和OpenCV中使用Kinect的字符串格式深度數據。使用可以從字符串創建的numpy數組,這是Python的cv2(OpenCV)中的默認數據類型。

代碼示例這裏:http://euanfreeman.co.uk/pyopenni-and-opencv/

不知道Kinect的從深度傳感器的不同之處,但是這可能是一個很好的起點。祝你好運!

編輯:添加代碼

from openni import * 
import numpy as np 
import cv2 

# Initialise OpenNI 
context = Context() 
context.init() 

# Create a depth generator to access the depth stream 
depth = DepthGenerator() 
depth.create(context) 
depth.set_resolution_preset(RES_VGA) 
depth.fps = 30 

# Start Kinect 
context.start_generating_all() 
context.wait_any_update_all() 

# Create array from the raw depth map string 
frame = np.fromstring(depth.get_raw_depth_map_8(), "uint8").reshape(480, 640) 

# Render in OpenCV 
cv2.imshow("image", frame)