Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FaceSubstitution: added dirlist for linux (drag&drop doesn't work)

  • Loading branch information...
commit bae6d6cf382e34ba310bb40d851e794418a34147 1 parent 2a7c21b
@arturoc authored
Showing with 38 additions and 3 deletions.
  1. +32 −3 FaceSubstitution/src/testApp.cpp
  2. +6 −0 FaceSubstitution/src/testApp.h
View
35 FaceSubstitution/src/testApp.cpp
@@ -3,7 +3,9 @@
using namespace ofxCv;
void testApp::setup() {
+#ifdef TARGET_OSX
ofSetDataPathRoot("../data/");
+#endif
ofSetVerticalSync(true);
cloneReady = false;
cam.initGrabber(640, 480);
@@ -17,6 +19,14 @@ void testApp::setup() {
srcTracker.setup();
srcTracker.setIterations(25);
srcTracker.setAttempts(4);
+
+ faces.allowExt("jpg");
+ faces.allowExt("png");
+ faces.listDir("faces");
+ currentFace = 0;
+ if(faces.size()!=0){
+ loadFace(faces.getPath(currentFace));
+ }
}
void testApp::update() {
@@ -67,10 +77,29 @@ void testApp::draw() {
}
}
-void testApp::dragEvent(ofDragInfo dragInfo) {
- src.loadImage(dragInfo.files[0]);
+void testApp::loadFace(string face){
+ src.loadImage(face);
if(src.getWidth() > 0) {
srcTracker.update(toCv(src));
srcPoints = srcTracker.getImagePoints();
}
-}
+}
+
+void testApp::dragEvent(ofDragInfo dragInfo) {
+ loadFace(dragInfo.files[0]);
+}
+
+void testApp::keyPressed(int key){
+ switch(key){
+ case OF_KEY_UP:
+ currentFace++;
+ break;
+ case OF_KEY_DOWN:
+ currentFace--;
+ break;
+ }
+ currentFace = ofClamp(currentFace,0,faces.size());
+ if(faces.size()!=0){
+ loadFace(faces.getPath(currentFace));
+ }
+}
View
6 FaceSubstitution/src/testApp.h
@@ -12,7 +12,10 @@ class testApp : public ofBaseApp {
void update();
void draw();
void dragEvent(ofDragInfo dragInfo);
+ void loadFace(string face);
+ void keyPressed(int key);
+
ofxFaceTrackerThreaded camTracker;
ofVideoGrabber cam;
@@ -23,4 +26,7 @@ class testApp : public ofBaseApp {
bool cloneReady;
Clone clone;
ofFbo srcFbo, maskFbo;
+
+ ofDirectory faces;
+ int currentFace;
};
Please sign in to comment.
Something went wrong with that request. Please try again.