Running ofxopenni

Hey nikpalmer,

Thank you for your reply to my ofxopenni query. It was helpful, however I am still having problems. When I try to compile the OF 62 example It cannot the file ofxOpenNI.h (no such file or directory, it says).

Here’s what I did:

I followed gameoverhacks instructions and copied his example into “yourofdir/apps/yourworkingdir” folder and then copied and pasted “lib” per his instructions. Next, as you suggested, I copied the OF 62 example and also moved it into yourofdir/apps/yourworkingdir. From there I added the
#include “ofxOpenNI.h” to testApp.h but when I build I get the following error:

/Users/xiouyang/Desktop/Jeffs kinect project/apps/myApps/ofxOpenniExample_from ofx/src/testApp.h:7:0
/Users/xiouyang/Desktop/Jeffs kinect project/apps/myApps/ofxOpenniExample_from ofx/src/testApp.h:7:23:
error: ofxOpenNI.h: No such file or directory

I have a couple questions:

  1. what do you mean by "you need to creata the “openni” directory in your ““yourexample/bin/data/” folder”. Are you simply confirming gameoverhacks instructions or is this an additional step?

  2. if it is an additional step, what and where is the openni directory? Sorry if I am obtuse, but I am so new to all of this (xcode, frameworks, addons and such).

  3. Why am I getting a “No such file or directory” error?

Thank you for any help you can provide,

Jeff

did you fix your problems??? I have the same problem with OF 007

@jwton and @christophepouly

Ok it’s a bit confusing getting a library with both includes and pre-compiled (in this case dynamic) libraries setup. In order for me to understand what’s happening can you answer some questions?

Can you get the example to compile successfully? Ie., copying my example to your apps/yourworkingdir folder; then copying the libs folder to the apps/yourworkingdir/example/bin/data/openni/ directory…

This is the first place to start…and it’s easiest to just modify that example if you’re struggling with the adding the libraries and includes…

However, if you are trying to make your own project then there is no need to go copying my example to your apps/yourworkingdir

Instead copy a blank empty example to apps/yourworkingdir

Make a folder in bin/data called openni/

* This is important and missing from my instructions on github (sorry!!) you need to copy the config/ directory from my example into the openni/ folder you just made in your own example app.

Then you need to copy the lib folder from ofxOpenNI/mac/copy_to_data_openni_path to your openni/ folder

IE., you should now have two folders in bin/data/openni, one called config the other called lib

Ok, but we’re not done. In order for the compiler to know where all the files are we need to drag a number of items into Xcode (as per the github instructions):

In Xcode make a new Group called ‘ofxOpenNI’ under ‘Addons’ (right or control click the ‘Addons’ Group, select Add->New Group)

Drag the ‘src’ and ‘include’ folders from inside the ofxOpenNI folder (in your addons directory) into the Group ‘ofxOpenNI’ you just made.

Drag the folder ‘lib’ from bin/data/openni (the one you just copied) into the Group ‘ofxOpenNI’

So inside Xcode it should look like my example in your addons:

addons
->ofxOpenNI
->src
->include
->lib

I hope that helps…

M

@gameover :

Hey man. been checkin out your ofxOpenNI fork- I just noticed it after I had spent a lot of work already on roxlu’s, getting threaded .oni loading working, drawing using glDrawArrays, caching X/Y world positions to multiply by z depth, etc.
I am more or less trying to merge the best of my additions + yours. Good stuff in yours! I love the libfreenect tilt addition.

But- I am curious about your method in making the portable dylibs. I am using the latest installation of openNI/avin2’s sensorkinect with a custom built bayer.cpp so that it doesn’t look interlaced/NITE - so I’m trying to reform/repackage them so they load properly.

Usually i would create a run script phase that does something like this:

#copy the dylib into the bundle
cp -f …/…/…/addons/ofxOpenNI/mac/openni/libnimCodecs.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libnimCodecs.dylib”;

#fix reference to libOpenNI inside libnimCodecs
install_name_tool -change …/…/Bin/Release/libOpenNI.dylib @loader_path/…/MacOS/libOpenNI.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libnimCodecs.dylib”

#fix install name of libnimCodecs
install_name_tool -change “…/…/Bin/Release/libnimCodecs.dylib” @loader_path/…/MacOS/libnimCodecs.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME”

#rinse/repeat previous steps for all related files, based on otool -L x.dylib, or by seeing what causes a runtime crash

Is this essentially what you did to the dylibs, or is there an additional step for making the app portable?

Hi there.
You can try my fork of ofxOpenNI, in which I added an automatic skeleton recognition capability.
https://github.com/roymacdonald/ofxOpenNI
-download it
-copy the dowloaded folder to OF’s addons folder
-Copy the floder in folder mac to AutoSkeletonExample/bin/data
-Install the latest unstable version of OpenNI, NITE and avin2’s kinect driver.

Dont move AutoSkeletonExample folder from where it is.

Once done just open AutoSkeletonExample project and compile.

good luck

@briangibson

It took me ages to figure out how Roxlu got this to work in the beginning…not entirely sure his and my methods are exactly the same, but they seem close enough…

On a mac what I do to get portable dylibs is (generically):

* Find the bit of code in the openNI sources (was XnModuleLoader.cpp but is now in XnOpenNI.cpp) that deals with environment variables and/or hard paths to finding the file “modules.xml” (this file gets read on init’ing openNI and is used to load OpenNI, NITE and SensorKinect dylibs)…you can see what I do to that file here: https://github.com/gameoverhack/OpenNI/blob/unstable/Source/OpenNI/XnOpenNI.cpp … basically I just make OpenNI go looking in the openni/config folder…
* Compile the OpenNI dylibs with this modification as per their normal instructions; copy them to a staging folder
* Copy NITE and SensorKinect dylibs to the same folder;
* Use install name tool to change the install paths of all dylibs to reflect their new home within the oF structure…I use the batch file in the libs folder included with ofxOpenNI (Roxlu had one of these, but I needed to modify it a bit to get it to work for me)…see: https://github.com/gameoverhack/ofxOpenNI/blob/master/mac/copy-to-data-openni-path/lib/change-exec-paths.sh
* EDIT: and modify the modules.xml file to reflect the correct paths/names of the dylibs I want to load…

Hope that helps!

Would love to see the changes you are talking about to both ofxOpenNI and to the SensorKinect drivers…

hi
i’m on linux and i don’t use codeblocks, i use manually makefiles. i tried to read the readme but i did not understand what to do. can you point me some advice? thanks!

EDIT:
ok i’ve done something really stupid like:

of_path/addons/ofxOpenNI/src$ cp …/include/openni/* . -R
of_path/addons/ofxOpenNI/src$ cp …/include/libusb/* . -R
of_path/addons/ofxOpenNI/src$ cp …/include/nite/* . -R

and it compiles till… this error:

…/…/…/addons/ofxOpenCv/libs/opencv/lib/linux/libopencv_objdetect.a(haar.o): In function cvHaarDetectObjects': haar.cpp:(.text.cvHaarDetectObjects+0x1bf2): undefined reference tocvCanny’

ideas?

@nkint
your problem has to do with OpenCV and not OpenNI.
ofxOpenNI doesn’t depend on OpenCV, so it must be something that you added.
are you doing some sort of face detection?

thanks for answer.
of course not. i’m only try to compile ofxopenni example. and i can compile and run correctly ofxopencv example.

EDIT:
ok, in the example in ofxOpenNI include to ofxopencv.h is missing in testApp.h!!

now i have this compiling error:

…/…/…/addons/ofxOpenNI/src/XnStatus.h:50: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:59: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: two or more data types in declaration of ‘parameter’
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: expected ‘)’ before ‘,’ token
…/…/…/addons/ofxOpenNI/src/XnStatus.h:68: error: expected unqualified-id before ‘const’

Of course because ofxopenNI doesn’t need Opencv.
Which version/fork of ofxOpenNI are you trying to run?
Do you have the latest OpenNI and NITE libs installed?

EDIT:
i’ve found a post with openni under linux,
http://forum.openframeworks.cc/t/ofxopenni-linux/5578/1
i’m moving there

Hello,

I have been trying to get the ofxOpenNI samples from gemeover to run on linux (ubuntu 11.04) with openFrameworks 7 and failed so far.

I followed the instructions provided by gameover on https://github.com/gameoverhack/ofxOpenNI#readme and also did this “This is important and missing from my instructions on github (sorry!!) you need to copy the config/ directory from my example into the openni/ folder you just made in your own example app.”

My make file looks like this:

  
# 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  
# -I ../../../addons/ofxOpenNI/src -I ../../../addons/ofxOpenNI/include/openni -I ../../../addons/ofxOpenNI/include/nite  
  
USER_CFLAGS =  -I ../../../addons/ofxOpenNI/src -I ../../../addons/ofxOpenNI/include/openni -I ../../../addons/ofxOpenNI/include/nite  
  
  
# USER_LDFLAGS allows to pass custom flags to the linker  
# for example libraries like:  
# USER_LD_FLAGS = libs/libawesomelib.a  
  
USER_LDFLAGS =  
  
  
# use this to add system libraries for example:  
# USER_LIBS = -lpango  
  
USER_LIBS = -lOpenNI  
  
  
# change this to add different compiler optimizations to your project  
  
USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os  
  
  
EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj"  
  

I get the following errors:

  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:33: undefined reference to `ofxOpenNIContext::setup()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:35: undefined reference to `ofxDepthGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:36: undefined reference to `ofxImageGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:38: undefined reference to `ofxUserGenerator::setup(ofxOpenNIContext*)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:39: undefined reference to `ofxUserGenerator::setSmoothing(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:40: undefined reference to `ofxUserGenerator::setUseMaskPixels(bool)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:41: undefined reference to `ofxUserGenerator::setUseCloudPoints(bool)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:42: undefined reference to `ofxUserGenerator::setMaxNumberOfUsers(int)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:44: undefined reference to `ofxHandGenerator::setup(ofxOpenNIContext*, int)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:45: undefined reference to `ofxHandGenerator::setSmoothing(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:46: undefined reference to `ofxHandGenerator::setFilterFactors(float)'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:48: undefined reference to `ofxOpenNIContext::toggleRegisterViewport()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:49: undefined reference to `ofxOpenNIContext::toggleMirror()'  
/home/campusnews/of/apps/dev/emptyExample/src/testApp.cpp:51: undefined reference to `ofxOpenNIRecorder::setup(ofxOpenNIContext*, int, int, bool, bool, bool)'  

The list goes on unfortunately. Does anybody know what I am doing wrong?

hi!
i had the same problem more or less.
i resolved in this way:

  • make sure you have installed the last openni version.
    you could verify it if you have .so files in /use/lib.

ls /usr/lib/libXn*

this is my output:

/usr/lib/libXnCore.so
/usr/lib/libXnDDK.so
/usr/lib/libXnDeviceFile.so
/usr/lib/libXnDeviceSensorV2KM.so
/usr/lib/libXnDeviceSensorV2.so
/usr/lib/libXnFormats.so
/usr/lib/libXnVCNITE_1_4_1.so
/usr/lib/libXnVFeatures_1_4_1.so
/usr/lib/libXnVFeatures.so
/usr/lib/libXnVHandGenerator_1_4_1.so
/usr/lib/libXnVHandGenerator.so
/usr/lib/libXnVNite_1_4_1.so
/usr/lib/libXnVNITE.jni.so
/usr/lib/libXnVNite.so

and some Xn*.h in /usr/include/ni

  • not copy ofxOpenNI source in of_path/addons but inside of_path/addons/apps/myapps/my_openni_project
    use this config.make:

USER_CFLAGS = -I src/ofxOpenNI/src -I src/ofxOpenNI/include -I /usr/include/ni

USER_LDFLAGS = /usr/lib/libnimCodecs.so /usr/lib/libnimMockNodes.so /usr/lib/libnimRecorder.so /usr/lib/libXnCore.so /usr/lib/libXnDDK.so /usr/lib/libXnDeviceFile.so /usr/lib/libXnDeviceSensorV2.so /usr/lib/libXnFormats.so /usr/lib/libXnVCNITE_1_3_1.so /usr/lib/libXnVFeatures.so /usr/lib/libXnVFeatures_1_3_1.so /usr/lib/libXnVHandGenerator.so /usr/lib/libXnVHandGenerator_1_3_1.so /usr/lib/libXnVNite.so /usr/lib/libXnVNite_1_3_1.so /usr/lib/libOpenNI.so

USER_LIBS = -lOpenNI

i don’t think this is the best way to do it. but in this way it works, in my case.

ps. i have grabbed the configs here:
https://github.com/patriciogonzalezvivo/KinectCoreVision/blob/master/config.make

hope it helps, let me know!

Hi nkint,

thank you for your reply!

wow that make adjustment got rid of a lot of problems! Thanks a bunch! It is working now!

What I also noticed is that I had a backup main in my src folder, which messed things up even more I think.

Hi guys I’m new to open frameworks and kinect. I’ve followed all the steps up to this point but the addon files within codeblocks are still broken and I can’t call the .h files

hey oceanmachine89,
code`blocks is a bit of a pain IMHO. You need to manually add the paths to the .h files of the addon.
I really don’t remember the exact process to add the includes in CB. google it.
best!

Hi thanks for the reply, this is still giving me a massive headache tried build options for headers and tried adding the files recursively

now I seem to be getting a bunch of errors after fixing the other stuff

  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::GestureCB_handleGestureProgress(xn::GestureGenerator&, char const*, XnVector3D const*, float, void*)@20'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::HandsCB_handleGestureProgress(xn::GestureGenerator&, char const*, XnVector3D const*, float, void*)@20'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::UserCB_handleCalibrationStart(xn::SkeletonCapability&, unsigned int, void*)@12'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::stopCommon()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::setLogLevel(XnLogSeverity)'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::logErrors(xn::EnumerationErrors&)'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::isRecording()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::setLooped(bool)'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getLooped()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::setSpeed(float)'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getSpeed()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getCurrentFrame()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getTotalNumFrames()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getPosition()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::getIsONIDone()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::setPaused(bool)'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::isPaused()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::isPlaying()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::addAudioGenerator()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::removeAudioGenerator()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::allocateDepthRawBuffers()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::allocateImageBuffers()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::allocateIRBuffers()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::allocateGestures()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
obj\release\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| multiple definition of `ofxOpenNI::updateImagePixels()'|  
obj\release\addons\ofxOpenNI\src\ofxOpenNI.o:ofxOpenNI.cpp|| first defined here|  
||More errors follow but not being shown.|  
||Edit the max errors limit in compiler options...|  
||=== Build finished: 50 errors, 0 warnings (0 minutes, 10 seconds) ===|  
  

Hi guys just wondering about the skeleton data. Is there an example out there that would be of good for referencing ?

Hello! I’m a beginner for OF and i’m more used to Processing. Recently I’ve been reading a book named which talks about building interactive apps with the help of Kinect and I want to transform my processing code to OF for further study. Unfortunately I stuck on the first step, to run examples giving by you successfully. I read the advise you provided above but it still doesn’t work for me.
Here is the error:
ld: warning: directory not found for option ‘-L/Volumes/Macintosh HD 2/of_v0.9.0RC2_osx_release/apps/myApps/mySketch/bindata/openni/lib’
ld: library not found for -lXnDDK
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I use XcodeVersion 6.3.1 (6D1002) and Ido as exactly what you told above; XnDDK.dylib does exits in the lib folder!
addons
->ofxOpenNI
->src
->include
->lib

Hope you can find me the solution!! Really looking forward to your reply!! :grin: