0

我想使用打开的 cv 库将 AdaptiveThreshold 应用于我的位图图像,但是一旦我使用以下代码,它会显示空白(全白)图像,请帮我解决它。

以下是代码:

Mat grayMat = imread(getImageUri(this, photo).getPath(), IMREAD_GRAYSCALE);
        Mat resultMat = new Mat();
        Imgproc.adaptiveThreshold(grayMat, resultMat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 3, 40);
        Bitmap imgBitmap = Bitmap.createBitmap(resultMat.cols(), resultMat.rows(), Bitmap.Config.ARGB_8888);
4

1 回答 1

0

Add following line after init. bitmap

Utils.matToBitmap(resultMat, imgBitmap);

and load imgBitmap to your ImageView, I hope this will solve your problem.

于 2017-05-11T09:19:48.560 回答