I'm trying to run an OCR on a speed sign. I'm getting the contours like below :
static ArrayList<MatOfPoint> getContours(Mat fgMask) { ArrayList<MatOfPoint> contours = new ArrayList<>(); float threshold = 100.0f; Mat cannyOutput = new Mat(); Imgproc.Canny(fgMask, cannyOutput, threshold, threshold * 3); Mat hierarchy = new Mat(); Imgproc.findContours(cannyOutput, contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE); hierarchy.release(); return contours; }
But sometimes, I detect a 0 inside a 0. As you can see here :
I know that we can use the hierachy mat to do what I want. I just don't understand how to do it in Java.