I want to detect a circle, rectangle shaped object in an image and read the information from that object. Is there any api in java which will be helpful to me?
Ex: Detect a round shaped coin in a white background and obtain information about that that coin like ( value of a coin, etc.)
Thanks.
In this tutorial, you will learn how you can detect shapes (mainly lines and circles) in images using Hough Transform technique in Python using OpenCV library. The Hough Transform is a popular feature extraction technique to detect any shape within an image. It is mainly used in image analysis, computer vision and image recognition.
Normally we use the cv2. findContours () function to detect objects in an image, right? Sometimes objects are in different locations. But in some cases, some shapes are inside other shapes, just like nested figures. In this case, we call the outer one as parent and inner one as child.
It is mostly used with python. In this article we are going to see how to detect shapes in image. For this we need cv2.findContours () function of OpenCV, and also we are going to use cv2.drawContours () function to draw edges on images.
Approach 1 Import module 2 Import image 3 Convert it to grayscale image 4 Apply thresholding on image and then find out contours. 5 Run a loop in the range of contours and iterate through it. 6 In this loop draw a outline of shapes (Using drawContours () ) and find out center point of shape. More items...
Circles are perfect targets for the Hough transform. Check this out Detect circles with HT and OpenCV
Rectangles are a bit harder since the Hough Transform is not rotation invariant. You can go into edge detection and fast fitting (Fast line and rectangle detection by clustering and grouping)
Here's an answer to a similar question for C++.
For Java, you can use the OpenCV wrappers. However, once you understand the essence of the approach you should be able to solve your problem using whichever framework is available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With