我目前正在做一个项目,我需要使用 PyKinect 库访问和处理深度数据。
我想要做的是定义一个深度阈值,我将在其中进行一些图像分割,但由于我是 PyKinect 的新手,我仍然不太清楚在哪里寻找资源,我不知道如何访问该数据并获取值。
我也试过使用 freenect 库,但我无法让它工作。
谁能告诉我该怎么做或将我重定向到某种文档?
我已在 Windows 10 系统上安装了 KinectV2 SDK,并在 SDK 浏览器中成功测试了它。
我尝试运行 Pykinect2 库中的一些代码,但导入时出现问题:
from pykinect2 import PyKinectV2
Run Code Online (Sandbox Code Playgroud)
错误:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[2], line 1
----> 1 from pykinect2 import PyKinectV2
2 from pykinect2.PyKinectV2 import *
File ~\Anaconda3\envs\kinect-env\lib\site-packages\pykinect2\PyKinectV2.py:2216
2131 ################################################################
2132 ## code template for ICoordinateMapper implementation
2133 ##class ICoordinateMapper_Impl(object):
(...)
2200 ## #return colorPoint
2201 ##
2203 tagSTATSTG._fields_ = [
2204 ('pwcsName', WSTRING),
2205 ('type', c_ulong),
(...)
2214 ('reserved', c_ulong),
2215 ]
-> 2216 assert sizeof(tagSTATSTG) == …Run Code Online (Sandbox Code Playgroud) 我目前正在使用 Pygame 和 pykinect2 从 Kinect2 摄像头获取实时 RGB 视频。我想将其转换为开放的简历图像,以便对我进一步的计算有所帮助。
import pykinect2
import pygame
import cv2
import ctypes
from pykinect2 import PyKinectV2
from pykinect2 import PyKinectRuntime
kinectcam = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Color)
def draw_color_frame(frame, target_surface):
target_surface.lock()
address = kinectcam.surface_as_array(target_surface.get_buffer())
ctypes.memmove(address, frame.ctypes.data, frame.size)
del address
target_surface.unlock()
pygame.init()
frame_surface = pygame.Surface((kinectcam.color_frame_desc.Width, kinectcam.color_frame_desc.Height), 0, 32)
clock = pygame.time.Clock()
pygame.display.set_caption("Kinect View")
infoObject = pygame.display.Info()
screen = pygame.display.set_mode((infoObject.current_w >> 1, infoObject.current_h >> 1),
pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)
clock = pygame.time.Clock()
done = False
while not done:
for event in pygame.event.get(): # …Run Code Online (Sandbox Code Playgroud)