Skip to content

Instantly share code, notes, and snippets.

@icq4ever
Last active March 30, 2016 20:58
Show Gist options
  • Select an option

  • Save icq4ever/0794d7f263c85ab4ece22ff5e38c544c to your computer and use it in GitHub Desktop.

Select an option

Save icq4ever/0794d7f263c85ab4ece22ff5e38c544c to your computer and use it in GitHub Desktop.
void ofApp::setup() {
camWidth = 1280;
camHeight = 800;
cam.initGrabber(camWidth, camHeight);
tracker.setup();
camImg.allocate(camWidth, camHeight, OF_IMAGE_COLOR); // ofImage camImg - full size
copiedImg.allocate(camWidth/2, camHeight/2, OF_IMAGE_COLOR); // ofImage copiedImg - half size
fbo.allocate(camWidth/2, camHeight/2); // ofFbo fbo - half size
}
void ofApp::update() {
ofSetWindowTitle(ofToString(ofGetFrameRate()));
cam.update();
if(cam.isFrameNew()) {
camImg = cam.getPixels(); // dump cam -> camImg
// fill FBO
fbo.begin();
cam.draw(0, 0, camWidth/2, camHeight/2); // draw half size
fbo.end();
fbo.readToPixels(pix);
copiedImg.setFromPixels(pix);
copiedImg.update(); // need to this ??
// tracker.update(toCv(cam)); // tracking with ofVideoGrabber.. work.
tracker.update(toCv(camImg)); // tracking with ofImage.. work.
// tracker.update(toCv(copiedImg)); // OpenCV Error: Assertion failed (ssize.area() > 0) in resize,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment