Android中opencv快速使用

1.app的build.gradle中添加依赖

implementation com.quickbirdstudios:opencv:4.3.0

2.MainActivity中判断成功与否

        if (!OpenCVLoader.initDebug())
            Log.e("OpenCv", "Unable to load OpenCV");
        else
            Log.d("OpenCv", "OpenCV loaded");

3.将bitmap图片转为mat

Mat srcv = new Mat(bitmapNew_x.getHeight(), bitmapNew_x.getWidth(), CvType.CV_8UC4);
Utils.bitmapToMat(bitmapNew_x, srcv);// turn bitmap into mat

4.将mat转为bitmap

final Bitmap lunju_x = bitmapNew_x.copy(Bitmap.Config.ARGB_8888, false);
        Utils.matToBitmap(srcv, lunju_x);

5.显示图片

imageView.setImageBitmap(lunju_x);

 

Android中opencv快速使用

上一篇:iOS学习之字符串(NSString)的截取、匹配、分隔


下一篇:181 01 Android 零基础入门 03 Java常用工具类03 Java字符串 02 String类 01 String常用方法简介