我的代码中有一个 Android 位图,我想运行 cvCanny 方法就可以了。但是,它首先需要在 Mat 中。我如何能 将数据转换为 Mat,以及如何将其转换回 Bitmap 我受够了?
最佳答案
首先导入org.opencv.android.Utils
然后使用:
Mat src = new Mat();
Utils.bitmapToMat(bitmap, src);
执行边缘检测:
Mat dest = new Mat();
Imgproc.Canny(src, dest, min, max);
Bitmap edgeBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(dest, edgeBitmap);
//edgeBitmap is ready
关于android - 在 OpenCV 中将位图转换为垫子,反之亦然,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46876472/