I am using Opencv 2.4.10 in Android Studio and the method connectedComponents is only available in Opencv 3.0 and above. I want to know if there are similar methods I can use to replace connectedComponents() and what are the methods.
I am developing a real-time application that can track the people passing by using an android camera. Currently, I can extract the foreground (or segment the motion) from the background. But some of the detected foreground are divided into parts, so I need connectedComponents() method to connect the blobs that should be grouped together. But like I said earlier, it is not available in my Opencv version. Please help.
This is just a snippet of my code:
Core.absdiff(frameGray, bgModelGray, differenceGray);
differenceGray.convertTo(mGray, CvType.CV_8UC1) ;
Imgproc.threshold(mGray, mGray, 0, 255, Imgproc.THRESH_OTSU);
Mat erodeElement = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(5, 5), new Point(3, 3));
Mat dilateElement = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3));
Imgproc.erode(mGray, mGray, erodeElement);
Imgproc.dilate(mGray, mGray, dilateElement);
contours.clear();
Imgproc.findContours(mGray, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE);
Imgproc.drawContours(mRgba, contours, -1, new Scalar(0, 0, 255), 2);
This is a screenshot after the dilation, contours are not yet added here