You sound rather new to OpenCV in general so these are my recommendations
After you are done with the installation process, proceed to following this tutorial. It should give you a basic idea of the main operations popularly used in OpenCV. I would go through sections Your First Java Application with OpenCV, Your First JavaX Application with OpenCV, OpenCV Basics, Image Segmentation and Object Detection. These sections consist of all the different pre-processing you would be required to do to isolate your objects.
Then look into findContours()
; explanation, Java usage.
From that point onwards, it becomes a matter of you performing different operations on the detected contours to see if they meet certain criteria. You could look at the Shape Factor. The area and perimeter can be attained using contourArea()
and arcLength()
as demonstrated here; I believe Imgproc.contourArea()
and Imgproc.arcLength()
are the Java equivalent. For circles you are expected to get values very close to 1. For triangles you are going to get low values around 0.3. For squares you are expected to get values around 0.7-0.8.
After you have done all of this and was able to detect a couple things, then you can start looking into Hough Line Transform and Hough Circle to compare the attained results.
Demos:
I would look into blob detection and shape detection only after reviewing the OpenCV basics. They do solve a couple of your problems but if you rush into them, you'll have a very hard time understanding what the hell is going on.
Two Cents:
As you might have noticed, some of my links consist of Python/C++ material. The API calls are similar so it should not be hard to convert it to Java. I would recommend you get familiar with either languages; in case you currently are not, because a huge chunk of the resources out there are in one of those two languages.
Always refer to the documentation; official, Java version should you get stuck at any point. Plus, Google and StackOverflow have never been a disappointment
After going through all of this, and you are up for the challenge, you can look into more sophisticated method like Hausdorff Distance and Chamfer Matching
Happy coding,
Cheers mate! :)