Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
openFrameworks app for sending images to disk for processing, and reading text back from disk. Used for "NeuralTalk and Walk".
#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());
}

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

Deepak- commented Feb 15, 2016

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