MRPT implements a common C++ interface to Xbox Kinect, a new RGB+D sensor with an immense potential in mobile robotics. The implementation offers the user only one unified interface. Behind the scenes, MRPT uses one of these libraries to actually access the sensor:
Intensity (RGB) images are automatically converted to the OpenCV's format (mrpt::utils::CImage), 10bit or 11bit raw depth is converted to meters, and methods are provided to handle the two matrices of camera parameters (one for the RGB camera and one for the "range image").
Observations grabbed from MRPT's Kinect C++ class can be directly saved, among other types, in rawlogs for grabbing robotics datasets, or can be used online for any real-time application. On performance, full speed 30fps is achieved without problems under both Linux and Windows with libfreenect, but a multi-core processor is highly recommended if something else has to be done in real-time with the huge amount of received data.
Note: Kinect is supported since MRPT 0.9.3. Also, check out the Ubuntu PPA repository for possible often updates.
Example2: Application: kinect-3d-slam
To enable Xbox Kinect in MRPT for Windows, you'll need either OpenKinect's libfreenect or CL NUI SDK: http://codelaboratories.com/nui.
Before January 2011 (MRPT 0.9.3), the only choice in Windows was CL NUI. That SDK is much easier to install than freenect, but lacks some important features like grabbing the IR channel (needed for a proper calibration), so I would rather recommend freenect.
A) Driver installation (Required either if you install MRPT precompiled packages or build it from sources)
libusb-win32-bin-x.x.x.x.zip (it has binaries for both 32 and 64bit Windows). MRPT programs will need some DLLs in that package to be in the system PATH, so add libusb-win32-bin-x.x.x.x/bin/{x86 or amd64}/ to your system PATH.
Windows 7: step-by-step walkthrough (should also work with Windows XP!)
- Plug in your Kinect. Windows will warn that no device driver was found for the plugged device (the LED of Kinect will not turn on). If Windows presents a dialog asking to search for drivers, simply cancel it.
- Open the Device Manager: Start >> Control Panel >> System and Security >> System >> Device Manager
- A device called "Xbox NUI Motor" should be somewhere there (most probably be under "Other devices") with a small yellow warning symbol "!" on top of its icon. Right click on it, and select "Update Driver Software...", then click on "Browse my computer for driver software".
- "Browse" and select the folder where the "XBox_NUI_Motor.inf" is located (/platform/windows/inf inside your libfreenect source folder). Click "Next" and if warned by Windows that a non-certified driver is about to be installed, just order it to install it anyway.
- After that, the Kinect LED should start blinking green. Now there will be two additional devices in the Device Manager list: "Xbox NUI Camera" and "Xbox NUI Audio". Repeat the above instructions for them as well.
B) CMake configuration (Required only if you're building MRPT from sources)
Notice that MRPT 0.9.4+ does NOT require the sources of the "freenect" project, since there exists an embedded copy of them.
In MRPT CMake configuration (from cmake-gui), enable BUILD_KINECT, click "Configure" and verify that "BUILD_KINECT_USE_FREENECT" is marked. Two new variables will appear:
Click configure again and no errors should appear now.
If at some point you have errors in MSVC 2008 due to a missing stdint.h file, download this file pstdint.h , rename it to stdint.h and save it, for example, in OPENKINECT_LIBFREENECT_DIR/include. You can also replace those #include <stdint.h> with #include <mrpt/utils/mrpt_stdint.h> which is assured to always work disregarding of the compiler version.
Notes on libusb for Windows:
fatal error C1083: Cannot open include file: 'usb.h': No such file or directory
A very easy solution is to create a new header in libusb-win32-bin-1.x.x.0\include\usb.h containing just one single line:
#include "lusb0_usb.h"
After downloading and installing, CMake should find it while you configure MRPT. If it's not done automatically, enable BUILD_KINECT, click "Configure", then "BUILD_KINECT_USE_CLNUI", then "Configure" again and set the variable CLNUI_SDK_DIR pointing to the installation directory. Remember to add the "CL NUI Platform\SDK\Bin" directory to the system PATH.
Just install libusb-1.0-0-dev. In Ubuntu:
sudo apt-get install libusb-1.0-0-dev
OpenKinect's libfreenect is currently embedded into MRPT sources.
Accessing the device requires root privileges (executing as "sudo"). To avoid that, install this file:
http://mrpt.googlecode.com/svn/trunk/scripts/51-kinect.rules
Comments
Driver Conflict - help please
I try to install your kinect-package on XP. I get a conflict between the kinect-drivers of NUI and PrimeSense, which do not want to live together on my system. Could you think of creating a binary with the PrimeSense driver, as this seems to be the winning choice at the moment?
Many thanx for your great software!
Mischa
Is this NITE SDKs what you
Is this NITE SDKs what you say it's becoming more widely used? http://www.primesense.com/?p=515
Yeah, NITE would be the package of choice
This driver setup seems more attractive to us than the NUI drivers, as it is integrated into ros.org and offers the full sceleton tracking abilities which are so great for interaction design.
The installation requires the following four packages:
http://openni.org/downloadfiles/openni-compliant-middleware/18-primesens...
http://openni.org/downloadfiles/openni-compliant-middleware/15-nite-1
http://openni.org/downloadfiles/2-openni-binaries
https://github.com/avin2/SensorKinect
It would be great if I could use your program on the same laptop as all the rest of my kinect fascinations.
Kind regards
Mischa
Hi Mischa and thanks for the
Hi Mischa and thanks for the links! (although they don't work by now, each released version seems to have different URLs).
Anyway, I finally decided to allow MRPT in Windows to use either CL NUI or the OpenKinect's libfreenect library, which was a smoother change since it's already supported in Linux. I have updated the information on this page above accordingly. IMO libfreenect is a good choice, at least, compared to CL NUI! Hopefully their drivers are not incompatible with OpenNI.
Since I don't have much spare time I won't be able to integrate the OpenNI SDKs, so I will have to leave to it to the community... if anyone is really interested and put hands on I'll be glad to help him/her integrating the changes back into the MRPT repositories.
Best,
JL
Need help
Where can I find this::
In MRPT CMake configuration (from cmake-gui), enable BUILD_KINECT, click "Configure" and verify that "BUILD_KINECT_USE_FREENECT" is marked. Two new variables will appear
I have installed both Cmake and MRPT but don't know where to find this. Please help.
NITE
Yes, this is the package. Your support would be highly appreciated.
Kind regards
Mischa
Error in this demo with ubuntu
Hi MRPT Community.
I'm trying to test this demo but I'm getting some concurrence errors.
Perhaps it also may be that I'm using opencv 2.0? Ubuntu default packages install opencv 2.0 yet. I tried to set the opencv path to my opencv2 ROS package folder but in the cmake configuration summary I get detected the 2.0 version.
Trying to debug with ddd I get this message:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe5dbe700 (LWP 1981)]
0x00007ffff66424e1 in CRIT_SECT_LIN const* mrpt::utils::CReferencedMemBlock::getAs < CRIT_SECT_LIN const* > () const () from /opt/MRPT/lib/libmrpt-base.so.0.9
(gdb)
--------------------------------------
This is what I've tried:
geus@geus-vaio:/opt/MRPT/bin$ ./kinect-3d-slam
[Stream 70] Expected max 1748 data bytes, but got 1908. Dropping...
Calling CKinect::initialize()...OK
kinect-3d-slam: pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
-------------------------------------
In a second attempt I get:
geus@geus-vaio:/opt/MRPT/bin$ ./kinect-3d-slam
Calling CKinect::initialize()...OK
[CMyGLCanvasBase::Render] Exception!:
=============== MRPT EXCEPTION =============
void mrpt::synch::CCriticalSection::leave() const, line 120:
Trying to release a critical section possessed by a different thread.
terminate called after throwing an instance of 'std::logic_error'
what():
=============== MRPT EXCEPTION =============
mrpt::synch::CCriticalSection::~CCriticalSection(), line 81:
Destroying a critical section currently locked by thread 0x7F7463FFF700
Aborted
Suggestions and corrections are welcome.
Got the same error when tried
Got the same error when tried out kinect-3d-slam. Any suggestion is appreciated.
stdint.h is not found
Hello,
I found difficulties on finding the reason why stdint.h is not found in my MSVC2008.
I've downloaded the pstdint.h and rename it with stdint.h.
After that, i put the stdint.h to : C:\Program Files\Microsoft Visual Studio 9.0\VC\include
Unfortunately, i still got errors while trying to compile the project.
Please help me ^^;
Thank you.
Hi, As said above, try
Hi,
As said above, try putting that header not in MSVC include directory (modifying that directory is a bad practice in general...), but in "OPENKINECT_LIBFREENECT_DIR/include", then go to CMake for the directory of MRPT and clear the cache and go again thru "Configure" & "generate". That should fix it.
JL
Number of devices found:0
Thank you very much for your help.
Files compiled nicely.
I found : glview.exe and other execution files inside /bin folder.
Something odd is i couldn't execute the glview.exe nor debug the project (through MSVC2008)
I got this error message :
"Kinect camera test
libusb-win32 version 1.2.4.0 (driver -1, -1, -1, -1)
Number of devices found: 0"
It seems that the program failed to communicate with kinect. But,
I tried to execute CLNUI platform : http://codelaboratories.com/nui/
and everything works normal. (i could confirm the RGB and Depth output)
When i tried to rebuild and debug the project, i got the above error messages.
Anyone knows why I cannot see the device?
The Kinect is connected to my usb port (as well as the power supply) and the kinect has a green light blinking so I have no idea why is not founding it.
Please help me ^^;
Thank you for your time.
kinect-3d-slam got many types of error msgs.
Hello,
I tried to run the kinect-3d-slam demo in [Windows 7 using VS2008, OpenCV 2.2.0].
The application can be show the 3D scene windows but will stop working immediately.
Sometimes it doesn't show any error msg. But most of the times, I got many different error msgs.
For example,
1) "Untyped exception in [auxiliary_thread_launcher_LIN/WIN]!!!"
2) "Runtime error!
Untyped exception in [auxiliary_thread_launcher_LIN/WIN]!!!
Thread execution finished."
3) "Another exception!!"
4) "Another expception!!
runtime error R6016
- not enough space for thread data"
What can be the cause for this? And How can I fix this?
Is it the cause from OpenCV 2.2.0? I should use older version?
Build fails
Hi,
I am trying to build mrpt package on Windows 7 (I need Kinect support and cannot get it with precompiled executables).
I ran CMake and set flags (ex. Kinect and OpenCV) and then generated Visual Studio projects.
Next I tried building "ALL_BUILD.vcxproj" and "INSTALL.vcxproj". In both cases I get:
"LINK : fatal error LNK1104: cannot open file 'libmrpt-base094-dbg.lib' "
Can you help?
Also (I am not good with VS), what is difference between building "ALL_BUILD" vs. "INSTALL"?
libmrpt-base095-dbg.lib
I can't help; but I have the same problem, but I with libmrpt-base095-dbg.lib. Do you fixed your problem?
I compile and run MRPT on
I compile and run MRPT on Linux Mint.
It works well, so I recommend you do the same.
libmrpt-base094-dbg.dll is missing
Hi,
I am trying to compile the Kinect slam project in VS2010 and I get The error "libmrpt-base094-dbg.dll is missing".
Does anybody knows how to get rid of this error.
Thanks in advance
kinect-3d-slam
Hi,
I have a question about "kinect-3d-slam":
Why do you use feature tracking and not odometer data?
I find that it is not very accurate: when I rotate kinect in one dimension (x-y) the perspective also rotates in other plane (x-z) thus making the point cloud useless.
I admire the work you guys did and will greatly appretiate your answer.
FuseWith function
I have another question:
How can I use CColouredPointsMap->fuseWith function to merge the maps/observations?
I cannot pass an CColouredPointsMap object to it nor can I create a CPointsMap to pass into the function...
Please help.