Reputation: 21
Iam a beginner to opencv and java. I want to learn the usage and functionalities of the method Imgproc.findContours()
. I didn't get any source to learn it. can anybody please explain the working of the same in detail. or can anyone suggest me a suitable source to learn it.
Upvotes: 1
Views: 3616
Reputation: 114
One example :
public class FindContours implements ImageFilter {
@Override
public Mat filter(final Mat src) {
final Mat dst = new Mat(src.rows(), src.cols(), src.type());
src.copyTo(dst);
Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);
final List<MatOfPoint> points = new ArrayList<>();
final Mat hierarchy = new Mat();
Imgproc.findContours(dst, points, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE);
Imgproc.cvtColor(dst, dst, Imgproc.COLOR_GRAY2BGR);
return dst;
}
@Override
public boolean isApplicable() {
return true;
}
}
And the link of the last doc : https://docs.opencv.org/3.3.1/d3/dc0/group__imgproc__shape.html#ga17ed9f5d79ae97bd4c7cf18403e1689a
Upvotes: 4