Created
October 16, 2014 00:59
-
-
Save 2bbb/c3ae1c605e813aaabb54 to your computer and use it in GitHub Desktop.
ofxTldTracker+ofxJpegGlitch
This file contains hidden or 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
| // | |
| // author: | |
| // TOMOTO Yusuke https://github.com/yusuketomoto | |
| // modify: | |
| // ISHII 2bit https://github.com/2bbb | |
| // | |
| // Dependencies: | |
| // ofxCV https://github.com/kylemcdonald/ofxCv | |
| // ofxTldTracker https://github.com/yusuketomoto/ofxTldTracker | |
| // ofxJpegGlitch https://github.com/2bbb/ofxJpegGlitch | |
| // | |
| #include "ofMain.h" | |
| #include "ofxTldTracker.h" | |
| #include "ofxJpegGlitch.h" | |
| class ofApp : public ofBaseApp | |
| { | |
| ofVideoGrabber video; | |
| ofxTldTracker tracker; | |
| ofxJpegGlitch jpeg; | |
| public: | |
| void setup() { | |
| ofSetFrameRate(60); | |
| ofSetVerticalSync(true); | |
| ofBackground(0); | |
| video.initGrabber(640, 480); | |
| tracker.setup(); | |
| jpeg.setup(400, 400, 400); | |
| } | |
| void update() { | |
| video.update(); | |
| if (video.isFrameNew()) { | |
| tracker.update(video); | |
| } | |
| } | |
| void draw() { | |
| video.draw(0, 0); | |
| ofRectangle predict = tracker.getBoundingBox(); | |
| if (predict.getArea() > 0) { | |
| ofFbo fbo; | |
| fbo.allocate(predict.width, predict.height); | |
| fbo.begin(); | |
| video.draw(-predict.x, -predict.y, video.getWidth(), video.getHeight()); | |
| fbo.end(); | |
| ofPixels pix; | |
| fbo.getTextureReference().readToPixels(pix); | |
| jpeg.setPixels(pix); | |
| jpeg.glitch(); | |
| jpeg.getImage().draw(predict); | |
| } | |
| else | |
| { | |
| tracker.draw(); | |
| } | |
| } | |
| void keyPressed(int key) { | |
| if (key == 'r') tracker.reset(); | |
| } | |
| void mousePressed(int x, int y, int button) { | |
| tracker.mousePressed(x, y); | |
| } | |
| void mouseDragged(int x, int y, int button) { | |
| tracker.mouseDragged(x, y); | |
| } | |
| void mouseReleased(int x, int y, int button) { | |
| tracker.mouseReleased(x, y); | |
| } | |
| }; | |
| //======================================================================== | |
| int main( ){ | |
| ofSetupOpenGL(640,480,OF_WINDOW); | |
| ofRunApp(new ofApp()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment