For Beginners

If you are a beginner in OpenCV programming, then this post may be helpful in providing a insight towards the basic image processing algorithms and its functions available in OpenCV.

Requirments:
OpenCV 2.4.3  (for other versions visit HERE )
Microsoft Visual Studio 10 (or higher version)
OpenCV Linking Guide

First, install OpenCV library and link it with C compiler ( I am using Microsoft Visual studio in Windows platform). Learn the basic image processing functions available in OpenCV through the examples provided in the blog. Here is a list of algorithms you can experiment on to make OpenCV handy.



  1. Load, Display and Save an image
  2. Capture Video from Webcam
  3. Basic drawing examples
  4. Convert RGB to gray / other color spaces
  5. Threshold operation
  6. Bilateral Filter / Gaussian Filter / Median Filter
  7. 2D Convolution / Creating new filter
  8. Sobel Edge Detection / Laplacian operator
  9. Hough Circle Detection
  10. Histogram Calculation
  11. Erosion or dilation
  12. Bitwise AND, OR, XOR and NOT
  13. Face Detection using Haar-Cascade Classifier

10 comments:

  1. It should be really usefull to do a complete Topic about creating haarcascade clasifier ;)
    But your website really nice ! continue

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Refer:
    http://opencv-hub.blogspot.in/

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. can you post for face recognition tutorial??

    ReplyDelete
    Replies
    1. import numpy as np
      import cv2
      import cv2.cv as cv
      from video import create_capture
      from common import clock, draw_str

      help_message = '''
      USAGE: facedetect.py [--cascade ] [--nested-cascade ] []
      '''

      def detect(img, cascade):
      rects = cascade.detectMultiScale(img, scaleFactor=1.3, minNeighbors=4, minSize=(30, 30), flags = cv.CV_HAAR_SCALE_IMAGE)
      if len(rects) == 0:
      return []
      rects[:,2:] += rects[:,:2]
      return rects

      def draw_rects(img, rects, color):
      for x1, y1, x2, y2 in rects:
      cv2.rectangle(img, (x1, y1), (x2, y2), color, 2)

      if __name__ == '__main__':
      import sys, getopt
      print help_message

      args, video_src = getopt.getopt(sys.argv[1:], '', ['cascade=', 'nested-cascade='])
      try: video_src = video_src[0]
      except: video_src = 0
      args = dict(args)
      cascade_fn = args.get('--cascade', "../../data/haarcascades/haarcascade_frontalface_alt.xml")
      nested_fn = args.get('--nested-cascade', "../../data/haarcascades/haarcascade_eye.xml")

      cascade = cv2.CascadeClassifier(cascade_fn)
      nested = cv2.CascadeClassifier(nested_fn)

      cam = create_capture(video_src, fallback='synth:bg=../cpp/lena.jpg:noise=0.05')

      while True:
      ret, img = cam.read()
      gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
      gray = cv2.equalizeHist(gray)

      t = clock()
      rects = detect(gray, cascade)
      vis = img.copy()
      draw_rects(vis, rects, (0, 255, 0))
      for x1, y1, x2, y2 in rects:
      roi = gray[y1:y2, x1:x2]
      vis_roi = vis[y1:y2, x1:x2]
      subrects = detect(roi.copy(), nested)
      draw_rects(vis_roi, subrects, (255, 0, 0))
      dt = clock() - t

      draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000))
      cv2.imshow('facedetect', vis)

      if 0xFF & cv2.waitKey(5) == 27:
      break
      cv2.destroyAllWindows()

      save this code in your python idle as facedetect.py.then run in ur terminal $python facedetect.py

      Delete
  6. Hi! It is really helpful! All the important things in one article! Lately, I was building an app in Android Studio, I needed to integrate it with OpenCv and I found a great article about it. Check it out: http://blog.zaven.co/opencv-in-android-studio-project/

    ReplyDelete
  7. Those are good examples of Open CV. For more information and resources about retail software solutions, please visit the TradeMeters point of sale software page. They also offer a reasonable Windows PC based optometry software for opticians.

    ReplyDelete
  8. I found most of the tutorials a waste of time and garbage as it says only how to use the existing junks (functions already written by someone). What should be taught is to load an image and play with the pixels rather than wasting readers time giving superfluous information about calling some functions.

    ReplyDelete