OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 20 Nov 2017 03:39:46 -0600Remove defects from round objecthttp://answers.opencv.org/question/178725/remove-defects-from-round-object/Hello everyone, I want to extract the inner circle *like* structure from this preprocessed image:
![image description](https://i.snag.gy/TJoDaA.jpg)
This is my best result so far (Green = Fitted Ellipse):
![](https://i.snag.gy/elAnLW.jpg)
For the result above i used:
`dilate` -> `findContours` -> only keeping the second largest `minAreaRect` -> `fitEllipse`
For my needs the fitted ellipse is not precise enough. What i tryed already:
- `approxPolyDP`: Either way it fails to detect part of the inner "circle" or it includes a lot of the defects
- `HoughCircles`: The structure Iam looking for is just round but not a real circle, so it's way to unprecise
- `convexHull`: Deforms the "circle" way to much
- `contourArea`: Tryed to remove some of the blobs due to their small size but since lines have a small area aswell it didn't work
The perfect result (created by hand) the green part:
![image description](https://snag.gy/jew8bA.jpg)
Any ideas how to get closer to this result?CriggesMon, 20 Nov 2017 03:39:46 -0600http://answers.opencv.org/question/178725/How to fit an ellipse to fingertips ?http://answers.opencv.org/question/100064/how-to-fit-an-ellipse-to-fingertips/ ![image description](/upfiles/1470937175857319.jpg)
I want to fit ellipse to all the fingertips on this hand using the detected points.
How should I draw ellipse only at those specific places.
Should I store these points in array and draw an ellipse for closest ones?
Or is there any optimal solution to this.supertramp-sidThu, 11 Aug 2016 12:42:32 -0500http://answers.opencv.org/question/100064/how to use python to detect ellipsehttp://answers.opencv.org/question/100569/how-to-use-python-to-detect-ellipse/ I want to detect the simple shapes in an image. I use cv2.approxPolyDP to detect vertices, but the result of ellipse is 4, same as square, how to differ them? Or, how to detect an ellipse, given the contour?
This is part of the code, "c" is the contour. I find ellipse's approx is 4, same as square.
shape = "unidentified"
peri = cv2.arcLength(c, True)
approx = cv2.approxPolyDP(c, 0.04 * peri, True)
# if the shape is a triangle, it will have 3 vertices
if len(approx) == 3:
shape = "triangle"
# if the shape has 4 vertices, it is either a square or
# a rectangle
elif len(approx) == 4:tiantongThu, 18 Aug 2016 21:14:45 -0500http://answers.opencv.org/question/100569/Calculating the mid point in a rotated rectangle sidehttp://answers.opencv.org/question/9457/calculating-the-mid-point-in-a-rotated-rectangle-side/Hi,
I have a rotated rectangle that is based on a CvBox2D object. The rotated rect contains a moving object, i.e. points of the object.
CvBox2D box = cvMinAreaRect2(pointList)
RotatedRec myRect (box);
I'm trying to calculate the middle point of the two sides (left and right) of this rotating rectangle, i want to know those middle points in each side because that's where my fitting rotating ellipse would be, the problem is I think my math is missing something. for instance, to get to the middle point in the right side, here's what I'm doing:
Point2f rightSide;
float rotationAngle = myRect.angle * (180.0/ CV_PI); // Convert from degrees to radians
rightSide.x = myRect.center.x + myRect.size.width/2; // Get to the middle point
rightSide.y = myRect.center.y; // Keep the y coordinate the same as the center
// Apply the rotation equation, i'm not updating y because I always have the most up to
// date y coordinate from the center position
rightSide.x = (rightSide.x * cos(rotationAngle)) - (rightSide.y * sin(rotationAngle));
Of course the object is moving randomly within the screen, and so the rotated rectangle is moving along with it. Unfortunately the above piece of code doesn't produce the middle point in the right side of the rotating rectangle, I can tell because I'm actually drawing the point. I'm following a similar approach for the left side. Just wondering if anybody can offer any ideas ? Is it the angle ? Do I have to deal with the fact that sometimes the angle can be in negative and I have to figure out which quarter it lies within ? Is the angle given by the rotated rect is the rotation angle to begin with ?
I tried another approach where I get the vertices (i.e. the corners) of the rotated rect and then move to those middle points but that did not work out either.
I'm sure my math is missing something somewhere, I noticed that someone was having a similar problem here (http://answers.opencv.org/question/1945/fast-way-to-draw-ellipse-axes/) but I did not want to hijack the thread.
Appreciate the help, thanks in advance.hesperusSun, 17 Mar 2013 02:39:15 -0500http://answers.opencv.org/question/9457/