Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niisar/53e257f8c258b47ae5c4f42d9d64049f to your computer and use it in GitHub Desktop.
Save niisar/53e257f8c258b47ae5c4f42d9d64049f to your computer and use it in GitHub Desktop.
Detect the position of an object - computer vision.md

Detect the position of an object - computer vision

Problem

Comparing two images: The observed position vs the required position.

Solution using (OpenCV-Python)

  1. Load your image and binarize it.
  2. Use cv2.findContours(thresh, 1, 2) to find the contour of interest object.
  3. Find the bounding rectangle using cv2.boundingRect(cnt) function.
  4. Using rectangle coordinates find its center as representative point.
  5. Compare the centre with your reference point by calculaing the euclidean distance.

OpenCV is python and C++ based library. But as a C# guy i whould use Emgu CV which is a Wrapper of OpenCV and has almost all the function of OpenCV with Speed and Performance (50 frames per second)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment