1.添加依赖 // OpenCV基础库(*必须) implementation 'com.github.jenly1314.WeChatQRCode:opencv:2.0.1' implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv7a:2.0.1' // OpenCV的其他ABI(可选),根据你的需要选择想要支持的SO库架构 implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv64:2.0.1' // 微信二维码识别功能(可选) implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode:2.0.1'
API需要等于大于33
2.初始化
OpenCV.initAsync(context); //初始化WeChatQRCodeDetector WeChatQRCodeDetector.init(context);
3.识别
public static String detectAndDecode(Bitmap bitmap) { List<String> results = WeChatQRCodeDetector.detectAndDecode(bitmap); return results.get(0);//图片中只有一个二维码,返回集合中的0下标即可 }