Kinect RGB through Python Remote connection

Typically: "How do I... ", "How can I... " questions
Post Reply
t2chiang
Posts: 3
Joined: 23 Mar 2024, 23:10

Kinect RGB through Python Remote connection

Post by t2chiang »

Hello, I am now using kinect camera to get the RGB image and the disparity image in copelliasim.

Here is my code:

Code: Select all

err, _, rgbImage = sim.simxGetVisionSensorImage(clientID, camRgbHandle, 0, sim.simx_opmode_oneshot_wait)
image_R = np.array([rgbImage[i] for i in range(0, len(rgbImage), 3)]).reshape(resY, resX).astype(np.uint8)
image_G = np.array([rgbImage[i] for i in range(1, len(rgbImage), 3)]).reshape(resY, resX).astype(np.uint8)
image_B = np.array([rgbImage[i] for i in range(2, len(rgbImage), 3)]).reshape(resY, resX).astype(np.uint8)
However, the err is not equal to sim.simx_return_ok, and the image size is 0 and then simulation stop.

I got the handle object by the following code:

Code: Select all

_, camRgbHandle = sim.simxGetObjectHandle(clientID, camRgbName, sim.simx_opmode_blocking)
Is anything wrong with my code?

Thank you guys

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Kinect RGB through Python Remote connection

Post by coppelia »

Hello,

please use the ZeroMQ remote API, which is much faster, flexible and easy to use. The legacy remote API is deprecated.

Cheers

Post Reply