Created
November 23, 2015 15:30
-
-
Save kylemcdonald/b02edbc33942a85856c8 to your computer and use it in GitHub Desktop.
openFrameworks app for sending images to disk for processing, and reading text back from disk. Used for "NeuralTalk and Walk".
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
#include "ofMain.h" | |
#include "ofxTiming.h" | |
class ofApp : public ofBaseApp { | |
public: | |
ofVideoGrabber grabber; | |
DelayTimer delay; | |
ofTrueTypeFont font; | |
string description; | |
void setup(){ | |
ofBackground(0); | |
ofSetFrameRate(60); | |
grabber.setup(1280, 720); | |
delay.setFramerate(4); | |
font.load("Avenir Light", 64); | |
} | |
void update(){ | |
grabber.update(); | |
if(delay.tick()) { | |
ofPixels frame = grabber.getPixels(); | |
frame.resize(640, 360); | |
ofSaveImage(frame, "feed.jpg"); | |
description = ofBufferFromFile("../description.txt").getText(); | |
} | |
} | |
void draw(){ | |
ofPushMatrix(); | |
ofTranslate(ofGetWidth() / 2, 0); | |
float scale = ofGetHeight() / grabber.getHeight(); | |
ofScale(scale, scale); | |
ofTranslate(-grabber.getWidth() / 2, 0); | |
grabber.draw(0, 0); | |
ofPopMatrix(); | |
ofPushStyle(); | |
float padding = 16; | |
ofTranslate(padding, 2 * padding + 64); | |
ofSetColor(0, 128); | |
ofRectangle box = font.getStringBoundingBox(description, 0, 0); | |
box.width += padding * 2; | |
box.height += padding * 2; | |
ofDrawRectangle(box); | |
ofSetColor(255); | |
font.drawString(description, padding, padding); | |
ofPopStyle(); | |
} | |
void keyPressed(int key){ | |
if(key == 'f') { | |
ofToggleFullscreen(); | |
} | |
} | |
}; | |
int main( ){ | |
ofSetupOpenGL(1280,720,OF_WINDOW); | |
ofRunApp(new ofApp()); | |
} |
Where do I put this script in order to run it with neural talk?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi. how did you manage to print the result on description.txt and to loop the process / eval.lua? I'm still learning to code and I wonder how you did that. thanks