Unable to determine object's concavity in OpenCVHow to determine a Python variable's type?In Python, how do I determine if an object is iterable?Determine the type of an object?Why drawcontours in OpenCV doesn´t fill contours in the edge of the image?General contour detectionTriangle detection using OpenCVopenCV: cannot detect small shapes using findContoursOpenCV Convex Hull coordinatesOpenCV 3.4.0 video contours/arclength error(s)how to join nearby contours in a opencv motion detection
If I leave the US through an airport, do I have to return through the same airport?
Section numbering in binary
Does the new finding on "reversing a quantum jump mid-flight" rule out any interpretations of QM?
How do we say "within a kilometer radius spherically"?
What does the pair of vertical lines in empirical entropy formula mean?
Java Servlet & JSP simple login
Please figure out this Pan digital Prince
How can I remove material from this wood beam?
C++ logging library
Analogy between an unknown in an argument, and a contradiction in the principle of explosion
Electricity free spaceship
What aircraft was used as Air Force One for the flight between Southampton and Shannon?
Is using 'echo' to display attacker-controlled data on the terminal dangerous?
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
Is the use of umgeben in the passive unusual?
Are polynomials with the same roots identical?
Should I put programming books I wrote a few years ago on my resume?
How to make the letter "K" that denote Krylov space
Did Apple bundle a specific monitor with the Apple II+ for schools?
Why does this query, missing a FROM clause, not error out?
Who voices the small round football sized demon in Good Omens?
Teaching a class likely meant to inflate the GPA of student athletes
How to write a convincing religious myth?
2019 gold coins to share
Unable to determine object's concavity in OpenCV
How to determine a Python variable's type?In Python, how do I determine if an object is iterable?Determine the type of an object?Why drawcontours in OpenCV doesn´t fill contours in the edge of the image?General contour detectionTriangle detection using OpenCVopenCV: cannot detect small shapes using findContoursOpenCV Convex Hull coordinatesOpenCV 3.4.0 video contours/arclength error(s)how to join nearby contours in a opencv motion detection
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:
I first find the contours in the image and then do this:
approx = cv2.approxPolyDP(c, 0.04 * perimeter, True)
isPentagon = len(approx) == 5
When I ran this on the image, I got this result:
This white part in the image is being detected. I thought that checking the concavity would solve it. Here is what I attempted:
isPentagon = len(approx) == 5 and cv2.isContourConvex(c)
However, for all the pentagons I tried, isContourConvex
returned False
. I am not sure why. I tried other images as well and the same happened. Variable c
is the contour.
Is there a way to fix this? Maybe a better way to check if a polygon is regular?
python opencv object-detection
add a comment |
I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:
I first find the contours in the image and then do this:
approx = cv2.approxPolyDP(c, 0.04 * perimeter, True)
isPentagon = len(approx) == 5
When I ran this on the image, I got this result:
This white part in the image is being detected. I thought that checking the concavity would solve it. Here is what I attempted:
isPentagon = len(approx) == 5 and cv2.isContourConvex(c)
However, for all the pentagons I tried, isContourConvex
returned False
. I am not sure why. I tried other images as well and the same happened. Variable c
is the contour.
Is there a way to fix this? Maybe a better way to check if a polygon is regular?
python opencv object-detection
add a comment |
I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:
I first find the contours in the image and then do this:
approx = cv2.approxPolyDP(c, 0.04 * perimeter, True)
isPentagon = len(approx) == 5
When I ran this on the image, I got this result:
This white part in the image is being detected. I thought that checking the concavity would solve it. Here is what I attempted:
isPentagon = len(approx) == 5 and cv2.isContourConvex(c)
However, for all the pentagons I tried, isContourConvex
returned False
. I am not sure why. I tried other images as well and the same happened. Variable c
is the contour.
Is there a way to fix this? Maybe a better way to check if a polygon is regular?
python opencv object-detection
I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:
I first find the contours in the image and then do this:
approx = cv2.approxPolyDP(c, 0.04 * perimeter, True)
isPentagon = len(approx) == 5
When I ran this on the image, I got this result:
This white part in the image is being detected. I thought that checking the concavity would solve it. Here is what I attempted:
isPentagon = len(approx) == 5 and cv2.isContourConvex(c)
However, for all the pentagons I tried, isContourConvex
returned False
. I am not sure why. I tried other images as well and the same happened. Variable c
is the contour.
Is there a way to fix this? Maybe a better way to check if a polygon is regular?
python opencv object-detection
python opencv object-detection
asked Mar 24 at 20:33
Nick SolonkoNick Solonko
294318
294318
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The issues was that I was passing in the original contour found by cv2.findContours
into the cv2.isContourConvex
. That original contour has a ton of points, some of which give the shape a concave characteristic.
To fix this, I had to call cv2.isContourConvex(approx)
. This would evaluate the approximation of the pentagon that has exactly five sides and five vertices. Although I would later draw the initial contour, evaluating the contourConvex function on the approximation yielded the correct result.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328296%2funable-to-determine-objects-concavity-in-opencv%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The issues was that I was passing in the original contour found by cv2.findContours
into the cv2.isContourConvex
. That original contour has a ton of points, some of which give the shape a concave characteristic.
To fix this, I had to call cv2.isContourConvex(approx)
. This would evaluate the approximation of the pentagon that has exactly five sides and five vertices. Although I would later draw the initial contour, evaluating the contourConvex function on the approximation yielded the correct result.
add a comment |
The issues was that I was passing in the original contour found by cv2.findContours
into the cv2.isContourConvex
. That original contour has a ton of points, some of which give the shape a concave characteristic.
To fix this, I had to call cv2.isContourConvex(approx)
. This would evaluate the approximation of the pentagon that has exactly five sides and five vertices. Although I would later draw the initial contour, evaluating the contourConvex function on the approximation yielded the correct result.
add a comment |
The issues was that I was passing in the original contour found by cv2.findContours
into the cv2.isContourConvex
. That original contour has a ton of points, some of which give the shape a concave characteristic.
To fix this, I had to call cv2.isContourConvex(approx)
. This would evaluate the approximation of the pentagon that has exactly five sides and five vertices. Although I would later draw the initial contour, evaluating the contourConvex function on the approximation yielded the correct result.
The issues was that I was passing in the original contour found by cv2.findContours
into the cv2.isContourConvex
. That original contour has a ton of points, some of which give the shape a concave characteristic.
To fix this, I had to call cv2.isContourConvex(approx)
. This would evaluate the approximation of the pentagon that has exactly five sides and five vertices. Although I would later draw the initial contour, evaluating the contourConvex function on the approximation yielded the correct result.
answered Mar 24 at 22:50
Nick SolonkoNick Solonko
294318
294318
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55328296%2funable-to-determine-objects-concavity-in-opencv%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown