Search code examples
opencvedge-detectionobject-detectionandroid

how to detect the outer frame of an object


I am using OpenCV4Android version 3.1.0 and I want the Android camera to be able to detect a card e.g: credit-card, customer's card or etc. To implement such functionalitey using OpenCV i tried to do it using Edge-Detection function, but as you see in the picture below, Edge-Detection detects all the edges in the frame, while what I am looking for is to detect the only the outer frame of the card.

I tried also Object-Detection "contour-detection" function, and as you see in the picture below, it did not detect the outer frame of the card.

please let me know what is the optimal solution or function i should use to be able to detect only the outer frame of any given card

Edge-Detection: enter image description here

Shape"contour" Detection: enter image description here


Solution

  • The number of edges that are found by edge detection is related to the thresholds you set (or that are set by default). Try manipulating with these thresholds to see if you get better results. You can also try gradient function, where you will get the "strength" of the edge instead of just binary "presence" of the edge. This will show you, that not all edges are equal.