Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Typically: "How do I... ", "How can I... " questions
Post Reply
SkySurfer1
Posts: 7
Joined: 14 Mar 2016, 14:34

Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by SkySurfer1 » 02 Mar 2018, 14:18

Hi,

I try to take an image using a camera sensor inside of vrep export it to my application using remote c++ API modifiy it and return it to vrep.

What I have done right now:

Added 2 cameras to the scene at the same place (camera1 & camera2).
Camera1 records the scene camera2 is set to use external image and creates an floating view and shows the processed image.

What my programm does:

Code: Select all

// setup programm, open connection , ...

    union {
        struct {
            unsigned int x;
            unsigned int y;
        };
        simxInt ptr[2];
    } resolution = {{0,0}};

simxInt result = simxGetObjectHandle(mConnectionhandle, "camera1", &mSensorHandle1, simx_opmode_blocking);
simxUChar* image;
result = simxGetVisionSensorImage(mConnectionhandle, mSensorHandle1, resolution.ptr, &image, 0, simx_opmode_buffer);

// modify image and show it on screen
 simxInt size = resolution.x * resolution.y * 3;
 result = simxGetObjectHandle(mConnectionhandle, name, &mSensorHandle2, simx_opmode_blocking);
 result = simxSetVisionSensorImage(mConnectionhandle, mSensorHandle2, image, size, 0, simx_opmode_oneshot); 

Everything works fine except of the simxSetVisionSensorImage call this returns simx_return_remote_error_flag

How can I figure out what is the problem on setting the image?

BR

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

Re: Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by coppelia » 02 Mar 2018, 16:47

Hello,

you can try to use simxGetLastErrors. Make also sure that the resolution of the vision sensor where you want to apply the image is the same size as the image.
Also, have a look at this topic.

Cheers

SkySurfer1
Posts: 7
Joined: 14 Mar 2016, 14:34

Re: Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by SkySurfer1 » 05 Mar 2018, 11:25

Hi,

I checked resolution of the camera, and usage of simxSetVisionSensorImage is like in the mentioned post.
I added the following code:

Code: Select all

result = simxSetVisionSensorImage(mConnectionhandle, mSensorHandle2, image, size, 0, simx_opmode_blocking); 
if (result != simx_return_ok) {
    simxInt numErrors = 0;
    simxChar* errors[500];

    simxInt result = simxGetLastErrors(connection, &numErrors, errors, simx_opmode_blocking);
    std::cout << "Errors : " << numErrors << std::endl;
    for(int i = 0; i < numErrors; ++i)
    {
        std::cout << i << errors[i] << std::endl;
    }
}
I set both calls to blocking but result = 8 end numError = 0

Is there any other way to get more detailed information on what is failing?

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

Re: Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by coppelia » 06 Mar 2018, 09:06

You should retrieve errors like:

Code: Select all

simxInt numErrors = 0;
simxChar* errors;

simxInt result = simxGetLastErrors(mConnectionhandle, &numErrors, &errors, simx_opmode_blocking);
std::cout << "Errors : " << numErrors << std::endl;
int off=0;
for(int i = 0; i < numErrors; ++i)
{
    std::cout << i << errors+off << std::endl;
    off+=strlen(errors+off);
}
Btw you used a different clientId to retrieve errors.
The simxSetVisionSensorImage function can only remotely fail in following conditions:
  • the vision sensor handle is not valid, or does not correspond to a vision sensor
  • following is not equal: sensorResX*sensorResY*bytesPerPixel != imageSize
Cheers

SkySurfer1
Posts: 7
Joined: 14 Mar 2016, 14:34

Re: Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by SkySurfer1 » 07 Mar 2018, 11:40

I checked naming and resolution but same issue.
I put together a minimal example that represents my issue which can be found here:https://www.dropbox.com/s/wbws2pwy42pjl ... st.7z?dl=0.

With V-REP 3.4 it is working fine.
With V-REP 3.5 it returns 8 on setting vision sensor image. So this could be a bug in 3.5?

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

Re: Set vision sensor image from remote API alrways return simx_return_remote_error_flag

Post by coppelia » 07 Mar 2018, 16:17

You are indeed right, there is a problem, that was fixed here.
The change is reflected in the V-REP version 3.5.0.rev3, available now in the download section.

Thanks a lot for pointing onto that bug.

Cheers

Post Reply