Using Skeltrack with Kinect on Fedora 18

Skeltrack is a skeleton tracking library developed by Igalia’s Joaquim Rocha. Developed as a FOSS library, it is very well integrated with Gnome technologies, an example of which is the capability to control Gnome desktop using Skeltrack.

Here, the steps needed to get Skeltrack up and running on your fresh F18 system is detailed. First, install the dependencies using yum:

sudo yum install libfreenect* autoconf automake gobject-introspection-devel gtk-doc */cairo.h

Now we are ready to begin the actual installation. Since, libfreenect lacks the motor control capabilities, GFreenect was developed at Igalia. It is a dependency for Skeltrack, so we need to install it first using the following steps:

  • sudo updatedb
  • export LD_LIBRARY_PATH=/usr/local/lib/
  • export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
  • git clone https://github.com/elima/GFreenect.git
  • cd GFreenect && libtoolize -v –copy –install
  • aclocal
  • autoconf
  • ./autogen.sh
  • ./configure
  • make
  • sudo make install

With this, GFreenect installation should be done. You can test the installation by plugging in Kinect and executing:

  • cd <PATH_TO_GFreenect_FOLDER>/examples
  • python2.7 test*.py

You should get something like this:

GFreenect Demo

Now to install Skeltrack, similar steps are needed:

  • sudo updatedb
  • export LD_LIBRARY_PATH=/usr/local/lib/
  • export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
  • git clone https://github.com/joaquimrocha/Skeltrack.git
  • cd Skeltrack && libtoolize -v –copy –install
  • aclocal
  • autoconf
  • ./autogen.sh
  • ./configure
  • make
  • sudo make install

Thats it! Skeltrack would be up and running on your system :). To test, run:

  • cd <PATH_TO_Skeltrack_FOLDER>/examples
  • ./test-kinect.o

These steps should be enough to get us ready to use the amazing Skeltrack library.. In case you’re even more eager to play around with Kinect and want to show off your gesture skills, install and use Skeltrack-Desktop-Control :

And we’re done. To run the software:

  • cd <PATH_TO_Skeltrack_FOLDER>/src
  • ./skeltrack-desktop-control

Happy Kinect hacking! 🙂

Set up samba share on Fedora 18

With the advent of samba4, seems a few stuff have changed (havent really gone through the changes list). Till now used to copy previous Fedora installation’s smb.conf file. However, doing the same didnt really help creating the share.

Reverting back to the original smb.conf file (ALWAYS, ALWAYS back up conf files before making any changes!), added the hostname restriction as had mentioned in one of the previous posts. Once done, added in the “Share Definitions” section shared folder information:

[Share_Name]
comment = Shared Folder
path = <location>
read only = no
; browseable = yes
guest ok = yes

This step can also be achieved using a gui tool : system-config-samba (sudo yum / dnf install system-config-samba).

Next comes SELinux policy settings. Either using the gui policycoreutils-gui (sudo yum / dnf install policycoreutils-gui) or through terminal set the following Booleans:

  • su
  • setsebool -P allow_smbd_anon_write=1

For full read / write access :

  • setsebool -P samba_export_all_rw on

For only read access :

  • setsebool -P samba_export_all_ro on

and Finally relabeling for the shared folder:

  • chcon -t samba_share_t <path_to_shared_folder>/

And we are ALMOST done. Just install samba-client and set samba password for the user:

  • smbpasswd -a <username>

Finally, restart / enable smb.service and nmb.service to ensure samba server starts at boot from next time:

  • systemctl enable smb.service
  • systemctl enable nmb.service
  • systemctl restart smb.service
  • systemctl restart nmb.service

Thats it! Enjoy samba shares on Linux and Windows from a fresh, moowing F18 system..

P.S : (1) also check if firewall allows samba connections, i.e., Firewall > Persistent Configuration > check on samba.

(2) change the permissions of the folder you want to share, i.e., chmod -R a+rwx folder_location/ .

Nice features in TeXLive 2012

Tried TeXLive 2012 in Fedora 18 Beta today. Till now, whenever needed to create / edit tex files, used to install TeXMaker, and it pulled in most of the TeXLive dependencies. Unfortunately, that didnt happen this time around.

dvips, psfrags.sty and cmr10.tfm didnt get installed leading to errors like : Error could not start command, dvips: couldnt find header file : psfrags.pro and dvips: i can’t find cmr10.tfm respectively, when trying to compile a tex file. It was then that i found a really convenient feature introduced in TeXLive 2012.

To install any of the above missing TeXLive packages (or for that matter, any missing TeXLive package), all that we need to do is :

sudo yum install ‘tex(dvips)’

sudo yum install ‘tex(psfrag.sty)’

sudo yum install ‘tex(cmr10.tfm)’

(Please substitute ‘yum install’ with ‘apt-get install’ if you’re using a Debian-derivative)

And we are done! Easy and so convenient.. helps avoid frantically searching for the missing packages.. Kudos to the TeXLive developers. But why the packages were missing in the first place, is something that am trying to figure out.

Revisiting Nvidia Driver and CUDA Toolkit install in Fedoa 17/ CentOS 6

After having gone through a lengthy set of instructions for installing Nvidia binary driver and CUDA Toolkit on CentOS, I woke up one day to kernel updates and to my horror post restart, no login screen! Rebooting into to the older kernel worked fine, offering a much needed solace in the midst of thoughts of all the effort having gone down the drain.

It didnt take me much time to realize the culprit: kernel-source-path argument while executing the binary installer (step #7 in previous post). Did this imply I had to manually reinstall the driver everytime the kernel got updated!

Not wanting to waste time repeating mechanical work, I started googling, and thanks to a tuxgeek post, realized a much simpler, hassle free way of managing the Nvidia driver. The steps are as follows:

The install step above can be done in GUI by double clicking on the downloaded .rpm file(s). Now, all that is needed are the following yum commands in the terminal:

  • sudo yum update
  • (Fedora 17) sudo yum install kmod-nvidia xorg-x11-drv-nvidia-libs
  • (CentOS 6) sudo yum install kmod-nvidia nvidia-x11-drv

and one more step to blacklist the open source driver nouveau from loading:

  • su -c        # log in as root
  • echo “blacklist nouveau options nouveau modeset=0” > /etc/modprobe.d/blacklist-nouveau.conf
  • exit         # exit from root environment

Thats it!! 4 lines in terminal instead of the first 9 bulleted steps in the previous post! Kudos to the maintainers of these rpms 🙂 .. But the question remains, does this handle kernel updates. Well, post the availability of a newer kernel, boot into the previous kernel till the time an update for kmod-nvidia arrives. Once its updated, your newer kernel will boot without any fuss!

Unfortunately, the CUDA toolkit steps are still to be followed as given in the previous post. But compared to the driver install, they are practically nothing..

NOTE: CentOS users may have to follow the vga=ask step as given in previous post to see plymouth at boot. Fedora’s “charge” plymouth works out of the box!

UPDATE: As pointed out by Jim, the kmod-nvidia package can be substituted with akmod-nvidia to get uninterrupted Nvidia driver usage even on an updated kernel, thus reducing the wait time to boot to the new kernel to a simple restart, rather than a day or two till the kmod-nvidia package is released in RPMFusion / ELRepo.

Restrict samba share access to certain IPs / hosts

Samba provides an easy (well.. almost) way of sharing files and folders between Linux and Windows. In certain situations, it may be required that a certain system allows both write and read permissions to some folders. Now imagine a situation where the systems are in a large subnet: an unrestricted write access gives anyone on the subnet free access to your data (maybe sensitive too). Can something be done so that only certain IPs / hosts in the subnet  get access to your system?

Well, it turns out, Samba developers have given it a good thought.  First of all, edit /etc/hosts and add aliases in the following format:

IP                                alias_name

Say you added 3 aliases for 3 different hosts (alias1, alias2, alias3). This step ensures you dont have to remember the actual IP of the hosts, and those can be referred to by their alias names. Now, edit /etc/samba/smb.conf, and add the following to the [global] section:

  • hostname lookups = yes
  • hosts allow = alias1 alias2 alias3

And its done.. Restart samba server for the changes to take effect:

  • sudo systemctl restart smb.service
  • sudo systemctl nmb.service

Now only the aliased IPs will get access to your samba share, while the rest of the subnet will be blocked out!

MATLAB: Using ANN library wrapper in Windows XP

ANN (Approximate Nearest Neighbours) is an extremely useful library when working with any type of application where the properties of data points are influenced by their neighbours. The MATLAB MEX-wrapper for the same provided by Shai Bagon, along with the patches, compiles effortlessly in Linux (have tried on F16 and F17). However, making the same work in Windows turned out to be quite an effort. First, the MATLAB inbuilt compiler for Windows (lcc) continuously kept crashing whenever I tried executing the library, and second, the lack of pre-existing solid C/C++ compiler made things difficult.

After searching on the net for free and supported compilers for MATLAB R2010a, I first tried Open Watcom, but it gave too many errors during compilation of the mex-wrappers.  Then it was the turn to check out MS Visual C++ Express Edition. Tried on a friend’s system having MS-VC++ 2010, and it too gave quite a few errors during compilation. Thought to try out MS-VC++ 2008, and guess what, it worked out of the box and the mex-wrapper compiled with quite an ease 🙂 . Wonder why MS-VC++ 2010 created issues..

Install Nvidia Driver and CUDA Toolkit on CentOS 6

( Update: have posted a MUCH simpler method of driver install. Steps for CUDA toolkit install have to be followed as given in this post, i.e. , bulleted step # 10 – 19 )

Although the topic has been addressed succinctly in a CentOS forum post, there are certain things like plymouth configuration post Nvidia driver install, etc. which I felt needed to be jotted down for reference. So, here we go describing the Nvidia CUDA toolkit installation on a CentOS system:

  • Download the appropriate toolkit, driver and SDK from Nvidia’s website.
  • RHEL, and its derivatives come with the open source Nvidia driver called nouveau. Before installing Nvidia drivers, we need to ensure nouveau drivers dont get loaded. For this, append the following in the line starting with ‘kernel’ in the file /etc/boot/grub.conf:

rdblacklist=nouveau nouveau.modeset=0

  • Install the Development Tools and Development Libraries group packages, and a few extra packages listed below:

sudo yum groupinstall ‘Development Tools’ ‘Development Libraries’

sudo yum install kernel-devel gcc-c++ freeglut freeglut-devel libX11-devel mesa-libGLU-devel libXmu-devel libXi-devel gcc* compat-gcc* compat-glibc* compat-lib*

  • Restart the system. Upon restart, you’ll see that the resolution of the display would have gone for a toss. Thats due to blacklisting the nouveau driver, and is a sign that we are on track! Open terminal and type the following to goto non-GUI mode (called, runlevel 3):

sudo init 3

  • Above command takes us to text mode. Change directory to /usr/src/kernels/ and note down the complete path of the kernel folder present. In our scenario, it shows up as:

/usr/src/kernels/2.6.32-220.13.1.el6.x86_64/

  • Change directory to the folder containing the downloaded files from Nvidia’s website (say ~/Downloads). Mark the 3 downloaded files as executables:

cd ~/Downloads

chmod a+x NV*; chmod a+x cuda*; chmod a+x gpu*

  • Now finally, we are ready to run the installer. First is the Nvidia Driver install :

sudo sh NVIDIA-Linux-x86_64-295.20.run –kernel-source-path=/usr/src/kernels/2.6.32-220.13.1.el6.x86_64/

  • NOTE : there’s a double minus sign before the word kernel above. During the above install, accept the licence agreement shown. Reboot upon completion:

sudo reboot

  • You’ll notice that the GUI resolution is back to normal, indicating successful Nvidia driver install. Now, cudatoolkit has to be installed.
  • Open terminal and change directory to ~/Downloads. Run the cudatoolkit*.run file:

sudo sh cudatoolkit_4.0.17_linux_64_rhel6.0.run

  • During the install, you’ll be asked to supply installation path. Enter the default path itself (/usr/local/cuda).
  • Once completed, few more steps are needed, like adding /usr/local/cuda to default path environment variable, etc. :

sudo nano /etc/ld.so.conf.d/cuda.conf

  • Add the following lines to the above created file :

/usr/local/cuda/lib64
/usr/local/cuda/lib

  • Save the above file by pressing Ctrl+x, followed by ‘y’ and pressing Enter. Now run:

sudo ldconfig

  • For adding cuda install path to enviroment path variable, edit ~/.bash_profile file using a text editor (say, nano ~/.bash_profile) :

export CUDA_INSTALL_PATH=/usr/local/cuda
export PATH=($PATH: /usr/local/cuda/bin)
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
export PATH=($PATH: /usr/local/cuda/lib)

  • Finally, gpucomputingsdk needs to be installed. For that :

sh gpucomputingsdk_4.0.17_linux.run

  • During the install , you’ll be asked for install path. Keep in mind that the sdk can take around 400-500MB. Say, we install it to ~/Documents/NVIDIA_GPU_Computing_SDK.
  • Once done, we need to compile the files in the SDK:

cd ~/Documents/NVIDIA_GPU_Computing_SDK/C/

make

  • To check whether everything is working fine, we’ll run the deviceQuery file, provided by the SDK just installed:

cd ~/Documents/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/

./deviceQuery

  • You should see something similar to what is shown at this link .

Congrats for successfully installing the Nvidia driver and the cudatoolkit on your CentOS system. I know, things should be much simpler. I wish someday Nvidia open-sources their drivers and CUDA toolkit to make things simpler for Linux enthusiasts. All that is left now, is to fix the ugly white-blue scrolling bar that shows up instead of the beautiful Plymouth at boot.

  • Reboot system. At the grub prompt, press ‘e’ against the first item on the grub menu to edit its kernel arguments (this mode is called kernel edit mode).
  • Out the the three lines being shown (starting with : root; kernel; initrd ), scroll to kernel line and press ‘e’ again. Type in the following at the end of that line:

vga=ask

  • Press Enter after typing the above and press ‘b’. You’ll see a tabulated list of keywords against several screen-resolutions. Note down the number being shown against the  most appropriate screen resolution. Say, the number is 361. Now, reboot system. Again, enter the kernel edit mode described in the previous two list items. The only difference being that instead of vga=ask, enter vga=0x361. Now press ‘b’ and you’ll see the beautiful Plymouth back in its glory!
  • To make this change permanent, open terminal and open /boot/grub/grub.conf as sudo (sudo nano /boot/grub/grub.conf).
  • Find the line saying ‘kernel’ against your most recent kernel version and add vga=0x361. Save the file (Ctrl+x, y, Enter)

Plymouth theme will now show up everytime that you’ll reboot. Enjoy!

MATLAB: Running codes in mixed OS environment

Ever faced the problem of running executables in a MATLAB installation on Linux. I frequently use an executable file (.exe) provided by an eminent research lab, but the linux enthusiast that I am, shifting to Windows just for running this file is out of the question! So, how to solve this issue!

Well, you need access to either a system running Windows at your workplace, or have a virtual Windows installation in VirtualBox. Set up ssh via cygwin (refer SSH via CYGWIN) on such a system and also make sure to have a password-less SSH login enabled (refer ssh autologin) between the Linux and Windows systems.

Once this is done and given the fact that such a Windows environment is up and running, all you have to do through the MATLAB command prompt is:

system(‘ssh username@IP_of_windows command1;command2’);

where : command1 and command2 are the things you want to execute on that system. For e.g: in my scenario, i have already put the .exe (say: test.exe) in the cygwin home folder (C:/cygwin/home/<username>/) on the Windows system. Now, i just run:

system(‘ssh username@IP_of_windows ./test.exe’);

You can use few more ssh/scp via system command calls in MATLAB to copy back & forth the data. Thats it!