summaryrefslogtreecommitdiff
path: root/offsetProject/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2014-03-14 15:14:37 +0000
committerTim Redfern <tim@eclectronics.org>2014-03-14 15:14:37 +0000
commit2438e0a034d7ef50c8d7837ea415ca6a95a94fc0 (patch)
treea46dedd57b752163d0a0ca87dca657b3127ed2fd /offsetProject/src
parentbcf4c0ac5428a1c3f331d66cf0c4a301d1f7a45f (diff)
publish version
Diffstat (limited to 'offsetProject/src')
-rw-r--r--offsetProject/src/buttonChecker.cpp2
-rw-r--r--offsetProject/src/buttonChecker.h4
-rw-r--r--offsetProject/src/imageStore.h13
-rw-r--r--offsetProject/src/main.cpp2
-rw-r--r--offsetProject/src/ofApp.cpp24
-rw-r--r--offsetProject/src/ofApp.h2
6 files changed, 37 insertions, 10 deletions
diff --git a/offsetProject/src/buttonChecker.cpp b/offsetProject/src/buttonChecker.cpp
index b8170e8..efd08ab 100644
--- a/offsetProject/src/buttonChecker.cpp
+++ b/offsetProject/src/buttonChecker.cpp
@@ -1,6 +1,6 @@
#include "buttonChecker.h"
-long ofToLong(const string& intString) {
+long toLong(const string& intString) {
long x = 0;
istringstream cur(intString);
cur >> x;
diff --git a/offsetProject/src/buttonChecker.h b/offsetProject/src/buttonChecker.h
index 2de14cb..edcde15 100644
--- a/offsetProject/src/buttonChecker.h
+++ b/offsetProject/src/buttonChecker.h
@@ -4,7 +4,7 @@
#include "ofMain.h"
#include "ofURLFileLoader.h"
-long ofToLong(const string& intString);
+long toLong(const string& intString);
class buttonChecker : public ofThread{
@@ -54,7 +54,7 @@ class buttonChecker : public ofThread{
//cout<<"."<<std::flush;
- long result = ofToLong(ofLoadURL(url).data.getText());
+ long result = toLong(ofLoadURL(url).data.getText());
if (result>last){
last=result;
active=true;
diff --git a/offsetProject/src/imageStore.h b/offsetProject/src/imageStore.h
index 2f8ccbb..58ef560 100644
--- a/offsetProject/src/imageStore.h
+++ b/offsetProject/src/imageStore.h
@@ -123,11 +123,12 @@ class imageStore : public ofThread{
Matrix<float> query(test,1,3);
Matrix<int> indices(new int[1], query.rows, 1);
Matrix<float> dists(new float[1], query.rows, 1);
- index->knnSearch(query, indices, dists, 1,SearchParams(20));
+ index->knnSearch(query, indices, dists, 1,SearchParams(10));
im=*imageptrs[*indices[0]];
//int i=rand()%imageptrs.size();
//im=images[imageptrs[i]];
//cerr<<"returning image "<<i<<endl;
+ delete[] test;
unlock();
}
return im;
@@ -136,14 +137,18 @@ class imageStore : public ofThread{
ofImage& get_image(float* data){
ofImage& im=images.begin()->second;
if( lock() ){
+ int* it=new int[1];
+ float* ft=new float[1];
Matrix<float> query(data,1,FLANN_MATRIX_SIZE*FLANN_MATRIX_SIZE*3);
- Matrix<int> indices(new int[1], query.rows, 1);
- Matrix<float> dists(new float[1], query.rows, 1);
- index->knnSearch(query, indices, dists, 1,SearchParams(4));
+ Matrix<int> indices(it, query.rows, 1);
+ Matrix<float> dists(ft, query.rows, 1);
+ index->knnSearch(query, indices, dists, 1,SearchParams(10));
im=*imageptrs[*indices[0]];
//int i=rand()%imageptrs.size();
//im=images[imageptrs[i]];
//cerr<<"returning image "<<i<<endl;
+ delete[] it;
+ delete[] ft;
unlock();
}
return im;
diff --git a/offsetProject/src/main.cpp b/offsetProject/src/main.cpp
index fc6f65f..5785abd 100644
--- a/offsetProject/src/main.cpp
+++ b/offsetProject/src/main.cpp
@@ -1,6 +1,6 @@
#include "ofApp.h"
int main() {
- ofSetupOpenGL(1500,800, OF_WINDOW);
+ ofSetupOpenGL(1920,1080, OF_WINDOW);
ofRunApp(new ofApp());
}
diff --git a/offsetProject/src/ofApp.cpp b/offsetProject/src/ofApp.cpp
index 694c592..3d497bc 100644
--- a/offsetProject/src/ofApp.cpp
+++ b/offsetProject/src/ofApp.cpp
@@ -60,6 +60,8 @@ void ofApp::setup() {
screenleft.loadImage("screenleft.png");
screenright.loadImage("screenright.png");
+
+ button.start();
}
//--------------------------------------------------------------
@@ -70,12 +72,19 @@ void ofApp::update() {
//prepare buffers etc
//decide whether to use kinect, to keep kinect photo frozen, or to display from instagram
-
+ kinect.update();
if (store.new_instagram()){
mode=MODE_DRAWINSTAGRAM;
}
+ if (button.action()) {
+ ofImage snap;
+ snap.setFromPixels(kinect.getPixels(),kinect.width, kinect.height, OF_IMAGE_COLOR);
+ snap.saveImage("saved/"+ofGetTimestampString()+".png");
+ cout<<"SNAP!"<<endl; //save image now
+ }
+
store.update();
switch(mode){
@@ -83,7 +92,7 @@ void ofApp::update() {
case MODE_FROZEN:
break;
default:
- kinect.update();
+
// there is a new frame and we are connected
if(kinect.isFrameNew()) {
@@ -250,6 +259,17 @@ void ofApp::draw() {
break;
}
+ float ttime=ofGetElapsedTimef()-button.triggerTime;
+
+ int b=(1.0f-ttime)*255;
+
+ if (b>-1) {
+ ofEnableAlphaBlending();
+ ofSetColor(255,255,255,b);
+ ofRect(0,0,ofGetWidth(),ofGetHeight());
+ ofDisableAlphaBlending();
+ }
+
}
diff --git a/offsetProject/src/ofApp.h b/offsetProject/src/ofApp.h
index 04d636c..b9508a3 100644
--- a/offsetProject/src/ofApp.h
+++ b/offsetProject/src/ofApp.h
@@ -5,6 +5,7 @@
#include "ofxKinect.h"
#include "imageStore.h"
+#include "buttonChecker.h"
#define MODE_COLOURTILES 0
#define MODE_DEPTH 1
@@ -32,6 +33,7 @@ public:
void windowResized(int w, int h);
imageStore store;
+ buttonChecker button;
int mode,farThreshold,angle;