Created
August 17, 2013 14:30
-
-
Save madc/6257141 to your computer and use it in GitHub Desktop.
Import a picture from cam to ofImage when using a separate thread. (openFrameworks)
Example: http://github.com/wirbrennen/ofxDocuApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _THREADED_CAM | |
#define _THREADED_CAM | |
#include "ofMain.h" | |
class threadedCam : public ofThread{ | |
public: | |
ofVideoGrabber vidGrabber; | |
ofImage exportImage; | |
void start(){ | |
vidGrabber.initGrabber(1280, 720, false); | |
exportImage.setUseTexture(false); | |
startThread(true, false); | |
} | |
void stop(){ | |
stopThread(); | |
vidGrabber.close(); | |
} | |
void threadedFunction(){ | |
while( isThreadRunning() != 0 ){ | |
vidGrabber.update(); | |
if (vidGrabber.isFrameNew()){ | |
exportImage.setFromPixels(vidGrabber.getPixelsRef()); | |
// Do something, like saving the picture: | |
exportImage.saveImage(ofGetTimestampString() + ".tiff"); | |
} | |
} | |
} | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment