Check if camera is setup properly


i am looking for a way to check if a webcam is properly setup.

I am reading the result of the boolean returned by ofVideoGrabber.setup() or testing with ofVideoGrabber.isInitialized() but it always returns true no matter is the camera exists or not.

I am using a macbook pro with integrated camera on oF0.9.8. I have only one device (the integrated one).

testing is always returning true no matter which device i initialize. With :




using :

bool bValidDevice = cam.setup(camWidth, camHeight, true);


bool bInit = cam.isInitialized();

both always return true while device 0 is the integrated webcam and device 1 doesn’t exist

Any idea ?

Hi! Would .listDevices() help?

    auto devs = cam.listDevices();
    for(auto & d : devs) {
        std::cout << << ": " << d.deviceName << std::endl;
    // output:
    // 0: FJ Camera: FJ Camera
    // 1: Microsoft® LifeCam HD-3000: Mi

That only answers your question in part. This way you can avoid trying with cameras that don’t exist, but it would not tell you if it really worked. Odd that you get true for .isInitialized()


thanks for the feedback.

Yes i ended up using listDevices() to only process if a camera is present. But i am not able to make sure the camera is setup correctly.

Somebody knows why isInitialized() or setup() always return true ?

thanks a lot

In Android it seems to work: it returns false before setting up. Maybe a bug in Mac OF?

thanks for the heads up.

i tried it again. It seems even if specifying a device, the app will use the first available device. For instance on my macbook the is only the integrated cam.

Whether i choose device 0, 1, 2… etc


the integrated cam lights up and i get its image displayed