Page 1 of 1

How are images from sim.getVisionSensorImage() formatted?

Posted: 05 Apr 2021, 19:21
by tim_wiesner
I'm using a vision sensor that I'm reading from python through the legacy API. The sensor has a resolution of 32x32 (RGB). Hence, I get 3072 individual numbers. In python, I want to reformat this one long array into something more useful, ideally a numpy array of size 32x32x3 and in a way that the first element of the outer array corresponds to the first row of pixels, and the first element from that array corresponds to RGB values of the left-most pixel. I'm currently using this code

Code: Select all

np.array(cam_image).reshape((res[0], res[1], 3))
in python, with cam_image being the 3072 elements-long array I get from Coppelia and res the x and y resolution (so both 32 in my case). However, I can't find anything that states if that's the correct way of reformatting it.

Re: How are images from sim.getVisionSensorImage() formatted?

Posted: 06 Apr 2021, 15:46
by fferri
Yes reshape is used to change the shape of a matrix (without changing the order of elements).