diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-06-17 15:32:14 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-06-17 15:32:14 +0100 |
| commit | 2395f29308fb424eaf9b9ebb08022568a117b0f0 (patch) | |
| tree | ca81402f792a1118b027ae0ad415e73659ff998b /05_pointcloud | |
| parent | 51df1cfbacd02cd362c82141a161f2fe859b8431 (diff) | |
back to user pointclouds
Diffstat (limited to '05_pointcloud')
| -rwxr-xr-x | 05_pointcloud/Makefile | 2 | ||||
| -rw-r--r-- | 05_pointcloud/Makfile | 244 | ||||
| -rw-r--r-- | 05_pointcloud/addons.make | 5 | ||||
| -rwxr-xr-x | 05_pointcloud/config.mak | 56 | ||||
| -rwxr-xr-x | 05_pointcloud/config.make | 58 | ||||
| -rw-r--r-- | 05_pointcloud/src/main.cpp | 17 | ||||
| -rw-r--r-- | 05_pointcloud/src/testApp.cpp | 281 | ||||
| -rw-r--r-- | 05_pointcloud/src/testApp.h | 56 |
8 files changed, 719 insertions, 0 deletions
diff --git a/05_pointcloud/Makefile b/05_pointcloud/Makefile new file mode 100755 index 0000000..2d83a77 --- /dev/null +++ b/05_pointcloud/Makefile @@ -0,0 +1,2 @@ +include config.make +include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/Makefile.examples diff --git a/05_pointcloud/Makfile b/05_pointcloud/Makfile new file mode 100644 index 0000000..0d8b4a1 --- /dev/null +++ b/05_pointcloud/Makfile @@ -0,0 +1,244 @@ +# openFrameworks OS X makefile +# +# make help : shows this message +# make Debug: makes the application with debug symbols +# make Release: makes the app with optimizations +# make: the same as make Release +# make CleanDebug: cleans the Debug target +# make CleanRelease: cleans the Release target +# make clean: cleans everything +# +# +# this should work with any OF app, just copy any example +# change the name of the folder and it should compile +# only .cpp support, don't use .c files +# it will look for files in any folder inside the application +# folder except that in the EXCLUDE_FROM_SOURCE variable +# it doesn't autodetect include paths yet +# add the include paths in the USER_CFLAGS variable +# using the gcc syntax: -Ipath +# +# to add addons to your application, edit the addons.make file +# in this directory and add the names of the addons you want to +# include +# +# edit the following vars to customize the makefile + +include config.mak +ARCH = i386 + +COMPILER_OPTIMIZATION = $(USER_COMPILER_OPTIMIZATION) + +EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" + +# you shouldn't modify anything below this line +SHELL = /bin/sh +CXX = g++ +LIBSPATH=osx + +NODEPS = clean +SED_EXCLUDE_FROM_SRC = $(shell echo $(EXCLUDE_FROM_SOURCE) | sed s/\,/\\\\\|/g) +SOURCE_DIRS = src +#$(shell find . -maxdepth 1 -mindepth 1 -type d | grep -v $(SED_EXCLUDE_FROM_SRC) | sed s/.\\///) +SOURCES = $(shell find $(SOURCE_DIRS) -name "*.cpp" -or -name "*.c") +OBJFILES = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES))) +APPNAME = $(shell basename `pwd`) +CORE_INCLUDES = $(shell find $(OF_ROOT)/libs/openFrameworks/ -type d) +CORE_INCLUDE_FLAGS = $(addprefix -I,$(CORE_INCLUDES)) +INCLUDES = $(shell find $(OF_ROOT)/libs/*/include -type d | grep -v glu | grep -v quicktime | grep -v poco) +INCLUDES_FLAGS = $(addprefix -I,$(INCLUDES)) +INCLUDES_FLAGS += -I$(OF_ROOT)/libs/poco/include +INCLUDES_FLAGS += -I$(OF_ROOT)/libs/glu/include +#INCLUDES_FLAGS += -I$(OF_ROOT)/libs/quicktime/include + +LIB_STATIC = $(shell ls $(OF_ROOT)/libs/*/lib/$(LIBSPATH)/*.a | grep -v openFrameworksCompiled | grep -v poco) +LIB_STATIC += $(OF_ROOT)/libs/fmodex/lib/osx/libfmodex.dylib +LIB_SHARED = $(shell ls $(OF_ROOT)/libs/*/lib/$(LIBSPATH)/*.so | grep -v openFrameworksCompiled | grep -v poco) +LIB_STATIC += $(OF_ROOT)/libs/poco/lib/$(LIBSPATH)/PocoNet.a $(OF_ROOT)/libs/poco/lib/$(LIBSPATH)/PocoXML.a $(OF_ROOT)/libs/poco/lib/$(LIBSPATH)/PocoUtil.a $(OF_ROOT)/libs/poco/lib/$(LIBSPATH)/PocoFoundation.a +LIB_PATHS_FLAGS = $(shell ls -d $(OF_ROOT)/libs/*/lib/$(LIBSPATH) | sed "s/\(\.*\)/-L\1/") + +CFLAGS += -Wall -fexceptions +CFLAGS += -I. +CFLAGS += $(INCLUDES_FLAGS) +CFLAGS += $(CORE_INCLUDE_FLAGS) +CFLAGS += -x c++ -arch $(ARCH) -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -Os -fasm-blocks -Wno-deprecated-declarations -Wno-invalid-offsetof -gdwarf-2 -msse3 -mssse3 + +LIBS += $(LIB_SHARED) +LIBS += $(LIB_STATIC) + +LDFLAGS = $(LIB_PATHS_FLAGS) -Wl +LIBS += -F$(OF_ROOT)/libs/glut/lib/osx -framework AppKit -framework Cocoa -framework IOKit -framework AGL -framework AudioToolbox -framework Carbon -framework CoreAudio -CoreFoundation -framework CoreServices -framework GLUT -framework OpenGL -framework Quicktime + +#Targets +ifeq ($(findstring Debug,$(MAKECMDGOALS)),Debug) + TARGET_CFLAGS = -g + TARGET_LIBS = $(OF_ROOT)/libs/openFrameworksCompiled/lib/osx/openFrameworksDebug.a + TARGET_NAME = Debug +endif + +ifeq ($(findstring Release,$(MAKECMDGOALS)),Release) + TARGET_CFLAGS = $(COMPILER_OPTIMIZATION) + TARGET_LIBS = $(OF_ROOT)/libs/openFrameworksCompiled/lib/osx/openFrameworks.a + TARGET_NAME = Release +endif + +ifeq ($(findstring Debug,$(MAKECMDGOALS)),Debug) + BIN_NAME = $(APPNAME)_debug + TARGET = bin/$(BIN_NAME) +endif + +ifeq ($(findstring Release,$(MAKECMDGOALS)),Release) + BIN_NAME = $(APPNAME) + TARGET = bin/$(BIN_NAME) +endif + +ifeq ($(findstring Release,$(MAKECMDGOALS)),clang) + CXX = clang +endif + +ifeq ($(MAKECMDGOALS),) + TARGET_NAME = Release + BIN_NAME = $(APPNAME) + TARGET = bin/$(BIN_NAME) + TARGET_LIBS = $(OF_ROOT)/libs/openFrameworksCompiled/lib/osx/openFrameworks.a +endif + +ifeq ($(MAKECMDGOALS),clean) + TARGET = bin/$(APPNAME)_debug bin/$(APPNAME) +endif + + +#Output +OBJ_OUTPUT = obj/$(TARGET_NAME)/ +CLEANTARGET = clean$(TARGET_NAME) +OBJS = $(addprefix $(OBJ_OUTPUT), $(OBJFILES)) +DEPFILES = $(patsubst %.o,%.d,$(OBJS)) +ifeq ($(findstring addons.make,$(wildcard *.make)),addons.make) + ADDONS = $(shell cat addons.make) + ADDONS_REL_DIRS = $(addsuffix /src, $(ADDONS)) + ADDONS_LIBS_REL_DIRS = $(addsuffix /libs, $(ADDONS)) + ADDONS_DIRS = $(addprefix $(OF_ROOT)/addons/, $(ADDONS_REL_DIRS) ) + ADDONS_LIBS_DIRS = $(addprefix $(OF_ROOT)/addons/, $(ADDONS_LIBS_REL_DIRS) ) + ADDONS_BIN_LIBS_DIRS = $(addsuffix /*/lib/$(LIBSPATH), $(ADDONS_LIBS_DIRS) ) + ADDONS_INCLUDES = $(ADDONS_DIRS) + ADDONS_INCLUDES = $(ADDONS_LIBS_DIRS) + ADDONS_INCLUDES += $(shell find $(ADDONS_DIRS) -type d 2> /dev/null) + ADDONS_INCLUDES += $(shell find $(ADDONS_LIBS_DIRS) -type d 2> /dev/null) + ADDONSCFLAGS = $(addprefix -I,$(ADDONS_INCLUDES)) +ifeq ($(findstring libsorder.make,$(shell find $(ADDONS_BIN_LIBS_DIRS) -name libsorder.make 2> /dev/null)),libsorder.make) + ADDONS_LIBS_W_ORDER = $(shell cat $(shell find $(ADDONS_BIN_LIBS_DIRS) -name libsorder.make 2> /dev/null)) + SED_EXCLUDE_LIBS = $(addsuffix \|,$(ADDONS_LIBS_W_ORDER)) + ADDONS_LIBS_STATICS = $(shell find $(ADDONS_BIN_LIBS_DIRS) -name *.a 2> /dev/null | grep -v '$(SED_EXCLUDE_LIBS)') + else + ADDONS_LIBS_STATICS = $(shell find $(ADDONS_BIN_LIBS_DIRS) -name *.a 2> /dev/null) + endif + + ADDONS_LIBS_STATICS += $(addprefix -l, $(ADDONS_LIBS_W_ORDER)) + ADDONS_LIBS_STATICS += $(addprefix -L, $(shell find $(ADDONS_BIN_LIBS_DIRS) -name libsorder.make 2> /dev/null | sed s/libsorder.make//g)) + ADDONS_LIBS_SHARED = $(shell find $(ADDONS_BIN_LIBS_DIRS) -name *.so 2> /dev/null) + ADDONSLIBS = $(ADDONS_LIBS_STATICS) + ADDONSLIBS += $(ADDONS_LIBS_SHARED) + + + ADDONS_SOURCES = $(shell find $(ADDONS_DIRS) -name "*.cpp" -or -name "*.c" 2> /dev/null) + ADDONS_SOURCES += $(shell find $(ADDONS_LIBS_DIRS) -name "*.cpp" -or -name "*.c" -or -name "*.cc" 2>/dev/null) + ADDONS_OBJFILES = $(subst $(OF_ROOT)/, ,$(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(ADDONS_SOURCES))))) + ADDONS_OBJS = $(addprefix $(OBJ_OUTPUT), $(ADDONS_OBJFILES)) + DEPFILES += $(patsubst %.o,%.d,$(ADDONS_OBJS)) +endif + +.PHONY: Debug Release all after + +Release: $(TARGET) after + +Debug: $(TARGET) after + +all: + $(MAKE) Release + + + +#This rule does the compilation +#$(OBJS): $(SOURCES) +$(OBJ_OUTPUT)%.o: %.cpp + @echo "compiling object for: " $< + mkdir -p $(@D) + $(CXX) -c $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o$@ -c $< + +$(OBJ_OUTPUT)%.o: %.c + @echo "compiling object for: " $< + mkdir -p $(@D) + $(CXX) -c $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o$@ -c $< + + +$(OBJ_OUTPUT)%.o: $(OF_ROOT)/%.cpp + @echo "compiling addon object for" $< + mkdir -p $(@D) + $(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o $@ -c $< + +$(OBJ_OUTPUT)%.o: $(OF_ROOT)/%.c + @echo "compiling addon object for" $< + mkdir -p $(@D) + $(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o $@ -c $< + +$(TARGET): $(OBJS) $(ADDONS_OBJS) + @echo "linking" $(TARGET) $(GTK) + $(CXX) -arch $(ARCH) -v -o $@ $(OBJS) $(ADDONS_OBJS) $(USER_CFLAGS) $(LDFLAGS) $(USER_LDFLAGS) $(TARGET_LIBS) $(ADDONSLIBS) $(USER_LIBS) $(LIBS) + +-include $(DEPFILES) + +.PHONY: clean cleanDebug cleanRelease +clean: + rm -Rf obj + rm -f -v $(TARGET) + rm -Rf -v bin/libs + +$(CLEANTARGET): + rm -Rf -v $(OBJ_OUTPUT) + rm -f -v $(TARGET) + +after:$(TARGET) + @echo Preparing MacOS .app + #-rm -rf -v $(TARGET).app + mkdir -p $(TARGET).app/Contents/Frameworks + mkdir -p $(TARGET).app/Contents/MacOS + cp -r $(OF_ROOT)/libs/glut/lib/osx/* $(TARGET).app/Contents/Frameworks/ + cp -r $(OF_ROOT)/libs/fmodex/lib/osx/* $(TARGET).app/Contents/MacOS/ + cp $(TARGET) $(TARGET).app/Contents/MacOS/ + install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib $(TARGET).app/Contents/MacOS/$(BIN_NAME) + @echo + @echo " compiling done" + @echo " to launch the application" + @echo + @echo " open $(TARGET).app" + @echo + + +.PHONY: help +help: + @echo + @echo openFrameworks universal makefile + @echo + @echo targets: + @echo "make Debug: builds the application with debug symbols" + @echo "make Release: builds the app with optimizations" + @echo "make: = make Release" + @echo "make all: = make Release" + @echo "make CleanDebug: cleans the Debug target" + @echo "make CleanRelease: cleans the Release target" + @echo "make clean: cleans everything" + @echo + @echo this should work with any OF app, just copy any example + @echo change the name of the folder and it should compile + @echo "only .cpp support, don't use .c files" + @echo it will look for files in any folder inside the application + @echo folder except that in the EXCLUDE_FROM_SOURCE variable. + @echo "it doesn't autodetect include paths yet" + @echo "add the include paths editing the var USER_CFLAGS" + @echo at the beginning of the makefile using the gcc syntax: + @echo -Ipath + @echo + @echo to add addons to your application, edit the addons.make file + @echo in this directory and add the names of the addons you want to + @echo include + @echo diff --git a/05_pointcloud/addons.make b/05_pointcloud/addons.make new file mode 100644 index 0000000..0b4df47 --- /dev/null +++ b/05_pointcloud/addons.make @@ -0,0 +1,5 @@ +ofxOpenNI +ofxFenster +ofxGui +ofxXmlSettings +ofxMayaCam diff --git a/05_pointcloud/config.mak b/05_pointcloud/config.mak new file mode 100755 index 0000000..cb19ecf --- /dev/null +++ b/05_pointcloud/config.mak @@ -0,0 +1,56 @@ +# add custom variables to this file + +# OF_ROOT allows to move projects outside apps/* just set this variable to the +# absoulte path to the OF root folder + +OF_ROOT = ../../../../../ + + +# USER_CFLAGS allows to pass custom flags to the compiler +# for example search paths like: +# USER_CFLAGS = -I src/objects + +USER_CFLAGS = -I $(OF_ROOT)/addons/ofxOpenNI/include/openni -I $(OF_ROOT)/addons/ofxOpenNI/include/nite -I $(OF_ROOT)/addons/ofxOpenNI/src + + +# USER_LDFLAGS allows to pass custom flags to the linker +# for example libraries like: +# USER_LDFLAGS = libs/libawesomelib.a + +#USER_LDFLAGS = -lOpenNI +USER_LDFLAGS = -L bin/data/openni/lib -L ../../../data/openni/lib/libusb-1.0.0.dylib -lOpenNI + +EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" + +# change this to add different compiler optimizations to your project + +USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os + + +# android specific, in case you want to use different optimizations +USER_LIBS_ARM = +USER_LIBS_ARM7 = +USER_LIBS_NEON = + +# android optimizations + +ANDROID_COMPILER_OPTIMIZATION = -Os + +NDK_PLATFORM = android-8 + +# uncomment this for custom application name (if the folder name is different than the application name) +#APPNAME = folderName + +# uncomment this for custom package name, must be the same as the java package that contains OFActivity +#PKGNAME = cc.openframeworks.$(APPNAME) + + + + + +# linux arm flags + +LINUX_ARM7_COMPILER_OPTIMIZATIONS = -march=armv7-a -mtune=cortex-a8 -finline-functions -funroll-all-loops -O3 -funsafe-math-optimizations -mfpu=neon -ftree-vectorize -mfloat-abi=hard -mfpu=vfp + + + diff --git a/05_pointcloud/config.make b/05_pointcloud/config.make new file mode 100755 index 0000000..af411a0 --- /dev/null +++ b/05_pointcloud/config.make @@ -0,0 +1,58 @@ +# add custom variables to this file + +# OF_ROOT allows to move projects outside apps/* just set this variable to the +# absoulte path to the OF root folder + +OF_ROOT = ../../openFrameworks + + +# USER_CFLAGS allows to pass custom flags to the compiler +# for example search paths like: +# USER_CFLAGS = -I src/objects + +USER_CFLAGS = -I $(OF_ROOT)/addons/ofxOpenNI/include/openni -I $(OF_ROOT)/addons/ofxOpenNI/include/nite -I $(OF_ROOT)/addons/ofxOpenNI/src + + +# USER_LDFLAGS allows to pass custom flags to the linker +# for example libraries like: +# USER_LDFLAGS = libs/libawesomelib.a + +USER_LDFLAGS = -lOpenNI + +CXX=colorgcc + + +EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj" + +# change this to add different compiler optimizations to your project + +USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os + + +# android specific, in case you want to use different optimizations +USER_LIBS_ARM = +USER_LIBS_ARM7 = +USER_LIBS_NEON = + +# android optimizations + +ANDROID_COMPILER_OPTIMIZATION = -Os + +NDK_PLATFORM = android-8 + +# uncomment this for custom application name (if the folder name is different than the application name) +#APPNAME = folderName + +# uncomment this for custom package name, must be the same as the java package that contains OFActivity +#PKGNAME = cc.openframeworks.$(APPNAME) + + + + + +# linux arm flags + +LINUX_ARM7_COMPILER_OPTIMIZATIONS = -march=armv7-a -mtune=cortex-a8 -finline-functions -funroll-all-loops -O3 -funsafe-math-optimizations -mfpu=neon -ftree-vectorize -mfloat-abi=hard -mfpu=vfp + + + diff --git a/05_pointcloud/src/main.cpp b/05_pointcloud/src/main.cpp new file mode 100644 index 0000000..f0d25bb --- /dev/null +++ b/05_pointcloud/src/main.cpp @@ -0,0 +1,17 @@ + +#include "testApp.h" +#include "ofMain.h" +#include "ofAppGlutWindow.h" + +//======================================================================== +int main( ){ + + ofAppGlutWindow window; + ofSetupOpenGL(&window, 1200,800, OF_WINDOW); // <-------- setup the GL context + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new testApp()); + +} diff --git a/05_pointcloud/src/testApp.cpp b/05_pointcloud/src/testApp.cpp new file mode 100644 index 0000000..6532b57 --- /dev/null +++ b/05_pointcloud/src/testApp.cpp @@ -0,0 +1,281 @@ +#include "testApp.h" + +//-------------------------------------------------------------- +void testApp::setup() { + + ofSetLogLevel(OF_LOG_NOTICE); + + verdana.loadFont(ofToDataPath("verdana.ttf"), 10); + + playing=0; + numDevices=2; + + string filename="TRSS_nesbitt_recordings.xml"; + + if( !XML.loadFile(filename) ){ + printf("unable to load recordings, check data/ folder\n"); + }else{ + if(XML.pushTag("TRSS")) { + int num=XML.getNumTags("rec"); + if(num) { + for (int i=0;i<num;i++) { + record rec; + rec.data.push_back(XML.getAttribute("rec","left","",i)); + rec.data.push_back(XML.getAttribute("rec","right","",i)); + rec.audio=XML.getAttribute("rec","audio","",i); + recs.push_back(rec); + } + } + else printf("no recordings!\n"); + } + } + ofxOpenNIUser user; + user.setUseMaskTexture(true); + user.setUsePointCloud(true); + user.setPointCloudDrawSize(2); // this is the size of the glPoint that will be drawn for the point cloud + user.setPointCloudResolution(2); // this is the step size between points for the cloud -> eg., this sets it to every second point + + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + + //openNIPlayers[deviceID].stop(); + openNIPlayers[deviceID].setup(true); + openNIPlayers[deviceID].addUserGenerator(); + openNIPlayers[deviceID].setRegister(true); + openNIPlayers[deviceID].start(); + openNIPlayers[deviceID].setBaseUserClass(user); + //openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing][deviceID])); + } + soundplayer.setLoop(false); + startPlayers(); + + //ofSetFrameRate(25.0f); + offset=0.0f; + drawmovies=false;drawcloud=true; + frame=0; +} + +void testApp::startPlayers(){ + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + //openNIPlayers[deviceID].stop(); + //openNIPlayers[deviceID].setup(false); + //openNIPlayers[deviceID].start(); + openNIPlayers[deviceID].startPlayer(ofToDataPath(recs[playing].data[deviceID])); + openNIPlayers[deviceID].setSpeed(0.01f); + //openNIPlayers[deviceID].setPaused(true); + + + soundplayer.stop(); + + if (recs[playing].audio!=""){ + soundplayer.loadSound(recs[playing].audio); + soundplayer.play(); + soundplayer.setPosition(offset); + } + } +} + +//-------------------------------------------------------------- +void testApp::update(){ + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIPlayers[deviceID].setFrame(frame); + openNIPlayers[deviceID].update(); + } +} + +//-------------------------------------------------------------- +void testApp::draw(){ + ofBackground(50, 50, 50); + ofSetColor(255, 255, 255); + + + + //glEnable(GL_PROGRAM_POINT_SIZE); + //glEnable(GL_POINT_SMOOTH); + //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + + //glPointSize(12.0f); + + + + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + + if (drawmovies) { + ofTranslate(0, deviceID * 400); + //openNIPlayers[deviceID].drawDebug(); + openNIPlayers[deviceID].drawDepth(50, 0,520,390); + openNIPlayers[deviceID].drawImage(600, 0,520,390); + } + + //construct points + //glBegin(GL_POINTS); + //how to find buffer size? + /* + XnStatus xn::DepthGenerator::ConvertProjectiveToRealWorld ( XnUInt32 nCount, + const XnPoint3D aProjective[], + XnPoint3D aRealWorld[] + ) + */ + + if (drawcloud) { + + cam.begin(); + + ofPushMatrix(); + ofRotate(0,1,0,180); + ofTranslate(0,0,1500); + + + + + ofDrawAxis(100); + + int count; + const XnDepthPixel* depthmap=openNIPlayers[deviceID].getDepthGenerator().GetDepthMap(); + int range=2500; + + int dmw=openNIPlayers[deviceID].getWidth(); + + for (int i=0;i<openNIPlayers[deviceID].getWidth();i+=2) { + + glBegin(GL_LINES); + + for (int j=0;j<openNIPlayers[deviceID].getHeight();j+=2) { + + + + ofPoint p= openNIPlayers[deviceID].projectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i])); + //ofPoint p= projectiveToWorld(ofPoint(i,j,(float)depthmap[j*dmw+i])); + + if (p.z == 0 || p.z>range) continue; // gets rid of background -> still a bit weird if userID > 0... //&& isCPBkgnd + //ofColor color = kinect->getColorAt(x,y); //userID); + //if (col) glColor4ub((unsigned char)color.r, (unsigned char)color.g, (unsigned char)color.b, (unsigned char)color.a); + // else + + + glColor4ub((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255); + glVertex3f(p.x, p.y, p.z); + //if (i==320&&j==160) cerr<<"world point: "<<p.x<<","<<p.y<<","<<p.z<<endl; + } + + glEnd(); + } + + + //export for fast/ switchable playback + //figure out how to line up (could be one off) + //export frame and find matching coords + //manually find positions + //calculate offset + //audio sync + //gui + //audio analysis + //sfx for point cloud + + // + + ofPopMatrix(); + + cam.end(); + + glDisable(GL_PROGRAM_POINT_SIZE); + + } + } + + ofSetColor(255, 255, 255); + string msg = "MILLIS: " + ofToString(ofGetElapsedTimeMillis()); + msg += "\nFPS: " + ofToString(ofGetFrameRate()); + msg += "\noffset: "+ofToString(offset); + verdana.drawString(msg, 10, 10); +} + +//-------------------------------------------------------------- +void testApp::exit(){ + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIPlayers[deviceID].stop(); + } +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key){ + bool changed=false; + switch (key) { + case ',': + if (playing==0) playing=recs.size(); + playing--; + changed=true; + break; + case '.': + playing=(playing+1)%recs.size(); + changed=true; + break; + case 'z': + offset+=.025; + break; + case 'x': + offset-=.025; + break; + case 'q': + drawmovies=!drawmovies; + break; + case 'w': + drawcloud=!drawcloud; + break; + case 'a': + frame--; + if (frame<0) frame=openNIPlayers[0].getTotalNumFrames()-1; + break; + case 's': + frame=((frame+1)%openNIPlayers[0].getTotalNumFrames()); + break; + } + if (changed) startPlayers(); + + /* why do this? + switch (key) { + case 't': + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].toggleRegister(); + } + break; + case 'x': + for (int deviceID = 0; deviceID < numDevices; deviceID++){ + openNIRecorders[deviceID].stop(); + } + break; + default: + break; + } + */ +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + diff --git a/05_pointcloud/src/testApp.h b/05_pointcloud/src/testApp.h new file mode 100644 index 0000000..67cd4dc --- /dev/null +++ b/05_pointcloud/src/testApp.h @@ -0,0 +1,56 @@ +#ifndef _TEST_APP +#define _TEST_APP + +#include "ofxOpenNI.h" +#include "ofMain.h" +#include "ofxXmlSettings.h" +#include "ofxMayaCam.h" + +#define MAX_DEVICES 2 + +struct record{ + vector<string> data; + string audio; +}; + +class testApp : public ofBaseApp{ + +public: + void setup(); + void update(); + void draw(); + void exit(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + + void startPlayers(); + + int numDevices; + ofxOpenNI openNIPlayers[MAX_DEVICES]; + + int playing; + + ofTrueTypeFont verdana; + + ofxXmlSettings XML; + + vector<record> recs; + + ofSoundPlayer soundplayer; + + float offset; + + ofxMayaCam cam; + + bool drawmovies,drawcloud; + int frame; + +}; + +#endif |
