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;








0















I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:



enter image description here



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:



enter image description here



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?










share|improve this question




























    0















    I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:



    enter image description here



    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:



    enter image description here



    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?










    share|improve this question
























      0












      0








      0








      I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:



      enter image description here



      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:



      enter image description here



      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?










      share|improve this question














      I am attempting to detect convex pentagons in an image using OpenCV. I am using the following image:



      enter image description here



      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:



      enter image description here



      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 20:33









      Nick SolonkoNick Solonko

      294318




      294318






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            0














            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.






            share|improve this answer



























              0














              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.






              share|improve this answer

























                0












                0








                0







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 22:50









                Nick SolonkoNick Solonko

                294318




                294318



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript