This page is for documentation of libfreenect.
=====Installation ===== First install CentOS6. update and turn off selinux/firewall.
Install EPEL.
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm</code>
Then do the following: adopted from here.
sudo yum install git cmake gcc gcc-c++ libXi libXi-devel libXmu libXmu-devel freeglut freeglut-devel libusb1-devel ImageMagick ffmpeg
cd /tmp
mkdir kinect
cd kinect
git clone git://github.com/OpenKinect/libfreenect.git
cd libfreenect
mkdir build
cd build
ccmake ..
Inside the ccmake editor, press c to configure
Using the arrow keys, move to line with LIBUSB_1_INCLUDE_DIR
Press enter to edit the line, then change it to /usr/include/libusb-1.0
Press enter when finished editing
Press g to generate and exit
cmake ..
make
sudo make install
Next you have to add the user that will run the executables to the video group in /etc/group. Then add the following to /etc/udev/rules.d/66-kinect.rules
#Rules for Kinect ####################################################
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ae", MODE="0660",GROUP="video"
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02ad", MODE="0660",GROUP="video"
SYSFS{idVendor}=="045e", SYSFS{idProduct}=="02b0", MODE="0660",GROUP="video"
### END #############################################################
Now there will be a set of binaries in /tmp/kinect/libfreenect/build/bin. Execute glview and make sure it is working correctly. You should see a video of the RGB and the depth.
cd /tmp/kinect/libfreenect/build/bin
sudo ./glview
Once this is known to work you have to edit some source code to get the binaries to only output the infrared file. The reason to do this is to have a lower amount of transfered data through the USB bus and thus avoid saturation. In order to do this you have to rebuild the libfreenect packages for record. redownload the git repository and edit the file kinect/libfreenect/fakenect/record.c. You want to comment out all of the body of the functions "snapshot_accel" and "rgb.cb". Now make the packages as above and the record binary will only save the pgm (depth) data.
#!/usr/bin/python
import numpy
from subprocess import Popen, PIPE
import time
start = time.clock()
#list folder contents and save output to the list lsall
ls = Popen(["ls"], stdout=PIPE)
lsall = ls.communicate()[0].decode("utf-8").split()
#search through lsall and make a new list of enteries with "pgm" in the name
#exits if no file with that name is in the folder
pgmlist=[] # make lis to store search results
for i in range(len(lsall)):
if lsall[i].find("pgm") != -1: #TODO: should test for .pgm extension
pgmlist.append(lsall[i])
if len(pgmlist)==0: # exception: pgm not found exits
print("No PGM files found. Exiting!")
exit() #TODO make this a real exception
pgmlist.pop()
# do the actual conversion of the pgm to numbers (0-2047)
filelist = open("filelist","w") #file stores a list of generated data files
for i in range(len(pgmlist)):
filename=pgmlist[i]
with open(filename, 'r') as infile:
header = infile.readline()
width, height, maxval = [int(item) for item in header.split()[1:]]
image = numpy.fromfile(infile, dtype=numpy.uint16).reshape((height, width))
numpy.savetxt(pgmlist[i][:-4]+".csv",image,fmt='%d , ')
filelist.write(pgmlist[i][:-4]+".csv \n")
print ("file: %s -> %s" %(pgmlist[i],pgmlist[i][:-4]+".csv"))
filelist.close()
stop=time.clock()
print ("conversion time (seconds): %f " %(stop-start))