Opencv – How to identify different objects in an image

computer visionimage processingopencvpattern matching

I'm intending to write a program to detect and differentiate certain objects from a nearly solid background. The foreground and the background have a high contrast difference which I would further increase to aid in the object identification process. I'm planning to use Hough transform technique and OpenCV.

Sample image

As seen in the above image, I would want to separately identify the circular objects and the square objects (or any other shape out of a finite set of shapes). Since I'm quite new to image processing I do not have an idea whether such a situation needs a neural network to be implemented and each shape to be learned beforehand. Would a technique such as template matching let me do this without a neural network?

Best Answer

These posts will get you started:

You will probably have to adjust some parameters in these codes to match your circles/squares, but the core of the technique is shown on these examples.