Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

ofVideoGrabber::initGrabber()'s arbitrary behaviour with multiple cameras

$
0
0

@hrodgair wrote:

Hi

I'm trying to setup a multi-cam app on a Mac. For now, I have two cameras: the built-in iSight; and a Logitech C525 USB cam. I've been struggling for both cameras to draw simultaneously. I just couldn't get both to draw at the same time. Until I realized that it depended on the parameters passed on to ofVideoGrabber's initGrabber(...).

I've tried different settings with these results:

cam->initGrabber(320, 240); // both cameras draw OK
cam->initGrabber(321, 241); // just one camera will draw
cam->initGrabber(319, 239); // both cameras draw OK
cam->initGrabber(320, 480); // both cameras draw [obviously] distorted
cam->initGrabber(640, 240); // both cameras draw [obviously] distorted
cam->initGrabber(640, 480); // just one camera will draw
cam->initGrabber(1024, 480); // just one camera will draw
cam->initGrabber(ofGetWidth(), ofGetHeight()); // just one camera will draw

Here's the [simplified] code.

ofApp.h

class ofApp : public ofBaseApp{
   // ...
    vector<shared_ptr<ofVideoGrabber> > cams;
}

ofApp.cpp

void ofApp::setup() {

    ofVideoGrabber vidGrabber;
    vector<ofVideoDevice> devices = vidGrabber.listDevices();

    for(int i = 0; i < devices.size(); i++) {
        shared_ptr<ofVideoGrabber> cam(new ofVideoGrabber());
        cam->setDeviceID(i);
        cam->initGrabber(ofGetWidth(), ofGetHeight()); // or whatever
        cams.push_back(cam);
    }
}

//--------------------------------------------------------------
void ofApp::update(){
    for (int i=0; i < cams.size(); i++) {
        cams[i]->update();
    }
}

//--------------------------------------------------------------
void ofApp::draw(){
    for (int i=0; i < cams.size(); i++) {
        cams[i]->draw(320*i, 0);
    }
}

Any ideas on what is going on? I don't like the idea of hard-coding camera sizes, and even if there wasn't any other solution, 320x240 is way too small for what I'm willing to accomplish.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles