Closed rosesolow closed 2 years ago
I'm not sure if I can answer all of your questions, but I'll try to help as much as I can!
I believe the captures are BGRA32 format by default, meaning each channel of (Blue, Green, Red, Alpha) is 8 bits, having values [0-255]. In your code, you create a default Config()
object with no arguments, so looking on Line 73 of pyk4a/config.py
, you'll see that the default pyk4a.Config()
object is as follows:
color_resolution: ColorResolution = ColorResolution.RES_720P,
color_format: ImageFormat = ImageFormat.COLOR_BGRA32,
depth_mode: DepthMode = DepthMode.NFOV_UNBINNED,
camera_fps: FPS = FPS.FPS_30,
synchronized_images_only: bool = True,
depth_delay_off_color_usec: int = 0,
wired_sync_mode: WiredSyncMode = WiredSyncMode.STANDALONE,
subordinate_delay_off_master_usec: int = 0,
disable_streaming_indicator: bool = False
If you'd prefer other formats, check out this page for the operating modes supported by the camera, and then create a pyk4a.Config()
object passing the corresponding values.
The helpers
module that is imported is just a small python file in the pyk4a/examples
folder. It contains two helper functions which are used by various pyk4a examples. You could also download this file and/or copy its functions to your own code if they are convenient for you.
As for why the depth image is all zeros, I believe I also had a similar issue when things were incorrectly/not fully installed on my system. Do you see any warnings/errors when you import pyk4a
? What errors did you get when you tried to pip install pyk4a
(not pyk4a-bundle
?
reopen is problem persists
I'm unable to properly capture the depth values from the Kinect with pyk4a. I can capture an image no problem, but the depth values are all zeros. I installed pyk4a-bundle, because "pip install pyk4a" had an install error unable to build wheels.
My code is below, I tried playing with the pyk4a config settings but that did not help.
Also, I'm confused by the shape of the color capture and depth capture. Color captures are shape (720, 1280, 4), why is there 4 values for every pixel location? Shouldn't it just be RGB? Depth captures are shape (576, 640), I was expecting depth captures to be the same resolution as the color captures (720,1280).
Additionally in your depth example files you are using "from helpers import colorize" to color images based on depth values, what is the "helpers" library you are using to colorize with?
import open3d as o3d import cv2 import pyk4a from pyk4a import Config, PyK4A import numpy as np
config = Config() k4a = PyK4A(config) k4a.start() capture = k4a.get_capture() points = capture.depth_point_cloud.reshape((-1, 3))
cv2.imshow("k4a", colorize(capture.depth, (None, 5000), cv2.COLORMAP_HSV))
cv2.imshow('img', capture.color) key = cv2.waitKey(10) k4a.stop()
print(capture.depth.shape) print(capture.color.shape)