From bcf4c0ac5428a1c3f331d66cf0c4a301d1f7a45f Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 14 Mar 2014 14:07:28 +0000 Subject: nearly ready --- offsetProject/bin/data/screenleft.png | Bin 0 -> 17594 bytes offsetProject/bin/data/screenright.png | Bin 0 -> 9734 bytes offsetProject/src/buttonChecker.cpp | 8 ++ offsetProject/src/buttonChecker.h | 72 ++++++++++++++ offsetProject/src/imageStore.h | 87 ++++++++++++++++- offsetProject/src/ofApp.cpp | 168 ++++++++++++++++++++------------- offsetProject/src/ofApp.h | 6 ++ 7 files changed, 274 insertions(+), 67 deletions(-) create mode 100644 offsetProject/bin/data/screenleft.png create mode 100644 offsetProject/bin/data/screenright.png create mode 100644 offsetProject/src/buttonChecker.cpp create mode 100644 offsetProject/src/buttonChecker.h (limited to 'offsetProject') diff --git a/offsetProject/bin/data/screenleft.png b/offsetProject/bin/data/screenleft.png new file mode 100644 index 0000000..eca31d1 Binary files /dev/null and b/offsetProject/bin/data/screenleft.png differ diff --git a/offsetProject/bin/data/screenright.png b/offsetProject/bin/data/screenright.png new file mode 100644 index 0000000..6fe6bad Binary files /dev/null and b/offsetProject/bin/data/screenright.png differ diff --git a/offsetProject/src/buttonChecker.cpp b/offsetProject/src/buttonChecker.cpp new file mode 100644 index 0000000..b8170e8 --- /dev/null +++ b/offsetProject/src/buttonChecker.cpp @@ -0,0 +1,8 @@ +#include "buttonChecker.h" + +long ofToLong(const string& intString) { + long x = 0; + istringstream cur(intString); + cur >> x; + return x; +} \ No newline at end of file diff --git a/offsetProject/src/buttonChecker.h b/offsetProject/src/buttonChecker.h new file mode 100644 index 0000000..2de14cb --- /dev/null +++ b/offsetProject/src/buttonChecker.h @@ -0,0 +1,72 @@ +#ifndef _BUTTON_CHECK +#define _BUTTON_CHECK + +#include "ofMain.h" +#include "ofURLFileLoader.h" + +long ofToLong(const string& intString); + +class buttonChecker : public ofThread{ + + public: + + float interval; //time between refreshes in seconds + std::string url; + long last; + float triggerTime; + bool active; + + buttonChecker(){ + url = "http://tycleeson.com/trigger.php"; + interval=0.05; + last=0; + triggerTime=0.0f; + active=false; + } + + void set_interval(float _interval){ + interval=_interval; + } + + void start(){ + startThread(true, false); // blocking, verbose + } + + void stop(){ + stopThread(); + } + + bool action(){ + if(active){ + active=false; + return true; + } + return false; + } + + + //-------------------------- + void threadedFunction(){ + + cout << "Api: " << url<last){ + last=result; + active=true; + triggerTime=ofGetElapsedTimef(); + } + + + ofSleepMillis(interval * 1000); + } + } + + +}; + +#endif \ No newline at end of file diff --git a/offsetProject/src/imageStore.h b/offsetProject/src/imageStore.h index 9cde96c..2f8ccbb 100644 --- a/offsetProject/src/imageStore.h +++ b/offsetProject/src/imageStore.h @@ -7,6 +7,9 @@ #define FLANN_MATRIX_SIZE 5 +#define INSTAGRAM_DISPLAY_TIME 5 +#define IMAGE_FREEZE_TIME 5 + #include "ofMain.h" #include "ofxJSONElement.h" #include "ofxOpenCv.h" @@ -29,6 +32,9 @@ class imageStore : public ofThread{ std::map images; vector imageptrs; deque to_update; + bool newinstagram; + ofImage instagram_image; + float newinstagramtime; //Matrix dataset; doesn't need to be retained? @@ -56,7 +62,7 @@ class imageStore : public ofThread{ img.update(); images["000000"]=img; //colours["000000"]=ofColor(0,0,0); - + newinstagram=false; } ~imageStore(){ delete index; @@ -161,6 +167,46 @@ class imageStore : public ofThread{ } } + bool new_instagram(){ + if (newinstagram){ + if( lock() ){ + loadtexture(instagram_image); + newinstagram=false; + newinstagramtime=ofGetElapsedTimef(); + unlock(); + return true; + } + } + return false; + } + + bool drawinstagram(int x,int y,int w,int h){ + if( lock() ){ + instagram_image.draw(x,y,w,h); + unlock(); + } + if (ofGetElapsedTimef()-newinstagramtime>INSTAGRAM_DISPLAY_TIME) return false; + return true; + } + + void instagram_floats(float* floatImage){ + if( lock() ){ + + int size=ceil(ofGetHeight()/MAX_TILE_SIZE)*FLANN_MATRIX_SIZE; + ofImage imm=instagram_image; + imm.resize(size,size); + uint8_t* cptr=imm.getPixels(); + for (int i=0;i dataset(&data[0],data.size()/(3*FLANN_MATRIX_SIZE*FLANN_MATRIX_SIZE),3*FLANN_MATRIX_SIZE*FLANN_MATRIX_SIZE); index= new Index >(dataset, KDTreeIndexParams(4)); @@ -205,7 +256,7 @@ class imageStore : public ofThread{ while( isThreadRunning() != 0 ){ - /* + cout<<"."< dataset(&data[0],data.size()/(3*FLANN_MATRIX_SIZE*FLANN_MATRIX_SIZE),3*FLANN_MATRIX_SIZE*FLANN_MATRIX_SIZE); + index= new Index >(dataset, KDTreeIndexParams(4)); + index->buildIndex(); + cout<<"rebuilt flann index of "<IMAGE_FREEZE_TIME) mode=MODE_COLOURTILES; case MODE_COLOURTILES: //store.draw(); xstart=(ofGetWidth()/2)-((depthImage.getHeight()/2)*MAX_TILE_SIZE); diff --git a/offsetProject/src/ofApp.h b/offsetProject/src/ofApp.h index e31c5b1..04d636c 100644 --- a/offsetProject/src/ofApp.h +++ b/offsetProject/src/ofApp.h @@ -9,6 +9,8 @@ #define MODE_COLOURTILES 0 #define MODE_DEPTH 1 #define MODE_COMPONENTS 2 +#define MODE_DRAWINSTAGRAM 3 +#define MODE_FROZEN 4 #define NUM_MODES 3 @@ -43,5 +45,9 @@ public: float* tiledata; float* frametiledata; + ofImage screenleft,screenright; + + float frozentime; + bool fullscreen; }; -- cgit v1.2.3