OpenKinect / libfreenect

Drivers and libraries for the Xbox Kinect device on Windows, Linux, and OS X
http://openkinect.org
3.56k stars 1.15k forks source link

Add support for Kinect for Xbox 360 Model 1473 #316

Closed hkzlab closed 11 years ago

hkzlab commented 11 years ago

Hello, I write to open an issue on the missing support for this device. The 1473 model does not work with libfreenect: I always get a "Could not open device" when trying to launch demos using the camera or the tilt motor.

Also, the Xbox NUI Motor doesn't show up when checking with lsusb (testing on Ubuntu 12.10, 32bit): Bus 001 Device 086: ID 045e:02c2 Microsoft Corp. Bus 001 Device 087: ID 045e:02ad Microsoft Corp. Xbox NUI Audio Bus 001 Device 088: ID 045e:02ae Microsoft Corp. Xbox NUI Camera If needed, I can provide more verbose lsusb logs.

tong commented 11 years ago

dunno.please!

a-m-p-m commented 11 years ago

I have the same issue with Kinect for Xbox 360 Model 1473. Ubuntu 12.04 32bit, 64bit; Linux Mint 13 32bit on different computers.

ansoto commented 11 years ago

Hi, I have the same issue... Have you found a solution ?

JoshBlake commented 11 years ago

The solution is somewhat technically complicated and we're still discussing the right way to approach it. For more information check the OpenKinect mailing list: https://groups.google.com/group/openkinect

ansoto commented 11 years ago

Is there any progress about that ? Thanks

vitaly-little commented 11 years ago

I found solution in this topic http://forum.openframeworks.cc/index.php?topic=11632.0

here is a very rough fix for it in the libfrenect files in this branch: https://github.com/ofTheo/ofxKinect/tree/kinect-device-fix you can see the differences between the current develop branch: https://github.com/ofTheo/ofxKinect/compare/develop...kinect-device-fix

Exomene commented 11 years ago

Thanks for finding this. Can you explain how you proceeded? I compiled and installed this fix but still have the "Unable to open" error while testing with glview with ubuntu 12.10 64bits. Thanks

ghost commented 11 years ago

The link doesn't work for me either, is anyone working on it?

chriswei commented 11 years ago

I was able to build and run the openFrameworks example described in the previously mentioned post on my Xbox Kinect model 1473. I built the ofxKinect 'kinect-device-fix' branch in openFrameworks using Xcode on my MBPro.

The video and point cloud seemed to be working, but I was unable to take that code and successfully build and run a standalone version of libfreenect. In my attempt with Theo Watson's kinect-device-fix branch, the glview test app finds a device, prints out some debug information in the terminal, opens a window, then hangs. At least it gets past the "Could not open device" error! Unfortunately I don't have any time (and maybe not the skills) to dig deeper.

I'm very interested in a solution that gets libfreenect working with the 'new' Xbox Kinect model 1473. I'd hate to have to return it and go looking for an older model on eBay. I'm also considering trying to get one of the Prime Sense sensors, but they're $200 plus shipping from Israel and take 2-4 weeks to ship. I'd eventually like to get Processing talking to the Xbox Kinect model 1473 on OS X.

The "previously mentioned post": http://forum.openframeworks.cc/index.php?topic=11632.0

Thanks!

Exomene commented 11 years ago

I'd like to use it with processing too. By the way, if you use openkinect in processing the IR in the kinect 1473 starts and it returns some results (I didn't get further). I tried to follow the instructions on getting Theo Watson's branch to work with openFrameworks but failed (I got lost with code::blocks). Since it is a derivative, as far as I understood, I replaced the files in the source of openKinect by Theo's modified ones. It compiled on my ubuntu 12.10 but the problem remained the same. Another question: I didn't understand the difference between freenect-glview and glview on the getting started page (http://openkinect.org/wiki/Getting_Started). It seems one should use glview when installed from the binaries and glview when installed from the sources. It's quite confusing for me, could'nt this be the source of some issues?

dudefellah commented 11 years ago

I've been messing around with this a bunch (I have a Kinect v 1473) and can get the demos sort of going by making one small change in freenect_fetch_zero_plane_info in src/cameras.c (note that this will break libfreenect with "old" Kinect versions):

--- a/src/cameras.c
+++ b/src/cameras.c
@@ -899,14 +899,13 @@ static int freenect_fetch_reg_const_shift(freenect_device *dev)
 static int freenect_fetch_zero_plane_info(freenect_device *dev)
 {
        freenect_context *ctx = dev->parent;
-
        char reply[0x200];
        uint16_t cmd[5] = {0}; // Offset is the only field in this command, and it's 0

        int res;
-       res = send_cmd(dev, 0x04, cmd, 10, reply, 322); //OPCODE_GET_FIXED_PARAMS = 4,
-       if (res != 322) {
-               FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 322)\n", res);
+       res = send_cmd(dev, 0x04, cmd, 10, reply, 334); //OPCODE_GET_FIXED_PARAMS = 4,
+       if (res != 334) {
+               FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 334)\n", res);
                return -1;
        }

and then I remove attempts to use the motor:

--- a/examples/glview.c
+++ b/examples/glview.c
@@ -412,7 +412,8 @@ int main(int argc, char **argv)
        }

        freenect_set_log_level(f_ctx, FREENECT_LOG_DEBUG);
-       freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA));
+       //freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO));
+       freenect_select_subdevices(f_ctx, (freenect_device_flags)(FREENECT_DEVICE_CAMERA | FREENECT_DEVICE_AUDIO));

        int nr_devices = freenect_num_devices (f_ctx);
        printf ("Number of devices found: %d\n", nr_devices);

I've read that there have been changes with the motor device in that it's somehow attached to the audio now? I'm not very experienced with libusb, but I would like to try to mess around and make it work if anybody has any ideas/suggestions.

zanemcca commented 11 years ago

So I am brand new to github. Could you tell me how you compiled your changes after you put them in @dudefellah

I tried to make in the build directory but it did not seem to put the changes in. I also removed the object files and even tried removing the whole build directory and redoing cmake. Nothing seemed to work. Any help would be great.

dudefellah commented 11 years ago

I've forked my own copy here: https://github.com/dudefellah/libfreenect.git

You can diff against your repo to see what's been changed (the changes are somewhat different from what I posted earlier... I'm still trying to figure this stuff out)

When you compile, you'll need to build audio and I've added a flag for building for the kinect ver 1473, so you'll need at least something like cmake -DBUILD_AUDIO:BOOL=ON -DBUILD_KINECT_1473:BOOL=ON

I didn't commit the changes in glview since I've been messing around with a whole bunch of stuff, but I think you'll probably need remove the FREENECT_DEVICE_MOTOR flag from freenect_select_subdevices and may (I can't remember exactly) need to add FREENECT_DEVICE_AUDIO. The glview.c change should be the same as I posted earlier.

Hope that helps a bit more.

Does nobody else have more information on what's needed to get everything working again?

dudefellah commented 11 years ago

Looks like my work so far is actually a dumber version of this: https://github.com/renewagner/libfreenect/commit/06e48e5d4328f96bf61613953bab2f45a459a1fb . I'll probably end up using this code when I have time to play with libfreenect in the next week or so.

zanemcca commented 11 years ago

Thanks that helps. I cannot find anything useful telling me why this thing will not rebuild properly.

If I edit glview.c I can see my changes right away. But I cannot get anything to happen when I change cameras.c. make says it is compiling it but nothing I do changes the output. I have installed, uninstalled and deleted everything countless times nothing I do has changed the output at all.

My most reason version of this is here:

--- a/src/cameras.c
+++ b/src/cameras.c
@@ -903,13 +903,29 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev)
        uint16_t cmd[5] = {0}; // Offset is the only field in this command, and it's 0

        int res;
-       res = send_cmd(dev, 0x04, cmd, 10, reply, 322); //OPCODE_GET_FIXED_PARAMS = 4,
-       if (res != 322) {
-               FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 322)\n", res);
-               return -1;
-       }

-       memcpy(&(dev->registration.zero_plane_info), reply + 94, sizeof(dev->registration.zero_plane_info));
+        int expected_len = 0;
+        int struct_offset = 0;
+/*        switch(dev->hwrev) {
+          case HWREV_XBOX360_0:
+            expected_len = 322;
+            struct_offset = 94;
+            break;
+          case HWREV_K4W_0:
+          */
+            expected_len = 334;
+            struct_offset = 94;
+//            break;
+//        }
+
+        res = send_cmd(dev, 0x04, cmd, 10, reply, expected_len); //OPCODE_GET_FIXED_PARAMS = 4,
+        if (res != expected_len) {
+          //FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected %d)\n", res, expected_len);
+          FN_ERROR("ERROR: THIS SHOULD PRINT ON THE SCREEN");
+           return -1;
+        }
+
+        memcpy(&(dev->registration.zero_plane_info), reply + struct_offset, sizeof(dev->registration.zero_plane_info));
        union {
                uint32_t ui;
                float f;
@@ -1261,7 +1277,9 @@ int freenect_set_video_mode(freenect_device* dev, const freenect_frame_mode mode
        dev->video_resolution = res;
        // Now that we've changed video format and resolution, we need to update
        // registration tables.
-       freenect_fetch_reg_info(dev);
+        if (res == FREENECT_RESOLUTION_MEDIUM) {
+           freenect_fetch_reg_info(dev);
+        }
        return 0;
 } 

When I run glview I get this:

Kinect camera test
Number of devices found: 1
Control cmd=0016 tag=0000 len=000a: 18
Control reply: 18
start_lines:    0
end_lines:      0
cropping_lines: 0
Control cmd=0004 tag=0001 len=000a: 18
Control reply: 18
send_cmd: Data buffer is 322 bytes long, but got 334 bytes
freenect_fetch_zero_plane_info: send_cmd read 334 bytes (expected 322)
freenect_camera_init(): Failed to fetch zero plane info for device
Could not open device

I do not know how it is possible for it to print 322 at all I have it hard coded to 334. I have tried this a million times. Please help, how do I get the changes to go through?

zanemcca commented 11 years ago

Ok so I tried to edit the file on my MacAir and it worked. But it is still not responding on my RaspberryPi with RaspbianOS. I am guessing there is some other old definition of that code that is getting called but I have no idea where it is. I tried to go through my /usr and /bin directories and I deleted everything with libfreenect in it then I reinstalled everything but still nothing.

Exomene commented 11 years ago

Thanks @dudefellah. I tried René Wagner's branch and finally had the same message as @zanemcca though I removed all files related to libfreenect before.

leokoppel commented 11 years ago

I got the camera to work by combining renewagner's and ofTheo's code. I saved this here https://github.com/theoceanwalker/libfreenect The glview example doesn't seem to work (it shows a blank window, and running it somehow messes up subsequent attemps to access the kinect), though "regview" does. This doesn't really concern me as I am using the python wrappers which are now working.

zanemcca commented 11 years ago

Hey @Exomene I am trying to figure out why we are having this error.

My theory is that there is some file that is linking to an old copy of the /src directory and our changes are actually getting compiled into another file.

But to narrow down the symptoms of our problem can you tell me what hardware/OS you are on? I am on a RaspberryPi Rev B with RaspbianOS.

Also I tried to get the OpenFrameworks fix working, which could be the source of the error, did you try to install it as well?

Any other info you have should help. Thanks

leokoppel commented 11 years ago

@zanemcca @Exomene odd issue but almost certainly has nothing to do with this library in particular, or what hardware you're on. The simplest explanations are

What are you actually doing to build? The output of make will tell you what source directory it's using..

Exomene commented 11 years ago

Hi, I'm just passing by and I'll come back after having test thoroughly but the problem I face may be due to the use of Kinect on USB 3 ports. As strange as it sounds I read that Kinect is an USB 2 only device and might not work correctly on USB 3. I'm on a PC running Ubuntu 12.10 64bit.

zanemcca commented 11 years ago

Hi @theoceanwalker Thanks for the insight. I have gotten mine to work by the rather crude reinstall my OS method, not a big hassle for me since it had almost nothing on it anyway. But I did not change my method for recompiling at all so I am confident that was not the issue. I think you are probably right about the /usr/lib and /usr/local/lib having conflicts. I tried as best as I could to track down any instances of libfreenect in the /usr and /etc directories but it is possible that I missed stuff.

But just for an FYI here are my outputs from making on my new install.

pi@raspberrypi ~/libfreenect/build $ cmake ..
-- Operating system is Linux
-- Got System Processor armv6l
-- libfreenect will be installed to /usr/local
-- Headers will be installed to /usr/local/include/libfreenect
-- Libraries will be installed to /usr/local/lib
-- Found libusb-1.0:
--  - Includes: /usr/include/libusb-1.0
--  - Libraries: /usr/lib/arm-linux-gnueabihf/libusb-1.0.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/libfreenect/build
pi@raspberrypi ~/libfreenect/build $ make
Scanning dependencies of target freenect
[  4%] Building C object src/CMakeFiles/freenect.dir/usb_libusb10.c.o
Linking C shared library ../lib/libfreenect.so
[ 23%] Built target freenect
Scanning dependencies of target freenectstatic
[ 28%] Building C object src/CMakeFiles/freenectstatic.dir/usb_libusb10.c.o
Linking C static library ../lib/libfreenect.a
[ 47%] Built target freenectstatic
Linking C shared library ../../lib/libfreenect_sync.so
[ 52%] Built target freenect_sync
Linking C executable ../bin/glpclview
[ 57%] Built target glpclview
Linking C executable ../bin/glview
[ 61%] Built target glview
Linking C executable ../bin/hiview
[ 66%] Built target hiview
Linking C executable ../bin/regtest
[ 71%] Built target regtest
Linking C executable ../bin/regview
[ 76%] Built target regview
Linking C executable ../bin/tiltdemo
[ 80%] Built target tiltdemo
[ 85%] Built target fakenect
Linking C executable ../bin/record
[ 90%] Built target record
[ 95%] Built target freenect_sync_static
Linking CXX executable ../../bin/cppview
[100%] Built target cppview
pi@raspberrypi ~/libfreenect/build $ sudo make install
[ 23%] Built target freenect
[ 47%] Built target freenectstatic
[ 52%] Built target freenect_sync
[ 57%] Built target glpclview
[ 61%] Built target glview
[ 66%] Built target hiview
[ 71%] Built target regtest
[ 76%] Built target regview
[ 80%] Built target tiltdemo
[ 85%] Built target fakenect
[ 90%] Built target record
[ 95%] Built target freenect_sync_static
[100%] Built target cppview
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libfreenect.so.0.1.2
-- Up-to-date: /usr/local/lib/libfreenect.so.0.1
-- Up-to-date: /usr/local/lib/libfreenect.so
-- Installing: /usr/local/lib/libfreenect.a
-- Up-to-date: /usr/local/include/libfreenect/libfreenect.h
-- Up-to-date: /usr/local/include/libfreenect/libfreenect-registration.h
-- Up-to-date: /usr/local/lib/pkgconfig/libfreenect.pc
-- Installing: /usr/local/bin/glview
-- Removed runtime path from "/usr/local/bin/glview"
-- Installing: /usr/local/bin/regview
-- Removed runtime path from "/usr/local/bin/regview"
-- Installing: /usr/local/bin/hiview
-- Removed runtime path from "/usr/local/bin/hiview"
-- Installing: /usr/local/bin/glpclview
-- Removed runtime path from "/usr/local/bin/glpclview"
-- Installing: /usr/local/bin/tiltdemo
-- Removed runtime path from "/usr/local/bin/tiltdemo"
-- Up-to-date: /usr/local/lib/fakenect/libfreenect.so.0.1.2
-- Up-to-date: /usr/local/lib/fakenect/libfreenect.so.0.1
-- Up-to-date: /usr/local/lib/fakenect/libfreenect.so
-- Installing: /usr/local/bin/record
-- Removed runtime path from "/usr/local/bin/record"
-- Up-to-date: /usr/local/bin/fakenect
-- Installing: /usr/local/lib/libfreenect_sync.so.0.1.2
-- Up-to-date: /usr/local/lib/libfreenect_sync.so.0.1
-- Up-to-date: /usr/local/lib/libfreenect_sync.so
-- Removed runtime path from "/usr/local/lib/libfreenect_sync.so.0.1.2"
-- Up-to-date: /usr/local/lib/libfreenect_sync.a
-- Up-to-date: /usr/local/include/libfreenect/libfreenect_sync.h
-- Up-to-date: /usr/local/include/libfreenect.hpp
-- Installing: /usr/local/bin/cppview
-- Removed runtime path from "/usr/local/bin/cppview"

Thanks again.

Exomene commented 11 years ago

Hi @zanemcca, Yes I tried the openFrameworks fix. I thought you had a good idea by removing all the references to libfreenect and kinect before trying to reinstall @theoceanwalker 's branch. So this is what's left concerning *nect on my computer before reinstalling libfreenect (I'm running ubuntu 12.10 64bits)

/etc/modprobe.d/blacklist-gspca-kinect.conf
/etc/udev/rules.d/51-kinect.rules
/lib/modules/3.2.0-32-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-18-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-19-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-21-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-22-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-23-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-25-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/lib/modules/3.5.0-26-generic/kernel/drivers/media/video/gspca/gspca_kinect.ko
/usr/share/doc/opencv-doc/examples/cpp/kinect_maps.cpp.gz
/usr/share/pulseaudio/alsa-mixer/profile-sets/kinect-audio.conf
/usr/src/linux-headers-3.5.0-19-generic/include/config/usb/gspca/kinect.h
/usr/src/linux-headers-3.5.0-21-generic/include/config/usb/gspca/kinect.h
/usr/src/linux-headers-3.5.0-22-generic/include/config/usb/gspca/kinect.h
/usr/src/linux-headers-3.5.0-23-generic/include/config/usb/gspca/kinect.h
/usr/src/linux-headers-3.5.0-25-generic/include/config/usb/gspca/kinect.h
/usr/src/linux-headers-3.5.0-26-generic/include/config/usb/gspca/kinect.h

Is there still thing I should remove?

Regarding the result of cmake, here they are

-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Operating system is Linux
-- Got System Processor x86_64
-- Linux x86_64 Detected
-- libfreenect will be installed to /usr/local
-- Headers will be installed to /usr/local/include/libfreenect
-- Libraries will be installed to /usr/local/lib64
-- Found libusb-1.0:
--  - Includes: /usr/include/libusb-1.0
--  - Libraries: /usr/lib/x86_64-linux-gnu/libusb-1.0.so
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so  
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/exomene/libfreenect-master/build

And the results of make

Scanning dependencies of target freenect
[  4%] Building C object src/CMakeFiles/freenect.dir/core.c.o
[  9%] Building C object src/CMakeFiles/freenect.dir/tilt.c.o
[ 14%] Building C object src/CMakeFiles/freenect.dir/cameras.c.o
/home/exomene/libfreenect-master/src/cameras.c:749:17: attention : ‘read_register’ defined but not used [-Wunused-function]
/home/exomene/libfreenect-master/src/cameras.c: In function ‘freenect_set_smoothing_mode’:
/home/exomene/libfreenect-master/src/cameras.c:1338:1: attention : contrôle a atteint la fin non void de la fonction [-Wreturn-type]
[ 19%] Building C object src/CMakeFiles/freenect.dir/usb_libusb10.c.o
/home/exomene/libfreenect-master/src/usb_libusb10.c: In function ‘fnusb_open_subdevices’:
/home/exomene/libfreenect-master/src/usb_libusb10.c:382:1: attention : format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘struct libusb_device_handle *’ [-Wformat]
/home/exomene/libfreenect-master/src/usb_libusb10.c:385:1: attention : format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘struct libusb_device_handle *’ [-Wformat]
/home/exomene/libfreenect-master/src/usb_libusb10.c:178:25: attention : unused variable ‘nr_mot’ [-Wunused-variable]
[ 23%] Building C object src/CMakeFiles/freenect.dir/registration.c.o
Linking C shared library ../lib/libfreenect.so
[ 23%] Built target freenect
Scanning dependencies of target freenectstatic
[ 28%] Building C object src/CMakeFiles/freenectstatic.dir/core.c.o
[ 33%] Building C object src/CMakeFiles/freenectstatic.dir/tilt.c.o
[ 38%] Building C object src/CMakeFiles/freenectstatic.dir/cameras.c.o
/home/exomene/libfreenect-master/src/cameras.c:749:17: attention : ‘read_register’ defined but not used [-Wunused-function]
/home/exomene/libfreenect-master/src/cameras.c: In function ‘freenect_set_smoothing_mode’:
/home/exomene/libfreenect-master/src/cameras.c:1338:1: attention : contrôle a atteint la fin non void de la fonction [-Wreturn-type]
[ 42%] Building C object src/CMakeFiles/freenectstatic.dir/usb_libusb10.c.o
/home/exomene/libfreenect-master/src/usb_libusb10.c: In function ‘fnusb_open_subdevices’:
/home/exomene/libfreenect-master/src/usb_libusb10.c:382:1: attention : format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘struct libusb_device_handle *’ [-Wformat]
/home/exomene/libfreenect-master/src/usb_libusb10.c:385:1: attention : format ‘%i’ expects argument of type ‘int’, but argument 2 has type ‘struct libusb_device_handle *’ [-Wformat]
/home/exomene/libfreenect-master/src/usb_libusb10.c:178:25: attention : unused variable ‘nr_mot’ [-Wunused-variable]
[ 47%] Building C object src/CMakeFiles/freenectstatic.dir/registration.c.o
Linking C static library ../lib/libfreenect.a
[ 47%] Built target freenectstatic
Scanning dependencies of target freenect_sync
[ 52%] Building C object wrappers/c_sync/CMakeFiles/freenect_sync.dir/libfreenect_sync.c.o
Linking C shared library ../../lib/libfreenect_sync.so
[ 52%] Built target freenect_sync
Scanning dependencies of target glpclview
[ 57%] Building C object examples/CMakeFiles/glpclview.dir/glpclview.c.o
Linking C executable ../bin/glpclview
[ 57%] Built target glpclview
Scanning dependencies of target glview
[ 61%] Building C object examples/CMakeFiles/glview.dir/glview.c.o
Linking C executable ../bin/glview
[ 61%] Built target glview
Scanning dependencies of target hiview
[ 66%] Building C object examples/CMakeFiles/hiview.dir/hiview.c.o
Linking C executable ../bin/hiview
[ 66%] Built target hiview
Scanning dependencies of target regtest
[ 71%] Building C object examples/CMakeFiles/regtest.dir/regtest.c.o
Linking C executable ../bin/regtest
[ 71%] Built target regtest
Scanning dependencies of target regview
[ 76%] Building C object examples/CMakeFiles/regview.dir/regview.c.o
Linking C executable ../bin/regview
[ 76%] Built target regview
Scanning dependencies of target tiltdemo
[ 80%] Building C object examples/CMakeFiles/tiltdemo.dir/tiltdemo.c.o
Linking C executable ../bin/tiltdemo
[ 80%] Built target tiltdemo
Scanning dependencies of target fakenect
[ 85%] Building C object fakenect/CMakeFiles/fakenect.dir/fakenect.c.o
Linking C shared library ../lib/fakenect/libfreenect.so
[ 85%] Built target fakenect
Scanning dependencies of target record
[ 90%] Building C object fakenect/CMakeFiles/record.dir/record.c.o
Linking C executable ../bin/record
[ 90%] Built target record
Scanning dependencies of target freenect_sync_static
[ 95%] Building C object wrappers/c_sync/CMakeFiles/freenect_sync_static.dir/libfreenect_sync.c.o
Linking C static library ../../lib/libfreenect_sync.a
[ 95%] Built target freenect_sync_static
Scanning dependencies of target cppview
[100%] Building CXX object wrappers/cpp/CMakeFiles/cppview.dir/cppview.cpp.o
Linking CXX executable ../../bin/cppview
[100%] Built target cppview

Last question, I am supposed to do a make install after cmake and make?

Thank you all for your help,

Exomène

leokoppel commented 11 years ago

@Exomene Yes. If you don't run make install or manually tell the system where to look for the library, it's not going to find it. It will find the old version. See this: http://tldp.org/LDP/LG/current/smith.html on the usual build process (though in this case cmake replaces the configure script) and this: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html for details on shared libraries .

csotiriou commented 11 years ago

Is there any news on the implementation of support of model 1473? Is there anything we can use right now that actually works, until official support comes? I have seen suggestions in this thread, but I haven't got the time to test all of them. Yesterday, I found out that https://github.com/dudefellah/libfreenect.git does not work for me..

Has anyone been able to run openKinect with 1473 using any variant?

tong commented 11 years ago

yes, @dudefellah version works for me on 1473, not the glview and i have to re-plug the kinect after each try.

csotiriou commented 11 years ago

Maybe it's because the device's sensors are not properly closed after you try. I noticed that, too.

Anyone has any news on wether any fix will be implemented or if any effort is made by the official OpenKinect? So far it seems OpenNI is the only viable option, and even then, the newest 2.0 version needs the Kinect SDK ( = does not support Linux and OS X )

lucky13bbq commented 11 years ago

I also got it working like dudefellah by editing cameras.c, but I removed attempt to use the motor differently. Here are my 2 small changes:


diff --git a/include/libfreenect.h b/include/libfreenect.h
index 4dfb6b1..ceb9111 100644
--- a/include/libfreenect.h
+++ b/include/libfreenect.h
@@ -57,7 +57,7 @@ extern "C" {
 /// and motor support while letting OpenNI have access to the cameras.
 /// If a device is not supported on a particular platform, its flag will be ignored.
 typedef enum {
-   FREENECT_DEVICE_MOTOR  = 0x01,
+   FREENECT_DEVICE_MOTOR  = 0x00,
    FREENECT_DEVICE_CAMERA = 0x02,
    FREENECT_DEVICE_AUDIO  = 0x04,
 } freenect_device_flags;
diff --git a/src/cameras.c b/src/cameras.c
index 7886a33..915fd29 100644
--- a/src/cameras.c
+++ b/src/cameras.c
@@ -905,7 +905,7 @@ static int freenect_fetch_zero_plane_info(freenect_device *dev)

    int res;
    res = send_cmd(dev, 0x04, cmd, 10, reply, 322); //OPCODE_GET_FIXED_PARAMS = 4,
-   if (res != 322) {
+   if (res != 322 && res != 334) {
        FN_ERROR("freenect_fetch_zero_plane_info: send_cmd read %d bytes (expected 322)\n", res);
        return -1;
    }
dudefellah commented 11 years ago

Yeah there's a number of ways to achieve the same ends. I still think https://github.com/renewagner/libfreenect/commit/06e48e5d4328f96bf61613953bab2f45a459a1fb is a better option right now. There's still some stuff missing, of course. The stream seems to go out of sync quite easily. I'm guessing there's slight variations on what's being sent back and forth but I haven't had a whole lot of time lately, so I haven't really tried to figure it out. Whatever's changed in the data stream is causing glview to be a little jerky as the video stream is resynced.

I saw a thread a little while ago in my email (I can't seem to find it on github) referring to these: http://answers.ros.org/question/12876/kinect-for-windows/ http://answers.ros.org/answers/35351/revisions/ That might have a little more of what we're looking for on getting 1473 to work.

ghost commented 11 years ago

Hi! In my case, i tried dudefellas solution - the code of renewagner - but it still not worked. I got the error

send_cmd: Data buffer is 322 bytes long, but got 334 bytes
freenect_fetch_zero_plane_info: send_cmd read 334 bytes (expected 322)
freenect_camera_init(): Failed to fetch zero plane info for device
Could not open device

Therefore I simply changed the code of camera.c like this

switch(dev->hwrev) {
    case HWREV_XBOX360_0:
-      expected_len = 322;
+      expected_len = 334;
      struct_offset = 94;
      break;

And it works.

BTW, with OpenNI-1.5. I have no problems to run model 1473.

csotiriou commented 11 years ago

Yes. I think OpenNI is the only official viable solution for now.

ghost commented 11 years ago

Hi, I found this page http://learn.adafruit.com/hacking-the-kinect/verify-the-vid-and-pid

I followed the examples and my result is Modell 1414

Xbox NUI Camera:
                  Product ID: 0x02ae
                  Vendor ID: 0x045e  (Microsoft Corporation)
                  Version:  1.0b
                  Serial Number: A00364803145051A
                  Speed: Up to 480 Mb/sec
                  Manufacturer: Microsoft
                  Location ID: 0xfd133000 / 8
                  Current Available (mA): 500
                  Current Required (mA): 16
                Xbox Kinect Audio, © 2011 Microsoft Corporation. All rights reserved.:
                  Product ID: 0x02ad
                  Vendor ID: 0x045e  (Microsoft Corporation)
                  Version: 1,00
                  Serial Number: A44884B05001051A
                  Speed: Up to 480 Mb/sec
                  Manufacturer: Microsoft
                  Location ID: 0xfd131000 / 7
                  Current Available (mA): 500
                  Current Required (mA): Unknown (Device has not been configured)
                Xbox NUI Motor:
                  Product ID: 0x02b0
                  Vendor ID: 0x045e  (Microsoft Corporation)
                  Version: 1,07
                  Speed: Up to 12 Mb/sec
                  Manufacturer: Microsoft
                  Location ID: 0xfd132000 / 6
                  Current Available (mA): 500
                  Current Required (mA): 100

Model 1473

Xbox NUI Camera:
                  Product ID: 0x02ae
                  Vendor ID: 0x045e  (Microsoft Corporation)
                  Version: 2,05
                  Serial Number: 0
                  Speed: Up to 480 Mb/sec
                  Manufacturer: Microsoft
                  Location ID: 0xfd132000 / 7
                  Current Available (mA): 500
                  Current Required (mA): 16
                Xbox Kinect Audio, © 2011 Microsoft Corporation. All rights reserved.:
                  Product ID: 0x02ad
                  Vendor ID: 0x045e  (Microsoft Corporation)
                  Version: 1,00
                  Serial Number: A70777X03897236A
                  Speed: Up to 480 Mb/sec
                  Manufacturer: Microsoft
                  Location ID: 0xfd131000 / 6
                  Current Available (mA): 500
                  Current Required (mA): Unknown (Device has not been configured)

Truly no motor.

karlun commented 11 years ago

Sorry if this is off topic but I got the impression that part of the problem with the new model is to identify it as such. The vendor and product ids will not change between models, so also bcdDevice needs to be included when searching for the device, either to stop the driver from trying to interact with a model that it cannot support or to actually change the driver's behaviour depending on the model. The bcdDevice value for the camera changes from 1.0b to 2.05 between model 1414 and 1473. It does not change for the audio device, though.

wizgrav commented 11 years ago

We can probably identify the new kinect for xbox by checking the .iSerialNumber string returned from the usb descriptor. Can someone with the new kinect check it out with something like:

unsigned char string_desc[256];
res = libusb_get_string_descriptor_ascii(dev->usb_cam.dev, desc.iSerialNumber, string_desc, 256);
printf("*RES=%d, DESC=%s*\n",res,string_desc);

This should go in usb_libusb10.c > fnusb_open_subdevices() right before

if (desc.idProduct == PID_NUI_CAMERA) {

Please paste the results so we can push the detection fix in renewagner's fork(along with the USB3 fix to make it current).

As for the raspberry I gave up on it a long time ago, the problem lies on the USB implementation on the board itself. It drops all packets from the cameras and the rasp devs seem unable to fix it in software so you should better consider other solution. The pandaboard and beagleboard work nicely, I'm also waiting for a cubieboard and beaglebone to arrive and will test there as well

karlun commented 11 years ago

dev->usb_cam.dev is explicitly set to NULL in all versions of libfreenect I currently have clones of and I cannot see any line where that value would change. With the old Kinect device it crashes when retrieving the string and with the new model I get "RES=-2, DESC=7", which I assume is a fail.

wizgrav commented 11 years ago

Sorry it's getting initialized in line 197, at least in the official tree. Indeed a -2 libusb response means invalid param.

res = libusb_open (devs[i], &dev->usb_cam.dev);
if (res < 0 || !dev->usb_cam.dev) {
                    FN_ERROR("Could not open camera: %d\n", res);
                    dev->usb_cam.dev = NULL;
                    break;
}

try putting the printf right after that (but be careful not to place it inside the #ifndef _WIN32 if you're building on windows)

karlun commented 11 years ago

Yep, that worked better. Not much information there, through: "RES=16, DESC=0000000000000000". (With the old Kinect I get "RES=16, DESC=A00366A01397044A")

wizgrav commented 11 years ago

Thanks. That lack of information there is exactly what we need. I remember drew saying that the K4W also doesn't expose a desc so we should be able to catch that and set the correct zero_plane command just by that. I'll write a preliminary patch for the mainline tree. Of course I would appreciate if more people test with the printf code listed above to make sure that this assumption is correct

karlun commented 11 years ago

The bcdDevice (device release number in binary-coded decimal), however, is unique for both devices. I tried

printf("BCD=%d\n",res,desc.bcdDevice);

which gives me "BCD=517" for the new device and "BCD=267" with the old device.

wizgrav commented 11 years ago

You have two arguments and only one placeholder in the format string of that printf but I'm sure it's just a typo. I'll check in this order (IF PID IS K4XBOX) -> (IS OLD BCD) If these fail(a new bcd or something) it will default to the K4W setting in which the motor will be auto disabled, for now

ghost commented 11 years ago

Hi,

i tried with the new one. But i get

*RES=0, DESC=*

Maybe i did something wrong? My code looks like this

if (nr_cam == index) {
unsigned char string_desc[256];
res = libusb_open (devs[i], &dev->usb_cam.dev);
if (res < 0 || !dev->usb_cam.dev) {
    FN_ERROR("Could not open camera: %d\n", res);
    dev->usb_cam.dev = NULL;
    break;
}
printf("*RES=%d, DESC=%s*\n",res,string_desc);

And ran ./glview

karlun commented 11 years ago

Yep, typo. I added bcdDevice to the original print-out and tried to clean-up the code while pasting it in the message. Should have been:

unsigned char string_desc[256];
res = libusb_get_string_descriptor_ascii(dev->usb_cam.dev, desc.iSerialNumber, string_desc, 256);
printf("*RES=%d, DESC=%s*, BCD=%d\n",res,string_desc,desc.bcdDevice);
wizgrav commented 11 years ago

@m8n You forgot this

res = libusb_get_string_descriptor_ascii(dev->usb_cam.dev, desc.iSerialNumber, string_desc, 256);

This is needed to fill string_desc with the serial number and should go right before the printf. We'll probably won't have to check the serial as the bcd seems safer. Nevertheless please post your results to check if indeed the serials are the same among the new Kinects

ghost commented 11 years ago

Hi, @wizgrav yes, sry, my fault. after many problems (like "no device found" -.-' ), my result is

*RES=16, DESC=0000000000000000, BCD=517*

greetings

edit: for the record: I work with Kinect model 1473

wizgrav commented 11 years ago

Please check https://github.com/wizgrav/libfreenect with the new kinect(and K4W if available)

ghost commented 11 years ago

sry, that's similar to https://github.com/renewagner/libfreenect/commit/06e48e5d4328f96bf61613953bab2f45a459a1fb

wizgrav commented 11 years ago

@m8n I've added some debugging please check it out again and paste the output

karlun commented 11 years ago

I get a lot of debug output from my own software, but I believe yours is this line, right? With new Kinect: "desc.bcdDevice: 517, ctx->enabled_subdevices: 2, ctx->zero_plane_res: 334" With old Kinect: "desc.bcdDevice: 267, ctx->enabled_subdevices: 3, ctx->zero_plane_res: 322" Works with both devices! Great work!

Both devices take much longer to start producing usable data, though. With the new Kinect I get a lot of "Invalid magic ffff", but not with the old device. Still it takes several seconds before the image looks right. This is with my own software, through, since I have not been able to compile the examples yet.

karlun commented 11 years ago

Ignore my previous statement about the delay of usable data. That problem seems to have gone away.

wizgrav commented 11 years ago

@karlun Thanks for the feedback. I'm pretty certain that the detection will work for K4W as well. The motor is disabled for the newer versions for now. I'll do a pull request to main and start working on adding motor and led support for all kinects as well. Drew had posted a proof concept so I'll start from that. Is xtion support of any interest to anyone?