简体   繁体   English

OpenCV的PyOpenNI输入

[英]PyOpenNI input for OpenCV

I'm working with OpenCV in Python. 我正在Python中使用OpenCV I want to get input from Asus Xtion . 我想从华硕Xtion获得输入。 I'm able to successfully run samples from PyOpenNI . 我能够从PyOpenNI成功运行示例。 I want to use the image obtained (str format) by igen.get_synced_image_map_bgr() in opencv. 我想使用由opencv中的igen.get_synced_image_map_bgr()获得的图像(str格式)。

igen-ImageGenerator igen-ImageGenerator

I want to convert it to IplImage . 我想将其转换为IplImage How can I do it,or How can I otherwise use the input from the depth sensor in Opencv python code. 我该怎么做,或者我该如何使用Opencv python代码中深度传感器的输入。

I recently used the string format depth data from Kinect in PyOpenNI with OpenCV. 我最近在OpenCV的PyOpenNI中使用了Kinect的字符串格式深度数据。 Use numpy arrays which can be created from strings and which are the default data type in cv2 (OpenCV) for Python. 使用可以从字符串创建的numpy数组,它们是cv2(OpenCV)中Python的默认数据类型。

Code example here: http://euanfreeman.co.uk/pyopenni-and-opencv/ 此处的代码示例: http : //euanfreeman.co.uk/pyopenni-and-opencv/

Not sure how Kinect differs from your depth sensor but that may be a useful starting point. 不确定Kinect与您的深度传感器有何不同,但这可能是一个有用的起点。 Good luck! 祝好运!

Edit: added code 编辑:添加代码

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM