Monday, February 7, 2011

Using Fakenect


I was trying to browse the Internet for how to use Fakenect. But couldn't find a good straightforward description. After it got working for me, I thought I would myself write one :)

What is Fakenect
In essence, it's a way to get Kinect applications working without actual physical Kinect available with you. You fake the Kinect by replaying a pre-recorded Kinect capture.

(1) Build Library
assuming that you have the OpenKinect source code, to first build the fakenect library, you would just "cmake ." and then "make" in the OpenKinect directory (the one I have is "OpenKinect-libfreenect-2ea3ebb"). Now you must have a libfreenect.so at OpenKinect-libfreenect-2ea3ebb/fakenect/lib/fakenect/.

(2) Record
Now, to record, just go to OpenKinect-libfreenect-2ea3ebb/utils/ And run "./record some_directory_name". A new directory name some_directory_name will be created as "/utils/some_directory_name", all the record data will be dumped there. While the record program is running, you can stop recording by hitting cntrl+C.
Now, you should have a record-dump in the specified directory.

(3)Run Your Recording
Say, you want to run the glview program now, so go to the OpenKinect-libfreenect-2ea3ebb/examples folder and run the following:
LD_PRELOAD="/usr/local/lib/fakenect/libfreenect.so" FAKENECT_PATH="../utils/myself/" ../bin/glview.

That's it, you should see your capture being replayed now.

3 comments:

  1. hi,
    i'm roberto i was looking to ur guide and i've done the same but i have some problems with "make": i havent any .so file in lib/fakenect and no "utils" folder is created...any idea?
    tenx in advance

    ReplyDelete
  2. sorry...
    too few info, probably.
    i have this massage:


    [ 50%] Building C object CMakeFiles/fakenect.dir/fakenect.o
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c: In function ‘freenect_process_events’:
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:187: error: ‘FREENECT_RESOLUTION_MEDIUM’ undeclared (first use in this function)
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:187: error: (Each undeclared identifier is reported only once
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:187: error: for each function it appears in.)
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c: At top level:
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:253: error: expected ‘;’, ‘,’ or ‘)’ before ‘mode’
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:260: error: expected ‘;’, ‘,’ or ‘)’ before ‘mode’
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:267: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘freenect_find_video_mode’
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:276: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘freenect_find_depth_mode’
    /home/roberto/Scrivania/universita/tesi/openkinect/OpenKinect-libfreenect-dbfd4ce/fakenect/fakenect.c:304: error: expected declaration specifiers or ‘...’ before ‘freenect_device_flags’
    make[2]: *** [CMakeFiles/fakenect.dir/fakenect.o] Errore 1
    make[1]: *** [CMakeFiles/fakenect.dir/all] Errore 2
    make: *** [all] Errore 2

    ReplyDelete
  3. If someone wonder why ./record out doesnt work for him/her..
    After running cmake and make the executable file is called fakenect-record
    And you run it like : sudo fakenect-record out

    ReplyDelete