簡體   English   中英

OpenCV的PyOpenNI輸入

[英]PyOpenNI input for OpenCV

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

igen-ImageGenerator

我想將其轉換為IplImage 我該怎么做,或者我該如何使用Opencv python代碼中深度傳感器的輸入。

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

此處的代碼示例: 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM