Friday, July 27, 2012

Tips and Tricks for Linux

I am going to put down useful commands for Linux here and continuously update it. If you want to contribute to this page, please post your suggestion in comments.
1) Installing from a .iso file
Easiest thing to do is to mount the .iso in a tmp location and install it from there.
sudo mkdir /tmp/matlab 
sudo mount /<path to .iso file>/matlab.iso /tmp/matlab -t iso9660  -o loop=/dev/loop0
2) Using FFmpeg to break a video into parts
ffmpeg -i STOPS_20111214_CR1_02_C5.mov -sameq -ss 00:00:00 -t 00:00:30 videopart1.mov

So this code takes in a video named STOPS_20111214_CR1_02_C5.mov, uses all the parameters of video such as framerate, bit rate to make a new video and extracts all the frames from start time of 0 seconds to end time of 30 secs and writes it as videopart1.mov
3) Overcoming too many threads error of ffmpeg
http://crazedmuleproductions.blogspot.com/2007/10/multithreading-in-ffmpeg-and-mpstat.html

Wednesday, June 27, 2012

Renaming Files in a folder using Shell in Linux

I work with a lot of different image dataset and find it helpful if the image files are named in a particular order that I want. Below is the script that will convert all the 'png' files in a folder into frame_%05d.png format.

#!/bin/sh
prefix=$1

count=1
for f in *.png; do
    nn=`printf %05d $count`
    mv "$f" "frame_$prefix$nn".png
    count=`expr $count + 1`
done

Save this script as a .sh file (maybe frameconvert.sh) and then you can run it from command prompt using 'sh frameconvert.sh' . You can modify this script for your own purposes.

Friday, June 8, 2012

Getting the Kinect to Work

This post is about how I got kinect to work on my machine which is Ubuntu 10.04 Lucid using ROS
What didn't Work:
I was trying to get Kinect for Windows working on my system but apparently it's not supported by Open NI drivers. Find the discussion about it here: http://answers.ros.org/question/12876/kinect-for-windows/ . I then installed a Windows 7 virtual environment using VMplayer. Microsoft released SDK for windows which is pretty cool. You can download the SDK from here. I was really hoping for it to work but came to know that current version of SDK doesn't support virtual environments yet. You can find some discussion here. http://social.msdn.microsoft.com/Forums/br/kinectsdk/thread/86528a22-0643-4a1f-819f-8125d7668a68 I didn't want to do a dual boot and started exploring other options. 
What works:
Open NI does support the older Xbox 360 sensor, which we had in the lab. I tried it out and it worked perfect (close to). Major steps are outlined as follows
1) Install ROS. I installed fuerte for which you can find the installation directions here for Ubuntu.
2) Install Open NI drivers using apt-get install ros-fuerte-openni-kinect or follow the directions here.

That's it and you are done. To launch Xbox 360 sensor use
 roslaunch openni_launch openni.launch . You will see in command window
 [ INFO] [1339168119.174802439]: Number devices connected: 1
[ INFO] [1339168119.174938804]: 1. device on bus 002:21 is a Xbox NUI Camera (2ae) from Microsoft (45e) with serial id 'B00367200497042B'
If you want to visualize the rgb image, you can use 
rosrun image_view image_view image:=/camera/rgb/image_color
For depth image use
rosrun image_view disparity_view image:=/camera/depth_registered/disparity

If you want to save data using kinect, follow the instruction here.
Additionally you can install rviz which is visualization utility with ros using
sudo apt-get install ros-fuerte-visualization 
 You can visualize RGB image, depth image, point cloud using Rviz.  
Some more things to do are to import this data into MATLAB by following the tutorial here .
Also I want to use PCL  because they have pretty neat things in there. 

If you have any questions or feedback, please comment below. If you are interested in my work follow my website (just beginning to make it)