Hello, i need to be able to change the camera input (select which connected camera i want to use ) while my app is working.
For this I been using videoIn.setDeviceID(0); but the problem is that this command only works in setup(), so i just select which camera i want to use just one time when i start my program.
I been trying to use videoIn.setDeviceID(0); withing the draw() function so i would be able to change it dynamically but it doesnt work, i get this message:
OF: OF_LOG_WARNING: call setDeviceID before grabber is started!
Do anybody have an idea why is this and how to make it work?
thanks
my draw function that is suppose to change between cameras look like this:
void testApp::changeCamera(int num){
videoIn.close();
videoIn.setDeviceID(num);
videoIn.initGrabber(320,240); // change this to your settings
}
Why are you trying to do it within the draw function? That should be for drawing only. You don’t want to be trying to open and close the camera capture in a loop like update/draw, just call changeCamera(2) either on key up or if a button is clicked etc.
The results is that in OSX, the new grabber initialized after closing the first one it’s always called with deviceID = 0 . I’ve been debugging and seems like
Initially (the first time) it is called with the object “grabber” being an OSXVideoGrabber *. But once you hit ‘x’ and you close the initial grabber, when you try to init the grabber again and you reach this line of code grabber is “nil” !!
So the call [grabber setDevice:deviceID]; Has no effect and basically you can’t connect to another grabber that has a different deviceID …
What am I understanding or doing wrong ?
As far as OF documentation always talks about: