Sunday, June 19, 2011

A review on "OpenCV 2 Computer Vision Application Programming Cookbook"





I got a chance to review this book last week. This book is for those who are interested in learning Image Processing/Computer Vision programming in C++.

The thing that differentiates this book from the original book written by Researchers at Willow Garage (maintainer of OpenCV) is that this book mainly concentrates on the programming paradigm in C++.

The book "OpenCV 2 Computer Vision Application Programming Cookbook" is for those who want to get started quickly on programming with OpenCV. All the syntax is in C++ and thats a positive point as most of the programming in Industry is done using C++.


This book shows how to extensively use C++ for simple/common tasks required for daily tasks in Computer Vision/Image Processing.

There are sections on "Scanning an image with iterators", "Filtering Images with low pass filters", Segmentation of the image, Fundamental Matrix, Computing Homography, etc.

These can be considered as the sections which were not properly covered in the original "Learning OpenCV" book and yet they are very commonly used.

There is a Chapter on "Processing Images with Classes" which I think many may find useful.

Sections like "How it works" try to explain whats really going on and stuff.

Overall, this can be considered as a really good book to get started with OpenCV programming.

However, there are only two points about this book that dissapoint me.

  • One, there is no proper coverage of Machine Learning algorithms feature of OpenCV (including adaboost, d-trees, clustering, classification etc). 
  • Two, there is no mention of python API of OpenCV. It is important because many people have increasingly started using Python to quickly test their algorithms in OpenCV rather than coding completely in Matlab which is different programming language/environment. 


I can consider this a "Must Buy" as there have been lots of changes in API to OpenCV over the past few years which are not covered by any other book presently available in the market as of now.

You can buy it at the official Packt publishers website.

Friday, June 17, 2011

Configure NDK with OpenCV on Android

*updated*
Here are the official links to configure environment to compile, write OpenCV apps on Android:

  1. Android SDK, NDK with Eclipse.
  2. Compiling OpenCV, NDK apps.

Thursday, June 16, 2011

MIX on Android @ WVU


Here is how I configured MIX (Mountaineer Information eXpress) mail on my android:

Update: Now that MIX and Master-ID are renamed as My-ID, just enter My-ID details and you will be good.

Go to email app, add a new account. While configuring the account, leave the default settings except for the following:

  1. Name is as MIX (or whatever you want)
  2. username is <your_id>@mix.wvu.edu and password is <your_password>
  3. Incoming mail settings, server is "mix.wvu.edu" with appropriate security settings.
  4. Outgoing mail settings, username is <your_id> and password is <your_password>
  5. Outgoing mail settings, server is "exsmtp.wvu.edu" and security as SSL.

There are no articles on the web suggesting the same (except for suggestions on forums), so I've decided to write this article.

Saturday, June 11, 2011

Convert nphmotionjpeg to video or images

Hi all. I've found a work-around to convert streaming video in nphMotionJpeg format into mp4/jpg. I'm sure that this is what some of you might be interested. So, I'm posting this.

Apparently, ffmpeg doesn't seem to do this. Instead,  I made this process work with VLC player and Avidemux only.

There might be some other better way to do it, I'm not sure. But, I found no help on the web regarding the same, so I've written this blog post.

They are explained as follows:

  1. Make sure that open a streaming video on the internet. (Obviously :p)
  2. Right click on the video and click as "Save As"/ "Save Image as". This might take some time for the browser to understand whats going on, as what we are saving is not a image, its a continuous stream instead. If browser doesn't respond after a minute or two retry this step.
  3. Leave the default name/format. It is likely to be "nphMotionJpeg"
  4. Save the file in certain location which is accessible. 
  5. Save the video as long as you want (I've saved as long as the file size becomes 8 GB). More than 8 GB didn't seem to work if i did so.
  6. Now as its a continuous stream and not a file of certain size, its size goes on increasing. If you cancel the download, then the entire file gets deleted. Make another copy of this "downloading" file. You may want to do this number of times possible if you want the latest data.
  7. Now after you made a copy of the currently "downloading" file, cancel the download and the file gets deleted (except for the copies).
  8. Now rename the file as "foo.avi" (apparently, if I name it as ".avi" extension only then this method works).
  9. Open the file in vlc player (windows/linux). Now you have the entire video here.
  10. Pause the video and Click on File->Convert/Stream
  11. "Add" the file that you want to convert.
  12. Select convert, then it asks for which format it needs to be converted.
  13. Select H.264 .mp4 format.
  14. Click on convert and it converts it to the specified format.
  15. Now as the nphMotionJpeg stream is in a readble format, open it in Avidemux (you can use ffmpeg here, but may loose some frames if you don't give the right parameters while converting).
  16. Open the file in Avidemux and it will give a warning ask you to open the file in SAFE MODE. DO NOT open it in SAFE MODE, as you might loose frames. Click on  NO/Cancel and then select OK for indexing.
  17. Go to File->Save->Selection as series of Jpegs.
  18. Give the filename in a particular folder and it will give you a series of jpeg images from the video stream recorded.

Friday, June 10, 2011

Learning Representations for real-world recognition

This is a talk that I found on Google Tech Talk channel on youtube. Check it out

Thursday, June 2, 2011

Kinect on Ubuntu

In this post, we will see how to setup Kinect (Xbox 360)  to work with Ubuntu 10.4 or higher using Freenect

Update: If you plan to develop full fledged Applications with Kinect (Computer Vision, AR apps), you may also want to take a look at OpenNI Api (Apparently, this has wider support and more features in the API).



You will need to install a software/binary called "freenect" which comes with working binaries and header file (for development in C/C++).

Follow the steps mentioned below:

  1. Fire up your terminal and execute the following command:

    sudo add-apt-repository ppa:arne-alamut/freenect

    So basically you are adding the software source to your authorized software sources list
  2. Update your software sources list by executing the following command:

    sudo apt-get update

  3. Install the software using the following command:

    sudo apt-get install freenect

  4. Now, you need to add your user to "video" group using the following command:

    sudo adduser <OS_USER_NAME> video
  5. Now, connect your "Kinect" to your PC and execute the following command:
    freenect-cppview
    also, there are other programs like:
    freenect-glview
After you execute the following commands, you might see something like as follows:



Along with this application, comes libraries for development. Run your synaptic manager and search for "kinect" and you might see something like this:


So, you just need to include these C++ header along with your programs (C/C++ probably) to develop applications that use Kinect sensor.

Happy Kinect Hacking/Programming.

References: http://openkinect.org/wiki/Getting_Started#Linux

Wednesday, June 1, 2011

Behavior Subtraction

The following is an interesting paper on behavior subtraction. It basically talks about detection abornal activity in a visual scene.

http://iss.bu.edu/jkonrad/Research/VSNs/Behavior_Subtraction/behavior_subtraction.html

The authors of the paper seem to detect abnormal activity in a busy area (like an interstate highway) by just performing simple static background subtraction. They add the background subtracted images for each frame over time (spatio temporal) and subtract the default background image to create a behavior image of the area.

Then to detect abnormal activity, they simply subtract the new frame from the behavior image (after setting a threshold).


The idea is pretty intuitive and also very effective.