Reputation: 929
I am trying to DLLImport the function simxGetVisionSensorImage
from remoteApi.dll
of v-rep software. Here is the link to the function description:
http://www.coppeliarobotics.com/helpFiles/en/remoteApiFunctions.htm#simxGetVisionSensorImage
and here is the brief description for this function from the above link:
Description: Retrieves the image of a vision sensor. The returned data doesn't make sense if simHandleVisionSensor wasn't called previously (simHandleVisionSensor is called by default in the main script if the vision sensor is not tagged as explicit handling). Use the simxGetLastCmdTime function to verify the "freshness" of the retrieved data.
C synopsis: simxInt simxGetVisionSensorImage(simxInt clientID,simxInt sensorHandle,simxInt* resolution,simxUChar** image,simxUChar options,simxInt operationMode)
C parameters:
clientID: the client ID. refer to simxStart.
sensorHandle: handle of the vision sensor
resolution: pointer to 2 simxInt values receiving the resolution of the image
image: pointer to a pointer to the image data.
options: image options, bit-coded: bit0 set: each image pixel is a byte (greyscale image), otherwise each image pixel is a rgb byte-triplet
operationMode: a remote API function operation mode.
Here is the way I am importing it (simxGetVisionSensorImage
function):
[DllImport("remoteApi.dll", CallingConvention = CallingConvention.Cdecl)]
public extern static simx_error simxGetVisionSensorImage(int clientID, int sensorHandle, out int resolution, out IntPtr image, char option, simx_opmode opmode);
and here is how I am calling it:
int intResolution = 0;
char option = '\0';
IntPtr imageIntPtr= IntPtr.Zero;
simxGetVisionSensorImage(intClientID, intCamera1Handle, out intResolution, out imageIntPtr, option, simx_opmode.streaming);
It runs successfully and intResolution is 128 and imageIntPtr is validated as well after running. However, I don't know how to convert the "imageIntPtr" variable to image or bitmap.
I really appreciate if someone can help me on this.
Upvotes: 1
Views: 314