在使用opencv java查找轮廓后如何裁剪图像?

时间:2018-05-15 02:02:45

标签: java opencv

我正在尝试裁剪出一张表格。我使用了边缘检测,我使用这种方法找到了轮廓:

    Mat frameImg = tess.bufferedImageToMat(image);
    frameImg = this.doCanny(frameImg);
    frameImg = this.doBackgroundRemoval(frameImg);
    frameImg = this.doFindContours(frameImg);

public Mat doFindContours(final Mat src) {

Mat dst = new Mat(src.rows(), src.cols(), src.type());
src.copyTo(dst);

Imgproc.cvtColor(dst, dst, Imgproc.COLOR_BGR2GRAY);

final List<MatOfPoint> contours = new ArrayList<>();
final Mat hierarchy = new Mat();
Imgproc.findContours(dst, contours, hierarchy, Imgproc.RETR_TREE, Imgproc.CHAIN_APPROX_SIMPLE);
Rect boundRect;
Imgproc.cvtColor(dst, dst, Imgproc.COLOR_GRAY2BGR);

return dst;

}

我应该如何使用轮廓裁剪出我的图像?

0 个答案:

没有答案
相关问题