Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set colored image #119

Open
angle2392 opened this issue Apr 11, 2024 · 0 comments
Open

how to set colored image #119

angle2392 opened this issue Apr 11, 2024 · 0 comments

Comments

@angle2392
Copy link

Hello pyKinectAzure(s),

I am using parts of pyKinectAzure but "offline" on RGB and depth data. I recorded .jpeg images and .png images from a scene and want to pass it to a "Capture" object. There are some functions to pass images to a capture.

It works for me with depth data:


depth_im = cv2.imread("./depth.png",cv2.IMREAD_ANYDEPTH)
h, w = depth_im.shape
depth_image_np = np.array(depth_im)
#Convert numpy array to a ctypes array:
ctypes_data = depth_image_np.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8))
 
depth_image_k4a = _k4a.k4a_image_t()
_k4a.VERIFY(_k4a.k4a_image_create_from_buffer(_k4atypes.K4A_IMAGE_FORMAT_DEPTH16, w, h, depth_image_np.nbytes//h, ctypes_data, depth_image_np.nbytes , None, None, depth_image_k4a)," failed!")
_k4a.k4a_capture_set_depth_image(capture_handle, depth_image_k4a)

However, it does not work for RGB data:

im = cv2.imread("./rgb.jpeg", cv2.IMREAD_COLOR)
h_im, w_im, c = im.shape
image_np = np.array(im).flatten()
ctypes_data_im = image_np.ctypes.data_as(ctypes.POINTER(ctypes.c_uint8))
	
color_image_k4a = _k4a.k4a_image_t()
_k4a.VERIFY(_k4a.k4a_image_create_from_buffer(_k4atypes.K4A_IMAGE_FORMAT_COLOR_MJPG, w_im, h_im, w_im, ctypes_data_im, image_np.nbytes, None, None, color_image_k4a)," failed!")
_k4a.k4a_capture_set_color_image(capture_handle, color_image_k4a)

What am I doing wrong? Any clue why it does not take the RGB data?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant