Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect shapes in an image?

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.

like image 419
Manoj Avatar asked Apr 02 '11 11:04

Manoj


People also ask

How to detect shapes (mainly lines and circles) in images in Python?

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.

How to detect objects inside other shapes in an image?

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.

How to detect shapes in image using OpenCV in Python?

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.

How to find the center point of a shape in Python?

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...


2 Answers

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)

like image 45
code-gijoe Avatar answered Oct 06 '22 10:10

code-gijoe


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.

like image 130
mpenkov Avatar answered Oct 06 '22 09:10

mpenkov