File Exchange

image thumbnail

Matlab Wrapper for OpenNI 2.2

version 1.1 (4.94 KB) by

A very simple wrapper that provides an interface to RGBD cameras through OpenNI v2.2

15 Downloads

Updated

View License

This submission was motivated by the Kinect Matlab submission that provided an interface to OpenNI version 1.5. There was a significant reworking of the interface in OpenNI v2.2 that necessitated a bit of a rethink. The current interface is a single mex routine that acts as a 'switchyard'. You indicate which operation you want to perform on the device via the first argument which should be an integer.

Installation:

You need to install OpenNI 2.2 first before you build this mex function.

I have provided short compilation script which shows how to build the mex application. You should edit the filename variables in this script to match your system configuration.

IMPORTANT:
In order to run this mex file you need to copy the contents of the OpenNI/Redist directory to your current working directory. There may be a way to avoid this by messing with your DYLD_LIBRARY_PATH but I haven't tested this.

Usage:

Once you have this built you can type mxNI to see the operations that you can perform.

Known Issues:

This code assumes that you only have one OpenNI device attached

It has only been tested on MacOSX version 10.8.3.

When you run the compilation on this system their is an annoying warning regarding a dangling pragma.

This code is functional but more bells and whistles could be added. Fortunately the structure of the code is quite simple so please feel free to make it better.

Happy Hacking!!

Comments and Ratings (13)

Sorry. Clicking the download button helped :)
/Hans

This seems like exactly what I am looking for.
But where is the file mxNI.cpp? If I need to write is myself, then it would be really great if someone could post an example to get me started.
/Hans

Justin Cheng

Awesome!!! Saved my life with this.

Hi, I'm able to capture RGB images using ASTRA S and MATLAB in 480X640 resolution mode. However, I'm unable to capture clear images when I use Fps = 30
pixelFormat = PIXEL_FORMAT_RGB888
resX = 1280
resY = 720

Can anyone kindly advise in this regard.

Shehroz Khan

When I type mxNI(0), it gives this error
"Invalid MEX-file '/my/path/to/mxNI/mxNI.mexa64': libOpenNI2.so: cannot open shared object file:
No such file or directory"
Even though mxNI.mexa64 exists in the directory. Can someone help please?

Sarah

Sarah (view profile)

Hi, after installation I tried first to initialize by "mxNI(0)"
then I got the following error:

Couldn't open device
DeviceOpen using default: no devices found

Closing the NI device
Error using mxNI
mxNI init failed

I tried to connect with the microsoft Kinect.
What is going wrong?

If anybody knows about this problem - please help me.
Thanks in advance

Ana Gerós

Hi, I'm getting an erro when I write "mxNI" in the command window.

The following message appears:
Invalid MEX-file 'C:\Users\Staples\Documents\mxNI\mxNI.mexw64': Impossible to locate the specified module.

In fact, after compilation, a file named "mxNI.mexw64" was created, but apparently it can not be recongnized.

Does anyone can help me? Thanks in advance*

nevermind, i got it figured out! :)

Hi, i am getting an error when mxNI calls openni.h that there is a null character on 1:5 (line 1, column 5?).
The line itself is just "/*******************" and is the first part of the commented header information.

The error also says the word "book" after the location 1:5... but "book" does not appear in the code anywhere, let alone on line 5.

Does anyone know what is going on and how to get past the "warning null character" error that repeats several times before crashing the code?

Many thanks in advance

Hi, I'll start with a few things to help a user.

1. Add the location of the redist folder in 'C:\Program Files\OpenNI2\Redist' to the path variable & MATlab path via advanced setting-->system variables

2. As Ivan mentioned, change

OPENNI2_INCLUDE = 'C:\Program Files\OpenNI2\Include';

OPENNI2_REDIST = 'C:\Program Files\OpenNI2\Lib';

Congratulatory part:
Code is simple, effective and a great platform for simple hacks!

jetsun

jetsun (view profile)

It can works on Windows.

Ivan

Ivan (view profile)

Thanks for this. Compiled fine under Windows with Matlab2010a, MSVC 10 Express, OpenNI2.2 and Windows SDK 7.1. Had to rewrite the paths:
OPENNI2_INCLUDE = 'C:\Program Files\OpenNI2\Include';
OPENNI2_REDIST = 'C:\Program Files\OpenNI2\Lib';

Updates

1.1

Deleted an extraneous word from the Summary field

MATLAB Release
MATLAB 8.0 (R2012b)
Acknowledgements

Inspired by: Kinect Matlab

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today