Skip to content

how to set colored image  #119

Description

@angle2392

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions