Sunday, July 3, 2011

Opencv and Image processing reference books

I'm recommended following books for learning opencv and image processing . even they tech how to create GUI ( Graphical User Interface ) application. 

 


Title :   OpenCV 2 Computer Vision Application Programming Cookbook  
Author : Robert Laganière




OpenCV 2 Computer Vision Application Programming Cookbook  by robert laganiere



You can read sample book from HERE


---

Title : Learning OpenCV: Computer Vision in C++ with the OpenCV Library
Author :  Gary Bradski




Learning OpenCV: Computer Vision in C++ with the OpenCV Library by Gary Bradski





Monday, June 27, 2011

Background/Negative Images for Opencv haartaining

Selecting suitable  negative aka background image for haartraining is very important. Collect set of images  (about 3000) that does not contain objects of interest, for an example if you are going to train a haarcascade classifier for Face, you should have negatives with no face images.


you can download collection of negative images (about 3000 negatives) from here. [Use Internet Download Maneger]
http://tutorial-haartraining.googlecode.com/svn/trunk/data/negatives/ 

According to your haartraining requirement this may not be not enough . best proposition for No. Positive images : No. Negative images is 1:2, means if you have 2000 positive images you should have at least 4000 negative images. So if this is not enough, you can get more from public databases such as google images.
You can use these softwares to make download easy otherwise it would be boring . below softwares would be helpful
[1]bulk image downloader (commercial software)
[2]google image dowloader (FREE software) http://www.googleimagedownloader.com


After you get enough images you should  do index and rename all images properly for further use.This tool would be useful
Ant Renamer ( http://www.antp.be/software/renamer )


Related Post

[ Opencv installation ]
http://www.tectute.com/2011/01/opencv-22-installation-on-visual-studio.html

[ Positive images for haartraining ]
http://www.tectute.com/2011/06/haartraining-positive-samples.html

[ Opencv haartraining and haar cascade xml ]
http://www.tectute.com/2011/06/opencv-haartraining.html

haartraining positive samples

Following sites provides positive images for haartraining such as face, human gaits , cars , etc
 
Human Gaits
[1] http://www.cbsr.ia.ac.cn/english/Gait%20Databases.asp
[2] http://www.am.sanken.osaka-u.ac.jp/GaitDB/index.html
[3] http://www.mis.tu-darmstadt.de//node/382#name:cvpr08_data
[4] http://www.ri.cmu.edu//publication_view.html?pub_id=3904


Other

[1] http://sites.google.com/site/engb2s/databasehand
[2] http://web.mit.edu/emeyers/www/face_databases.html
[3] http://www-2.cs.cmu.edu/~cil/v-images.html



Related Post

[ Opencv installation ]
http://www.tectute.com/2011/01/opencv-22-installation-on-visual-studio.html

[ Negative images for haartraining ]
http://www.tectute.com/2011/06/negative-background-images.html

[ Opencv haartraining and haar cascade xml ]
http://www.tectute.com/2011/06/opencv-haartraining.html


Sunday, June 19, 2011

opencv haartraining

Learning opencv haartraining is challengeable, in this tutorial I describe haartraining best practices with my own experience. If you have basic knowledge at image processing , it will be helpful to understand haartraining concept. if you are new to image processing and opencv read some books. i recommend following books .
If you have questions regarding haartrainig don't hesitate to post them here.     


Download haartraining toolkit, vec files and haar classifiers from below link 
http://www.mediafire.com/download/mbd94o14wv8b4y2/Haartraining_Stuff.7z 

Alternative  download link :-
https://www.box.com/s/cdrf85e6aj8o82d0y4tp


Step 01: Collect postive images of interest object ( at least 1000 positive images )

                         If you have video of the interest object, then you can divided them into frames. All images should be in bitmap format. If you have .jpg or other format you can use "Right click image converter" or other image convertor to convert images into bitmap. learn more about opencv positive samples from here

Step 02: Crop Images

                         Here i'm going to create haar classifier of Side view of human. I hope you have download above toolkit . it contains with few sample images.
Put the all positive images into the "rawdata" folder and then double click and run the Objectmaker.exe to create the "info.txt" file. It would be something similar to this.


rawdata/IFWN-sequence-035.avi-00089-R200.bmp 1 305 57 69 202
rawdata/IFWN-sequence-035.avi-00096-R200.bmp 1 213 58 122 202
rawdata/IFWN-sequence-035.avi-00099-R200.bmp 1 208 61 107 207
rawdata/IFWN-sequence-036.avi-00117-R200.bmp 1 173 61 117 204

Step 03: Add absolute path for generated info.txt file
               For safety, you have to rename info.txt file becuase if you accidently double click the objectmaker.exe, it will cause to erase or change all data on info.txt file. As you can see the above, *.txt file contain with the relative path, but it's hard to create *.vec file with the relative path. So you should add the full path (absolute path) to your *.txt file. you can use append.bat file. right click and edit that bat file. it will looks like something similar to this

"for /F "delims=" %%j in (positiveOLD.txt) do echo.D:/opencvtest/HAAR/GAIT_REC_DET/DATA/Training/%%j >> POSITIVES.txt"

here positiveOLD.txt is without absolute path and  POSITIVES.txt is with absolute path.
once you got the POSITIVES.txt verify it's really added the correct absolute path or not.


Step 04: Generate *.vec file
By createSampleCommand.bat file you can generate the *.vec files. you should change the parameters according to your requirement

Step 05: Verify the *.vec file
By using SampleVerify.bat file you can verify the generated *.vec file.by pressing any key you can browse all cropped images manually. few vec files are located at "sample vec". folder

Step 06: Start Haartraining
Create new folder and put *.vec file, negatives.txt and haartraining.bat file. Double click the bat file and launch the haartraining process. This would be take 60,90 hours to complete and it depends on your sample complexity.you can't pause this process once it start, it is better use cloud . i used http://www.cloudshare.com .

Step 07: Check the performance
you can use performance.bat file to check the classifier performance.


=====
Human side view detection from real time stream/video
download source code (visual studio 2008 with opencv 2.2)

http://www.mediafire.com/download/l10hlfijd2el9cc/detection.7z

Alternative  download link :-
https://www.box.com/s/i5b8k08x8cr00ukr4n9m



                      



==========

Related post

[ Opencv installation ]
http://www.tectute.com/2011/01/opencv-22-installation-on-visual-studio.html

[ Negative images for haartraining ]
http://www.tectute.com/2011/06/negative-background-images.html

[ Positive images for haartraining ]
http://www.tectute.com/2011/06/haartraining-positive-samples.html



=========

These are the useful links for haartraining.

[1]. http://note.sonots.com/SciSoftware/haartraining.html
[2].http://www.computer-vision-software.com/blog/2009/11/faq-opencv-haartraining/
[3]. part 1. http://www.quotientrobotics.com/2010/04/opencv-haartraining-object-detection.html
      part 2. http://www.quotientrobotics.com/2010/04/opencv-haartraining-object-detection_09.html

Tuesday, January 11, 2011

opencv 2.2 installation on visual studio 2008

[1] Download opencv 2.2
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/

[2] Double click and lauch OpenCV-2.2.0-win32-vs2010.exe. this exe compatible with 32 bit OS. if you are using 64bit version you must use CMake to build OpenCV binaries from the sources .
Click "Next >"
opencv 2.2 setup wizard
















[3] Click "I Agree"



opencv 2.2 license agreement
















[4] Then Choose second option "Add Opencv to the system PATH for all users" and click "Next >" and finish the installation.



opencv install options
















[5] Lauch the visual studio. here i used visual studio 2008.
click "file" menu and "new" "project" then select Visual C++ and win32console application

















[6] click "Next >"




















[7] Click "Finish"




o















[8] then click "tools" menu and select "option" and chose "VC++ directory"




















[9] select "include files" from the drop down and add below links
C:\OpenCV2.2\include\opencv
C:\OpenCV2.2\include



adding opencv library files into visual studio

















[10] Then select "Library files" from drop down and add link
C:\OpenCV2.2\lib




















[11] Then go to solution explorer and right click on the project "test1" ( i had named my project as "test1" )



simple opencv application using visual studio




















[12] Brows to C/C++ and linker and click on "Additional Dependencies"
















[13] Add below links and click "ok"  and "Apply"

C:\OpenCV2.2\lib\opencv_calib3d220d.lib
C:\OpenCV2.2\lib\opencv_contrib220d.lib
C:\OpenCV2.2\lib\opencv_core220d.lib
C:\OpenCV2.2\lib\opencv_features2d220d.lib
C:\OpenCV2.2\lib\opencv_ffmpeg220d.lib
C:\OpenCV2.2\lib\opencv_flann220d.lib
C:\OpenCV2.2\lib\opencv_gpu220d.lib
C:\OpenCV2.2\lib\opencv_highgui220d.lib
C:\OpenCV2.2\lib\opencv_imgproc220d.lib
C:\OpenCV2.2\lib\opencv_legacy220d.lib
C:\OpenCV2.2\lib\opencv_ml220d.lib
C:\OpenCV2.2\lib\opencv_objdetect220d.lib
C:\OpenCV2.2\lib\opencv_video220d.lib 

















[14] Goto your project folder and open "test1" (according to my example)













[15] Then add any *.jpg image ( here i choose "cat.jpg" ) to that folder













[16]then back to VS2008 add following source Code

 #include "stdafx.h"
#include "highgui.h"
int main( int argc, char** argv )
{
    IplImage* img = cvLoadImage( "cat.jpg" );  // rename according to your  *.jpg image
    cvNamedWindow( "Example11", CV_WINDOW_AUTOSIZE );
    cvShowImage( "Example11", img );
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example11" );
}



[17] Click "Buid". If there is no errors click "Build Solution" after succesfull build debug the program and get a output like below



simple opencv application















[18] This is simple procedure to determine OpenCV is working correctly.


Related Post

 [ Negative images for haartraining ]
http://www.tectute.com/2011/06/negative-background-images.html

[ Positive images for haartraining ]
http://www.tectute.com/2011/06/haartraining-positive-samples.html

[ Opencv haartraining and haar cascade xml ]
http://www.tectute.com/2011/06/opencv-haartraining.html

Related Posts