// in declaration
ofVideoGrabber vidGrabber;
// in setup
vidGrabber.setVerbose(true);
vidGrabber.initGrabber(320,240);
vidGrabber.listDevices();
If creating an array of grayImages for example, I would…
// declaration
ofCvGrayscaleImage * myImage;
// setup
myImage = new ofCvGrayscaleImage[2];
for(int i =0; i <2; i++){
myImage[i].allocate(320,240);
}
But if you do the same with video players, you get this error : error C2679: binary ‘=’ : no operator found which takes a right-hand operand of type 'ofVideoPlayer *'
However, if I do this…
// in .h
ofVideoPlayer ** videoFile;
// in .cpp setup
videoFile = new ofVideoPlayer[2];
for(int i =0; i < 2; i++){
videoFile[i] = new ofVideoPlayer();
videoFile[i]->loadMovie("test.mov");
}
This works fine. Could you perhaps explain why?
However, when I try this with the video grabber, it builds but the error output is: choosing 15663656
error locating a video device
please check your software with amcap or other software
Now I only have one device, but in theory this should work, as here is my code
// .h
ofVideoGrabber ** vidGrabber;
// .cpp
vidGrabber = new ofVideoGrabber*[2];
for(int i =0; i < 1; i++){
vidGrabber[i]->setVerbose(true);
vidGrabber[i]->initGrabber(320,240);
vidGrabber[i]->listDevices();
}
Sorry I forgot to include the image declare in my post, but it is in my code
ofCvGrayscaleImage * myImage;
Using * doesn’t seem to work with video player or video grabber, but ** works with video player, as explained above. I had already done what you are suggesting
someone with more experience with c++ can explain this far better than me, but I think that should work
Yep, thats why I posted it in the advance section.
If I get this right you have no problem compiling your code but you do get a runtime error. According to the error it seams like you have some trouble locating your input device/devices. If you only have one input device try
videoFile = new ofVideoPlayer[1];
and see if that works. I’m guessing you’re trying to locate a device that doesn’t exists.
Thanks Henrik, this problem is now fixed. As you say, if you create a videoGrabber instance, that uses up the device, so if you start another it will say device not available. Sorted.