At the beginning, when I ran the sample program NiViewer from the OpenNI libaray, I got the following error:
Open failed: failed to set USB interface.
I found the solution on OpenNI Google group discussion. You need to remove the gspca_kinect kernel module that comes with the upgrade by doing:
rmmod gspca_kinectIt seems to work even though it says "cann't find the module gspca_kinect". However, every time you restart the computer or replugin the Kinect USB, the module will be loaded again. To permanently remove the module, you can change the name of the module file:
sudo mv /lib/modules/3.0.0-12-generic/kernel/drivers/media/video/gspca/ gspca_kinect.ko /lib/modules/3.0.0-12-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko.BAK
A better way may be blacklisting the module as suggested by this post. In this way, even after a kernel upgrade, the module will not be loaded.
$sudo gedit /etc/modprobe.d/blacklist.confThen add the following line to the end of the file and reboot:
blacklist gspcs_kinect
After this, the program could run, but I only got the RGB image data and the depth image was blank. Someone find out that this is due to the wrong use of
memcpy
in the OpenNI library. The line of code that causes the problem is in "/Source/OpenNI/Linux-x86/XnUSBLinux-x86.cpp" function "XN_THREAD_PROC xnUSBReadThreadMain(XN_THREAD_PARAM pThreadParam)" around line 1057. Instead of using memcpy
, it should be:memmove(pTransfer->buffer + nTotalBytes, pBuffer, pPacket->actual_length);The difference between
memcpy
and memmove
is that with memcpy
, the destination cannot overlap the source at all, while with memmove
, it can. For example, memcpy
might always copy addresses from low to high. If the destination overlaps after the source, this means some addresses will be overwritten before copied. memmove
would detect this and copy in the other direction - from high to low - in this case. However, checking this and switching to another (possibly less efficient) algorithm takes time.
The previous version of
memcpy
in libc6
may not make the difference so distinct, but in the new updated version of libc6 version 2.13, it might copy memory backward in some conditions, which causes issues if the source and destination overlap. You can read more about the changes in the new version in "/usr/share/doc/libc6/NEWS.Debian.gz".
Thank you so much! I was trapped by the exactly same problem. :)
ReplyDeleteThank you very much! It solved my problem as well :)
ReplyDelete