From bb852cee91b52b71fccade7d4a1ef065eb0de2f0 Mon Sep 17 00:00:00 2001 From: Comment Date: Fri, 14 Mar 2014 00:51:24 +0000 Subject: nice --- offsetProject/config.make | 4 +- offsetProject/src/imageStore.h | 10 ++- offsetProject/src/ofApp.cpp | 164 +++++++++++++++++++++++------------------ offsetProject/src/ofApp.h | 4 + 4 files changed, 105 insertions(+), 77 deletions(-) (limited to 'offsetProject') diff --git a/offsetProject/config.make b/offsetProject/config.make index 6edaada..5729780 100644 --- a/offsetProject/config.make +++ b/offsetProject/config.make @@ -78,7 +78,7 @@ ################################################################################ # PROJECT_LDFLAGS=-Wl,-rpath=./libs -PROJECT_LDFLAGS= -ljsoncpp -lflann +PROJECT_LDFLAGS= -ljsoncpp ################################################################################ # PROJECT DEFINES @@ -106,7 +106,7 @@ PROJECT_LDFLAGS= -ljsoncpp -lflann # # Note: Leave a leading space when adding list items with the += operator ################################################################################ - PROJECT_CFLAGS = `pkg-config --cflags jsoncpp` + PROJECT_CFLAGS = `pkg-config --cflags jsoncpp` -pg ################################################################################ diff --git a/offsetProject/src/imageStore.h b/offsetProject/src/imageStore.h index a2bd39d..9cde96c 100644 --- a/offsetProject/src/imageStore.h +++ b/offsetProject/src/imageStore.h @@ -3,15 +3,17 @@ #define IMAGE_STORE_SIZE 256 #define MIN_TILE_SIZE 8 -#define MAX_TILE_SIZE 16 +#define MAX_TILE_SIZE 32 -#define FLANN_MATRIX_SIZE 3 +#define FLANN_MATRIX_SIZE 5 #include "ofMain.h" #include "ofxJSONElement.h" #include "ofxOpenCv.h" //#include +//~9fps@33% 32*3 + using namespace cvflann; long ofToLong(const string& intString); @@ -115,7 +117,7 @@ class imageStore : public ofThread{ Matrix query(test,1,3); Matrix indices(new int[1], query.rows, 1); Matrix dists(new float[1], query.rows, 1); - index->knnSearch(query, indices, dists, 1,SearchParams(10)); + index->knnSearch(query, indices, dists, 1,SearchParams(20)); im=*imageptrs[*indices[0]]; //int i=rand()%imageptrs.size(); //im=images[imageptrs[i]]; @@ -159,6 +161,8 @@ class imageStore : public ofThread{ } } + //void flann(const ofImage& _img){ + //-------------------------- void threadedFunction(){ diff --git a/offsetProject/src/ofApp.cpp b/offsetProject/src/ofApp.cpp index 51795f5..c5163f9 100644 --- a/offsetProject/src/ofApp.cpp +++ b/offsetProject/src/ofApp.cpp @@ -5,27 +5,9 @@ so far so good, NOW threading -parse response and identify new pictures -save pictures & metadata - rather than reloading each time? -local images format -do we need any metadata? I guess not other than to know the tag id -could save with the tag id as the name of file, simpler - -how exactly do we parse or mipmap the images -do we worry about memory - I guess not - -identify the images - -image save- reload system (? even necessary ?) camera + button transitions -should the loader own the images? -should the whole image bank be locked while loading? -alternatively each image could have a lock? - threadedImage - -or true mip map via drawsubsection? - start with a max size say 64 - should be 16k inc mip maps graphics card has 2048MB @@ -33,38 +15,29 @@ graphics card has 2048MB 117964 textures I wonder is this faster with shared memory.. -load app -get list of images in defined folder -load them and create mip maps -store indexed by file stub - -start thread -when a new image comes in -load and create mip maps - -how to store pictures -threaded loader works away in the background -when a new picture comes in +performance? -a data structure which is part of the threaded object -each image contains a mutex to enable the threaded object to be accessed -the instagram id is just used to match against incoming - there needs to be the pattern matching algorithm - -how to draw pictures -need to search the db for pictures of a certain colour +use opencv to convert to floats? its a quick one.. */ //-------------------------------------------------------------- void ofApp::setup() { ofSetLogLevel(OF_LOG_WARNING); - + ofSetFrameRate(60); - kinect.setRegistration(true); + kinect.setRegistration(true); kinect.init(); kinect.open(); - colourImage.allocate(kinect.width, kinect.height); - depthImage.allocate(kinect.width, kinect.height); + //colourImage.allocate(kinect.width, kinect.height); + //depthImage.allocate(kinect.width, kinect.height); + //floatImage.setNativeScale(0.0f,255.0f); + int h=ceil(ofGetHeight()/MAX_TILE_SIZE); + //int w=(h*4)/3; + //floatImage.allocate(w*FLANN_MATRIX_SIZE,h*FLANN_MATRIX_SIZE); + floatImage=new float[h*FLANN_MATRIX_SIZE*h*FLANN_MATRIX_SIZE*3]; + //cerr<<"floatImage: "<': case '.': farThreshold ++; if (farThreshold > 255) farThreshold = 255; break; - + case '<': case ',': farThreshold --; if (farThreshold < 0) farThreshold = 0; break; - - + + case 'w': kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite()); break; - + case 'o': kinect.setCameraTiltAngle(angle); // go back to prev tilt kinect.open(); break; - + case 'c': kinect.setCameraTiltAngle(0); // zero the tilt kinect.close(); break; - + case '1': kinect.setLed(ofxKinect::LED_GREEN); break; - + case '2': kinect.setLed(ofxKinect::LED_YELLOW); break; - + case '3': kinect.setLed(ofxKinect::LED_RED); break; - + case '4': kinect.setLed(ofxKinect::LED_BLINK_GREEN); break; - + case '5': kinect.setLed(ofxKinect::LED_BLINK_YELLOW_RED); break; - + case '0': kinect.setLed(ofxKinect::LED_OFF); break; - + case OF_KEY_UP: angle++; if(angle>30) angle=30; kinect.setCameraTiltAngle(angle); break; - + case OF_KEY_DOWN: angle--; if(angle<-30) angle=-30; kinect.setCameraTiltAngle(angle); break; - + case OF_KEY_LEFT: mode--; if (mode<0) mode=NUM_MODES-1; diff --git a/offsetProject/src/ofApp.h b/offsetProject/src/ofApp.h index f3aa3be..e31c5b1 100644 --- a/offsetProject/src/ofApp.h +++ b/offsetProject/src/ofApp.h @@ -37,7 +37,11 @@ public: ofxCvGrayscaleImage depthImage,depthImage2; ofxKinect kinect; + //ofxCvFloatImage floatImage; + float* floatImage; + float* tiledata; + float* frametiledata; bool fullscreen; }; -- cgit v1.2.3