I am having a struggle with finding out only internal contours of the provided image. Finding an external contour is easy, however I have no clue how to find internal contours with JavaCV as documentation lacks.
My code so far is:
for (Mat mat : mats) {
Mat newMat = mat.clone();
opencv_imgproc.Canny(mat, newMat, 50.0, 100.0);
opencv_imgproc.blur(newMat, newMat, new Size(2, 2));
opencv_core.MatVector contours = new opencv_core.MatVector();
opencv_core.Mat hierarchy = new opencv_core.Mat();
//Mat hierarchy = new Mat(new double[]{255, 255, 255, 0});
opencv_imgproc.findContours(newMat, contours, hierarchy, opencv_imgproc.CV_RETR_TREE, opencv_imgproc.CHAIN_APPROX_SIMPLE, new opencv_core.Point(0, 0));
List<opencv_core.Rect> rectangles = new ArrayList<>();
for (Mat matContour : contours.get()) {
//clueless how to find internal contours here
}