Skip to content

Commit

Permalink
changes to make it work with newest ofxPlaymodes
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoc committed Oct 8, 2012
1 parent a3469aa commit e166300
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
3 changes: 2 additions & 1 deletion FaceSubstitution/addons.make
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ ofxGui
ofxXmlSettings
ofxPlaymodes
ofxOsc
ofxV4L2Settings
ofxV4L2Settings
ofxGstV4L2Sink
2 changes: 1 addition & 1 deletion FaceSubstitution/config.make
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ USER_LDFLAGS = -fopenmp
# use this to add system libraries for example:
# USER_LIBS = -lpango

USER_LIBS = -lv4l2 -ltbb
USER_LIBS = -lv4l2


# change this to add different compiler optimizations to your project
Expand Down
17 changes: 6 additions & 11 deletions FaceSubstitution/src/FaceBlinkRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using namespace ofxPm;
string FaceBlinkRecorder::LOG_NAME = "FaceBlinkRecorder";

FaceBlinkRecorder::FaceBlinkRecorder() {
vframe = NULL;

}

Expand Down Expand Up @@ -73,9 +72,8 @@ void FaceBlinkRecorder::update(ofPixels & frame){


if(recording && mutex.tryLock()){
if(vframe) vframe->release();
vframe = VideoFrame::newVideoFrame(frame);
newFrameEvent.notify(this,*vframe);
newFrameEvent.notify(this,vframe);
mutex.unlock();
}
}
Expand All @@ -88,19 +86,16 @@ void FaceBlinkRecorder::threadedFunction(){
int initFrame = int(buffer.size())-framesToSave;
if(initFrame>=0){
ofLogVerbose(LOG_NAME) << "start recording" << framesToSave << "frames at " << fps*1.2 << "fps";
recorder.setup("recordings/" + ofGetTimestampString()+".mp4",vframe->getWidth(),vframe->getHeight(),fps*1.2,false);
recorder.setup("recordings/" + ofGetTimestampString()+".mp4",vframe.getWidth(),vframe.getHeight(),fps*1.2,false);
for(int i=initFrame;i<(int)buffer.size();i++){
VideoFrame * frame = buffer.getVideoFrame(i);
recorder.addFrame(frame->getPixelsRef());
frame->release();
VideoFrame frame = buffer.getVideoFrame(i);
recorder.addFrame(frame.getPixelsRef());
}
recorder.encodeVideo();
}else{
ofLogVerbose(LOG_NAME) << "eyes clsed to sson only" << framesToSave << "frames at " << fps << "fps, dropping video";
}
buffer.clear();
vframe->release();
vframe = NULL;
encoding = false;
}
}
Expand All @@ -117,11 +112,11 @@ void FaceBlinkRecorder::setEyesClosed(bool closed){
eyesClosed = closed;
}

VideoFrame * FaceBlinkRecorder::getNextVideoFrame(){
VideoFrame FaceBlinkRecorder::getNextVideoFrame(){
return vframe;
}

int FaceBlinkRecorder::getFps(){
float FaceBlinkRecorder::getFps(){
return fps;
}

Expand Down
6 changes: 3 additions & 3 deletions FaceSubstitution/src/FaceBlinkRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class FaceBlinkRecorder: public ofThread, public ofxPm::VideoSource {

void setEyesClosed(bool closed);

ofxPm::VideoFrame * getNextVideoFrame();
int getFps();
ofxPm::VideoFrame getNextVideoFrame();
float getFps();

static string LOG_NAME;

Expand All @@ -53,7 +53,7 @@ class FaceBlinkRecorder: public ofThread, public ofxPm::VideoSource {
bool recording;
bool eyesClosed;
ofxPm::VideoBuffer buffer;
ofxPm::VideoFrame * vframe;
ofxPm::VideoFrame vframe;
bool encoding;

float oneSec;
Expand Down

0 comments on commit e166300

Please sign in to comment.