## Streaming video camera

Typically: "How do I... ", "How can I... " questions
coppelia
Posts: 7594
Joined: 14 Dec 2012, 00:25

### Re: Streaming video camera

Yes, you will be able to use BlueZero in other applications too, since it is a c/c++ library.

Also, releasing the buffer returned by V-REP (e.g. in simGetVisionSensorCharImage) is very important, otherwise you will run into memory issues.

Cheers

lpitonakova
Posts: 17
Joined: 22 Nov 2017, 12:32

### Re: Streaming video camera

Ok - I made the char* array (I assume that's what you mean by buffer) a class variable. So, are you saying that it's better to just create and delete a new buffer in every loop? Wouldn't that be slower?

lpitonakova
Posts: 17
Joined: 22 Nov 2017, 12:32

### Re: Streaming video camera

Also, I have another question about releasing. The description of simxGetVisionSensorImage (http://www.coppeliarobotics.com/helpFil ... ensorImage)says that the data is automatically released.

When I try this:

Code: Select all

    simUChar* image = new simUChar{};
if (simxGetConnectionId(simulatorInterface->GetServerId()) != -1) {
if (simxGetVisionSensorImage(simulatorInterface->GetServerId(),remoteVisionSensor,remoteVisionSensorResolution,&image,0,simx_opmode_buffer) == 0) {
//-- todo: do something with the image
simxReleaseBuffer(image);
}
}

The program crashes with " malloc: *** error for object 0x1211fe026: pointer being freed was not allocated"
Am I doing this correctly?

lpitonakova
Posts: 17
Joined: 22 Nov 2017, 12:32

### Re: Streaming video camera

Hi again, after some digging, I don't think that the buffer is the problem. I went back to start and looked at your example scene headlessModeDebug.

Since in that scene, the rendering is over pretty quickly, as the robot falls off, I loaded a different scene through the script. That all works fine until I remove

Code: Select all

simLaunchExecutable(appPath..'/vrep','-h -gREMOTEAPISERVERSERVICE_19900_FALSE_TRUE',1)
From the "visualisation" script and instead run a v-rep instance from the command line manually, using the same command line arguments as above. When I do that, the freezing occurs again.

Is this basically some kind of a bug in V-REP? I cannot see any solution to this for a program that is supposed to connect to an already running V-REP instance.

coppelia