I am trying to learn V-rep and its integration with Python remote API. I created a dummy model and added a vision sensor to it. I am running V-rep on continuous remote server mode by editing 'remoteconnections.txt' file.
I have not selected 'explicit Handling' in Vision Sensor Object Scene Properties(as per my understanding from documentation)
I wrote the following code to get the image file and I get following error.Is there any way to work around this? Any help would be much appreciated.
Code: Select all
from PIL import Image import array import vrep vrep.simxFinish(-1) # just in case, close all opened connections clientID=vrep.simxStart('127.0.0.1',19999,True,True,5000,5) # Connect to V-REP if clientID!=-1: x = vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot) res, v0 = vrep.simxGetObjectHandle(clientID, 'Vision_sensor', vrep.simx_opmode_oneshot_wait) res, resolution, image = vrep.simxGetVisionSensorImage(clientID, v0, 0, vrep.simx_opmode_streaming) print(type(image)) image_byte_array = array.array('b', image) im = Image.frombuffer("RGB", (256, 144), image_byte_array, "raw", "RGB", 0, 1) im.show() else: print('Error')