## Sensor Image with C++

Typically: "How do I... ", "How can I... " questions
jegovila
Posts: 6
Joined: 19 May 2013, 00:06

### Sensor Image with C++

Hello

I am trying to send an image from V-REP to C++. I am familiar with image processing in Matlab and I am trying to do something like that in C++, i.e. sending an image as a 2-D matrix and access to each pixel and its intensity (0-255).

I saw the Api function "simxGetVisionSensorImage", and one of the parameters is the image that is a pointer to a pointer. I tried this:

Code: Select all

int resolution[2];
resolution[0]=100;
resolution[1]=100;
char **image=NULL;

simxGetVisionSensorImage(clientID,vision,resolution,image,0,simx_opmode_streaming);
printf("%d \n",*(*(image+1)+2));

And I expected to receive the intensity value for the pixel in the first row and second column (image[1][2]) but the client just stop working.

Then I thought that I had to specify the size of the data I am going to receive and I tried to add something like this:

Code: Select all

char *image1=(char *) malloc(65000);
image= &image1;

But It did not work...

There is a way to access to the data of the image just like matlab? i.e. to each pixel of the 2-D matrix?

Thanks!

coppelia