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, res, 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.