Object detection


Published on

Object detection using opencv for detecting objects. Flow chart, Algorithm and implementation are explained.

Published in: Technology
1 Comment
1 Like
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Object detection

  1. 1. Object-Detection Somesh Vyas
  2. 2. Content OpenCV an Introduction Haar-training Flow-chart Algorithm part-1 Algorithm part-2 Implementation Code Reference References
  3. 3. OpenCV an Introduction OpenCV is an open source C++ library for image processing and computer vision, originally developed by Intel and now supported by Willow Garage. It is free for both commercial and non-commercial use. It is a library of many inbuilt functions mainly aimed at real time image processing. Now it has several hundreds of image processing and computer vision algorithms which make developing advanced computer vision applications easy and efficient.
  4. 4. Haar-training The OpenCV library gives us a greatly interesting demo for a object detection. Furthermore, it provides us programs (or functions) which they used to train classifiers for their object detection system (called HaarTraining). Thus, we can create our own object classifiers using the functions.
  5. 5. Flow-chart Gather image set of object e.g. fish Capture stream from camera Gather negative image set without object of interest While capture yes Create vector files of positive image set Query frame by frame Create dat file of negative one’s Convert each frame to grayscale haar training of positive and negative image sets to generate xml file Apply histogram equalization on image
  6. 6. Load haar cascade file Store objects to a variable faces while using detectMultiScale method While faces yes Draw Rectangle on object
  7. 7. Algorithm part-1 Collect image set of particular object e.g. fish Crop these images for better haarCascade file Collect negative image set which doesn’t contain object Use openCV createsamples utility to generate positive .vec file for generating variations in image set Create collection file format .dat file of negative images using this command $ find [image dir] -name '*.[image ext]' > [description file] Using openCV haartraining utility we will generate xml file which is called cascade classifier file to detect object.
  8. 8. Algorithm part-2 Use OpenCV for performing real time detection in video Use cvCaptureFromCAM to capture from camera Use cvQueryFrame to quering frame by frame for processing images to get ROI(Reason of Interest). Convert image to grayscale image using COLOR_BGR2GRAY of Imgproc class Use Histogram Equalization method for more accuracy.
  9. 9. Algorithm part-2 Using cascadeClassifier class of OpenCV load haar cascade xml file generated in part 1 of algorithm Use detectMultiScale method of cascadeClassifier class to detect objects and store them in variable. Iterate the variable so we can get all ROI Use rectangle function to generate rectangle on ROI
  10. 10. Implementation Install windows 7 Install visual studio Install crygwin Using crygwin generate sample training data positive sample data as well as negative data. Perform haartraining on sample data to generate haar cascade xml file. Install OpenCV
  11. 11. Set all environment variables according to opencv path Configure Visual studio project to get OpenCV libraries Use C++ or python for implementing algorithm
  12. 12. Code reference Code reference could be found at http://pastebin.com/Vw00NgCt This is visual studio code for detecting object By changing haar cascade file with haar cascade fish file we can detect particular class of fish
  13. 13. References http://note.sonots.com/SciSoftware/haartraining.html http://docs.opencv.org/doc/tutorials/objdetect/cascade_clas sifier/cascade_classifier.html http://docs.opencv.org/doc/tutorials/imgproc/histograms/his togram_equalization/histogram_equalization.html https://opencv-pythontutroals.readthedocs.org/en/latest/py_tutorials/py_objdetec t/py_face_detection/py_face_detection.html http://opencv-srf.blogspot.in/2013/05/installing-configuringopencv-with-vs.html