Sensor Image with C++

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

Sensor Image with C++

Post by jegovila » 03 Sep 2013, 22:24

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
Site Admin
Posts: 7272
Joined: 14 Dec 2012, 00:25

Re: Sensor Image with C++

Post by coppelia » 04 Sep 2013, 09:49

Hello,

Have a look at this post, which illustrates how to use simxGetVisionSensorDepthBuffer. simxGetVisionSensorImage basically works in a similar way, except that you have 3 times more values (for the red, green and blue components).

Cheers

Post Reply