Trouble with vision sensor output to remote API

Typically: "How do I... ", "How can I... " questions
Post Reply
georgeyhere
Posts: 1
Joined: 01 Apr 2021, 00:56

Trouble with vision sensor output to remote API

Post by georgeyhere »

Hi,

I'm trying to use simxGetVisionSensorImage to get an image from a vision sensor through remote API to a python client.

Code/output: https://gyazo.com/95dc0a236b4a5e3e8ac93876009fe737

Code: Select all

retCode, camHandle = sim.simxGetObjectHandle(clientID, 'cam1', sim.simx_opmode_blocking) # get handle of vision sensor 'cam1'

if clientID != -1:
    
    while (sim.simxGetConnectionId(clientID) != -1): 
    
        retCode, resolution, image = sim.simxGetVisionSensorImage(clientID,
                                                                  camHandle,
                                                                  0,
                                                                  sim.simx_opmode_buffer)
        
        print(retCode)
        print(resolution)
        print(image)

        if (retCode == sim.simx_return_ok):
            img = np.array(image, dtype = np.uint8)
            img.resize(resolution[0], resolution[1], 3)
            break
else:
    print ('Remote API connection failed.')
It keeps returning an error code of 1 and does not return any values for resolution or the image itself. The vision sensor is perspective type, non-explicitly handled.

Any help would be appreciated!

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

Re: Trouble with vision sensor output to remote API

Post by coppelia »

Hello,

did you read how to get data from CoppeliaSim and/or execute remote API function calls via the legacy remote API?

Make sure you read about data streaming via the legacy remote API, since it appears that's what you want to do. And here you can read about the meaning of return codes.

Cheers

Post Reply