7

I want to find custom shape in OpenCV. Shape is previously defined. I want to detect if this shape is equal or not equal to the current shape using WebCam in real time.

How can I do that? How to compare pre-defined custom shape and current shape?

2
  • Thanks for quick reply @runDOSrun..Is it possible with opencv-python?can you give me a good example or docs? Commented Feb 10, 2015 at 9:54
  • template matching and chamfer matching are common simple techniques for simple shape matching. Commented Feb 10, 2015 at 9:59

1 Answer 1

4

As the commenters have eluded, you can use template matching to detect custom shapes.

So What Is Template Matching?

Template matching is a technique in digital image processing for finding small parts of an image which match a template image. It can be used in manufacturing as a part of quality control, a way to navigate a mobile robot, or as a way to detect edges in images.

Template Matching In OpenCV/Python

Template Matching is a method for searching and finding the location of a template image in a larger image. OpenCV comes with a function cv2.matchTemplate() for this purpose. It simply slides the template image over the input image (as in 2D convolution) and compares the template and patch of input image under the template image.

I have taken this text from here which is a tutorial on how to perform template matching in OpenCV. You can search for any "custom shape" that you define. It includes code samples for python.

Sign up to request clarification or add additional context in comments.

1 Comment

I have already read you commanded tutorial.According to all of you,I must use template matching for my application.Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.