From 63a6970325463b3533edbf910f88750cb2d096f1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 11 Mar 2014 14:58:03 +0000 Subject: folder scanning and saving images --- json-instagram/src/exampleApp.cpp | 42 ------ offsetProject/Makefile | 2 +- offsetProject/config.make | 145 ++++++++++++++++++- offsetProject/src/ofApp.cpp | 298 +++++++------------------------------- offsetProject/src/ofApp.h | 2 +- 5 files changed, 201 insertions(+), 288 deletions(-) diff --git a/json-instagram/src/exampleApp.cpp b/json-instagram/src/exampleApp.cpp index c064261..75935a0 100644 --- a/json-instagram/src/exampleApp.cpp +++ b/json-instagram/src/exampleApp.cpp @@ -1,48 +1,6 @@ #include "exampleApp.h" -/* -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 -9% in use by ubuntu -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 - -when a new image comes in -load and create mip maps -save to - -*/ long ofToLong(const string& intString) { long x = 0; diff --git a/offsetProject/Makefile b/offsetProject/Makefile index 7a7fe8b..cda22b7 100644 --- a/offsetProject/Makefile +++ b/offsetProject/Makefile @@ -6,7 +6,7 @@ endif # make sure the the OF_ROOT location is defined ifndef OF_ROOT - OF_ROOT=../../.. + OF_ROOT=../../openFrameworks endif # call the project makefile! diff --git a/offsetProject/config.make b/offsetProject/config.make index 98bb09c..c9fd9dc 100644 --- a/offsetProject/config.make +++ b/offsetProject/config.make @@ -1 +1,144 @@ -OF_ROOT=../../openFrameworks +################################################################################ +# CONFIGURE PROJECT MAKEFILE (optional) +# This file is where we make project specific configurations. +################################################################################ + +################################################################################ +# OF ROOT +# The location of your root openFrameworks installation +# (default) PATH_OF_ROOT = ../../.. +################################################################################ +# PATH_OF_ROOT = ../../.. + +################################################################################ +# PROJECT ROOT +# The location of the project - a starting place for searching for files +# (default) PROJECT_ROOT = . (this directory) +# +################################################################################ +# PROJECT_ROOT = . + +################################################################################ +# PROJECT SPECIFIC CHECKS +# This is a project defined section to create internal makefile flags to +# conditionally enable or disable the addition of various features within +# this makefile. For instance, if you want to make changes based on whether +# GTK is installed, one might test that here and create a variable to check. +################################################################################ +# None + +################################################################################ +# PROJECT EXTERNAL SOURCE PATHS +# These are fully qualified paths that are not within the PROJECT_ROOT folder. +# Like source folders in the PROJECT_ROOT, these paths are subject to +# exlclusion via the PROJECT_EXLCUSIONS list. +# +# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_EXTERNAL_SOURCE_PATHS = + +################################################################################ +# PROJECT EXCLUSIONS +# These makefiles assume that all folders in your current project directory +# and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations +# to look for source code. The any folders or files that match any of the +# items in the PROJECT_EXCLUSIONS list below will be ignored. +# +# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete +# string unless teh user adds a wildcard (%) operator to match subdirectories. +# GNU make only allows one wildcard for matching. The second wildcard (%) is +# treated literally. +# +# (default) PROJECT_EXCLUSIONS = (blank) +# +# Will automatically exclude the following: +# +# $(PROJECT_ROOT)/bin% +# $(PROJECT_ROOT)/obj% +# $(PROJECT_ROOT)/%.xcodeproj +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_EXCLUSIONS = + +################################################################################ +# PROJECT LINKER FLAGS +# These flags will be sent to the linker when compiling the executable. +# +# (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs +# +# Note: Leave a leading space when adding list items with the += operator +# +# Currently, shared libraries that are needed are copied to the +# $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to +# add a runtime path to search for those shared libraries, since they aren't +# incorporated directly into the final executable application binary. +################################################################################ +# PROJECT_LDFLAGS=-Wl,-rpath=./libs + +PROJECT_LDFLAGS= -ljsoncpp + +################################################################################ +# PROJECT DEFINES +# Create a space-delimited list of DEFINES. The list will be converted into +# CFLAGS with the "-D" flag later in the makefile. +# +# (default) PROJECT_DEFINES = (blank) +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_DEFINES = + +################################################################################ +# PROJECT CFLAGS +# This is a list of fully qualified CFLAGS required when compiling for this +# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS +# defined in your platform specific core configuration files. These flags are +# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. +# +# (default) PROJECT_CFLAGS = (blank) +# +# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in +# your platform specific configuration file will be applied by default and +# further flags here may not be needed. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + PROJECT_CFLAGS = `pkg-config --cflags jsoncpp` + + +################################################################################ +# PROJECT OPTIMIZATION CFLAGS +# These are lists of CFLAGS that are target-specific. While any flags could +# be conditionally added, they are usually limited to optimization flags. +# These flags are added BEFORE the PROJECT_CFLAGS. +# +# PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. +# +# (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) +# +# PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. +# +# (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) +# +# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the +# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration +# file will be applied by default and further optimization flags here may not +# be needed. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_OPTIMIZATION_CFLAGS_RELEASE = +# PROJECT_OPTIMIZATION_CFLAGS_DEBUG = + +################################################################################ +# PROJECT COMPILERS +# Custom compilers can be set for CC and CXX +# (default) PROJECT_CXX = (blank) +# (default) PROJECT_CC = (blank) +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_CXX = +# PROJECT_CC = diff --git a/offsetProject/src/ofApp.cpp b/offsetProject/src/ofApp.cpp index 02875f2..00c7f57 100644 --- a/offsetProject/src/ofApp.cpp +++ b/offsetProject/src/ofApp.cpp @@ -1,71 +1,66 @@ #include "ofApp.h" +/* +so far so good, NOW -//-------------------------------------------------------------- -void ofApp::setup() { - ofSetLogLevel(OF_LOG_WARNING); - - // enable depth->video image calibration - kinect.setRegistration(true); - - kinect.init(); - //kinect.init(true); // shows infrared instead of RGB video image - //kinect.init(false, false); // disable video image (faster fps) - - kinect.open(); // opens first available kinect - //kinect.open(1); // open a kinect by id, starting with 0 (sorted by serial # lexicographically)) - //kinect.open("A00362A08602047A"); // open a kinect using it's unique serial # - - // print the intrinsic IR sensor values - if(kinect.isConnected()) { - ofLogNotice() << "sensor-emitter dist: " << kinect.getSensorEmitterDistance() << "cm"; - ofLogNotice() << "sensor-camera dist: " << kinect.getSensorCameraDistance() << "cm"; - ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() << "mm"; - ofLogNotice() << "zero plane dist: " << kinect.getZeroPlaneDistance() << "mm"; - } - - - colourImage.allocate(kinect.width, kinect.height); - depthImage.allocate(kinect.width, kinect.height); - - farThreshold = 70; - - ofSetFrameRate(60); - - // zero the tilt on startup - angle = 0; - kinect.setCameraTiltAngle(angle); +threading - //start with the largest size square - //get the depth, if below a certain size, subdivide and repeat +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 - //OR start at the smallest size, if adjacent squares are the same, work up +how exactly do we parse or mipmap the images +do we worry about memory - I guess not - //1 - create a pyramid of mip maps of depth - //2 - work upwards +identify the images - //a find layout of largest tiles - //b extend captured frame to this ratio - //c mip map this down into prepared containers +image save- reload system (? even necessary ?) +camera + button +transitions - int tiles_w=ceil((float)kinect.width/(MAX_TILE_SIZE*2))*2; - int tiles_h=ceil((float)kinect.height/(MAX_TILE_SIZE*2))*2; - extend_w=(tiles_w)*MAX_TILE_SIZE; - extend_h=(tiles_h)*MAX_TILE_SIZE; +should the loader own the images? +should the whole image bank be locked while loading? +alternatively each image could have a lock? - threadedImage - //get number of levels - levels=0; - for (int i=MIN_TILE_SIZE;i<=MAX_TILE_SIZE;i*=2) { - levels++; - } +or true mip map via drawsubsection? + +start with a max size say 64 - should be 16k inc mip maps + +graphics card has 2048MB +9% in use by ubuntu +117964 textures +I wonder is this faster with shared memory.. - colourTiles.resize(levels); - depthTiles.resize(levels); +load app +get list of images in defined folder +load them and create mip maps +store indexed by file stub - for (int i=MIN_TILE_SIZE,l=0;i<=MAX_TILE_SIZE;i*=2,l++) { - colourTiles[l].allocate(extend_w/i,extend_h/i); - depthTiles[l].allocate(extend_w/i,extend_h/i); - cerr<<"level "<0&&max(0,depthTiles[level].getPixels()[y*((int)depthTiles[level].getWidth())+x]-128)>level*levels_factor){ - for (int i=0;i<2;i++){ - for (int j=0;j<2;j++){ - checktile(level-1,x*2+i,y*2+j,size/2); - } - } - } - else { - ofSetColor(colourTiles[level].getPixels()[(y*((int)colourTiles[level].getWidth())+x)*3], - colourTiles[level].getPixels()[(y*((int)colourTiles[level].getWidth())+x)*3+1], - colourTiles[level].getPixels()[(y*((int)colourTiles[level].getWidth())+x)*3+2]); - ofRect(x*size,y*size,size,size); - } -} + //-------------------------------------------------------------- void ofApp::draw() { @@ -138,79 +85,7 @@ void ofApp::draw() { ofSetColor(255, 255, 255); - int pixelsize=ofGetWidth()/colourTiles[levels-1].getWidth(); - - - switch(mode){ - case MODE_COLOURTILES: - - //recursively draw pixels - - //int yoffset= - - for (int i=0;i': - 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 711dc0d..67e1b71 100644 --- a/offsetProject/src/ofApp.h +++ b/offsetProject/src/ofApp.h @@ -13,7 +13,7 @@ #define NUM_MODES 3 -#define STORE_SIZE 256 +#define IMAGE_STORE_SIZE 256 class ofApp : public ofBaseApp { -- cgit v1.2.3