diff --git a/README.md b/README.md index ce1e540..981c283 100644 --- a/README.md +++ b/README.md @@ -77,43 +77,43 @@ OpenCV二维码扫码:有了上面的OpenCV二维码识别功能,基本的 1. 在Project的 **build.gradle** 或 **setting.gradle** 中添加远程仓库 -```gradle -repositories { - //... - mavenCentral() - maven { url 'https://jitpack.io' } -} -``` + ```gradle + repositories { + //... + mavenCentral() + maven { url 'https://jitpack.io' } + } + ``` 2. 在Module的 **build.gradle** 里面添加引入依赖项 -```gradle -// OpenCV基础库(*必须) -implementation 'com.github.jenly1314.WeChatQRCode:opencv:2.0.0' -implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv7a:2.0.0' - -// OpenCV的其他ABI(可选),根据你的需要选择想要支持的SO库架构 -implementation 'com.github.jenly1314.WeChatQRCode:opencv-armv64:2.0.0' -implementation 'com.github.jenly1314.WeChatQRCode:opencv-x86:2.0.0' -implementation 'com.github.jenly1314.WeChatQRCode:opencv-x86_64:2.0.0' - -// OpenCV二维码识别功能(可选) -implementation 'com.github.jenly1314.WeChatQRCode:opencv-qrcode:2.0.0' -// OpenCV二维码扫码功能(可选) -implementation 'com.github.jenly1314.WeChatQRCode:opencv-qrcode-scanning:2.0.0' - -// 微信二维码识别功能(可选) -implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode:2.0.0' -// 微信二维码扫码功能(可选) -implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode-scanning:2.0.0' - -``` + ```gradle + // 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:opencv-x86:2.0.1' + implementation 'com.github.jenly1314.WeChatQRCode:opencv-x86_64:2.0.1' + + // OpenCV二维码识别功能(可选) + implementation 'com.github.jenly1314.WeChatQRCode:opencv-qrcode:2.0.1' + // OpenCV二维码扫码功能(可选) + implementation 'com.github.jenly1314.WeChatQRCode:opencv-qrcode-scanning:2.0.1' + + // 微信二维码识别功能(可选) + implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode:2.0.1' + // 微信二维码扫码功能(可选) + implementation 'com.github.jenly1314.WeChatQRCode:wechat-qrcode-scanning:2.0.1' + + ``` ### 温馨提示 #### 关于WeChatQRCode版本与编译的SDK版本要求 -> 使用 v1.3.x 以上版本时,要求 compileSdkVersion >= 33 +> 使用 v2.x 以上版本时,要求 compileSdkVersion >= 33 > 如果 **compileSdkVersion < 33** 请使用 [**v1.x版本**](https://github.com/jenly1314/WeChatQRCode/tree/1.x/) @@ -356,6 +356,10 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() { ## 版本记录 +#### v2.0.1:2023-9-13 +* 更新CameraScan至v1.0.1 +* 更新ViewfinderView至v1.1.0 + #### v2.0.0:2023-8-14 * **wechat-qrcode-scanning** 和 **opencv-qrcode-scanning** 中移除原依赖(**mlkit-camera-core**),现改为依赖[CameraScan](https://github.com/jenly1314/CameraScan) * **wechat-qrcode-scanning** 和 **opencv-qrcode-scanning** 添加默认依赖[ViewfinderView](https://github.com/jenly1314/ViewfinderView) diff --git a/app/release/app-release.apk b/app/release/app-release.apk index 31ac50f..c0cb25c 100644 Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 7a796f2..8e76f1e 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 8, - "versionName": "2.0.0", + "versionCode": 9, + "versionName": "2.0.1", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/java/com/king/wechat/qrcode/app/Function.kt b/app/src/main/java/com/king/wechat/qrcode/app/Function.kt index fee5683..cb5a37d 100644 --- a/app/src/main/java/com/king/wechat/qrcode/app/Function.kt +++ b/app/src/main/java/com/king/wechat/qrcode/app/Function.kt @@ -10,7 +10,7 @@ import com.king.camera.scan.util.LogUtils * @author Jenly */ fun Bitmap.drawRect(block: (canvas: Canvas,paint: Paint) -> Unit): Bitmap { - var result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) + val result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) try { val canvas = Canvas(result) canvas.drawBitmap(this, 0f, 0f, null) diff --git a/app/src/main/java/com/king/wechat/qrcode/app/OpenCVQRCodeActivity.kt b/app/src/main/java/com/king/wechat/qrcode/app/OpenCVQRCodeActivity.kt index 8755c25..4daa07e 100644 --- a/app/src/main/java/com/king/wechat/qrcode/app/OpenCVQRCodeActivity.kt +++ b/app/src/main/java/com/king/wechat/qrcode/app/OpenCVQRCodeActivity.kt @@ -78,7 +78,7 @@ class OpenCVQRCodeActivity : OpenCVCameraScanActivity() { } } - override fun createAnalyzer(): Analyzer>? { + override fun createAnalyzer(): Analyzer> { // 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可 return OpenCVScanningAnalyzer(true) } diff --git a/app/src/main/java/com/king/wechat/qrcode/app/WeChatMultiQRCodeActivity.kt b/app/src/main/java/com/king/wechat/qrcode/app/WeChatMultiQRCodeActivity.kt index 7380d5d..5d585e0 100644 --- a/app/src/main/java/com/king/wechat/qrcode/app/WeChatMultiQRCodeActivity.kt +++ b/app/src/main/java/com/king/wechat/qrcode/app/WeChatMultiQRCodeActivity.kt @@ -81,7 +81,7 @@ class WeChatMultiQRCodeActivity : WeChatCameraScanActivity() { } } - override fun createAnalyzer(): Analyzer>? { + override fun createAnalyzer(): Analyzer> { // 分析器默认不会返回结果二维码的位置信息 // return WeChatScanningAnalyzer() // 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可 diff --git a/app/src/main/java/com/king/wechat/qrcode/app/WeChatQRCodeActivity.kt b/app/src/main/java/com/king/wechat/qrcode/app/WeChatQRCodeActivity.kt index 92dbaa0..1e12daf 100644 --- a/app/src/main/java/com/king/wechat/qrcode/app/WeChatQRCodeActivity.kt +++ b/app/src/main/java/com/king/wechat/qrcode/app/WeChatQRCodeActivity.kt @@ -8,7 +8,6 @@ import com.king.camera.scan.AnalyzeResult import com.king.camera.scan.CameraScan import com.king.camera.scan.analyze.Analyzer import com.king.camera.scan.util.PointUtils -import com.king.view.viewfinderview.ViewfinderView import com.king.wechat.qrcode.scanning.WeChatCameraScanActivity import com.king.wechat.qrcode.scanning.analyze.WeChatScanningAnalyzer @@ -30,13 +29,9 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() { // 停止分析 cameraScan.setAnalyzeImage(false) Log.d(TAG, result.result.toString()) - val frameMetadata = result.frameMetadata - var width = frameMetadata.width - var height = frameMetadata.height - if(frameMetadata.rotation == 90 || frameMetadata.rotation == 270) { - width = frameMetadata.height - height = frameMetadata.width - } + val width = result.bitmapWidth + val height = result.bitmapHeight + // 当初始化 WeChatScanningAnalyzer 时,如果是需要二维码的位置信息,则会返回 WeChatScanningAnalyzer.QRCodeAnalyzeResult if (result is WeChatScanningAnalyzer.QRCodeAnalyzeResult) { // 如果需要处理结果二维码的位置信息 //取预览当前帧图片并显示,为结果点提供参照 @@ -94,7 +89,7 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() { } } - override fun createAnalyzer(): Analyzer>? { + override fun createAnalyzer(): Analyzer> { // 分析器默认不会返回结果二维码的位置信息 // return WeChatScanningAnalyzer() // 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可 diff --git a/gitpack.yml b/gitpack.yml new file mode 100644 index 0000000..adb3fe1 --- /dev/null +++ b/gitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk11 diff --git a/gradle.properties b/gradle.properties index b911c69..0c7089e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,8 +18,8 @@ android.useAndroidX = true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style = official -VERSION_NAME=2.0.0 -VERSION_CODE=8 +VERSION_NAME=2.0.1 +VERSION_CODE=9 GROUP=com.github.jenly1314.WeChatQRCode POM_DESCRIPTION=Wechat QRCode diff --git a/opencv-qrcode-scanning/build.gradle b/opencv-qrcode-scanning/build.gradle index 24412aa..d3ebc6a 100644 --- a/opencv-qrcode-scanning/build.gradle +++ b/opencv-qrcode-scanning/build.gradle @@ -39,7 +39,7 @@ dependencies { androidTestImplementation "androidx.test.ext:junit:$versions.androidExtJunit" androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espressoCore" - api "com.github.jenly1314:CameraScan:$versions.cameraScan" + api "com.github.jenly1314:camera-scan:$versions.cameraScan" api "com.github.jenly1314:viewfinderview:$versions.viewfinderview" compileOnly project(path: ':opencv') diff --git a/opencv-qrcode-scanning/src/main/java/com/king/opencv/qrcode/scanning/analyze/OpenCVScanningAnalyzer.java b/opencv-qrcode-scanning/src/main/java/com/king/opencv/qrcode/scanning/analyze/OpenCVScanningAnalyzer.java index a676265..a249c9c 100644 --- a/opencv-qrcode-scanning/src/main/java/com/king/opencv/qrcode/scanning/analyze/OpenCVScanningAnalyzer.java +++ b/opencv-qrcode-scanning/src/main/java/com/king/opencv/qrcode/scanning/analyze/OpenCVScanningAnalyzer.java @@ -94,7 +94,7 @@ public void analyze(@NonNull ImageProxy imageProxy, @NonNull Analyzer.OnAnalyzeL * 检测并识别二维码 * * @param nv21 - * @param isOutputVertices + * @param isOutputVertices 是否输出二维码顶点坐标 * @return */ @Nullable @@ -111,7 +111,7 @@ private AnalyzeResult> detectAndDecode(byte[] nv21, FrameMetadata f String result = mDetector.detectAndDecode(bgrMat, points); bgrMat.release(); if (result != null && !result.isEmpty()) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(result); return new QRCodeAnalyzeResult<>(nv21, ImageFormat.NV21, frameMetadata, list, points); } @@ -120,7 +120,7 @@ private AnalyzeResult> detectAndDecode(byte[] nv21, FrameMetadata f String result = mDetector.detectAndDecode(bgrMat); bgrMat.release(); if (result != null && !result.isEmpty()) { - List list = new ArrayList(); + List list = new ArrayList<>(); list.add(result); return new QRCodeAnalyzeResult<>(nv21, ImageFormat.NV21, frameMetadata, list); } diff --git a/opencv-qrcode/src/main/java/com/king/opencv/qrcode/OpenCVQRCodeDetector.java b/opencv-qrcode/src/main/java/com/king/opencv/qrcode/OpenCVQRCodeDetector.java index fbfc732..81240c1 100644 --- a/opencv-qrcode/src/main/java/com/king/opencv/qrcode/OpenCVQRCodeDetector.java +++ b/opencv-qrcode/src/main/java/com/king/opencv/qrcode/OpenCVQRCodeDetector.java @@ -13,6 +13,7 @@ * * @author Jenly */ +@SuppressWarnings("unused") public class OpenCVQRCodeDetector extends QRCodeDetector { /** diff --git a/settings.gradle b/settings.gradle index 72f30de..23a6012 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,7 +10,6 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } } } diff --git a/versions.gradle b/versions.gradle index 84d2a65..481acf1 100644 --- a/versions.gradle +++ b/versions.gradle @@ -1,7 +1,7 @@ //App def app_version = [:] -app_version.versionCode = 8 -app_version.versionName = "2.0.0" +app_version.versionCode = 9 +app_version.versionName = "2.0.1" ext.app_version = app_version def opencv_version = [:] @@ -36,8 +36,8 @@ versions.androidExtJunit = "1.1.3" versions.espressoCore = "3.4.0" versions.lifecycleKtx="2.3.1" -versions.viewfinderview="1.0.0" -versions.cameraScan="1.0.0" +versions.viewfinderview="1.1.0" +versions.cameraScan="1.0.1" versions.appDialog="1.1.4" diff --git a/wechat-qrcode-scanning/build.gradle b/wechat-qrcode-scanning/build.gradle index ab0f370..809103c 100644 --- a/wechat-qrcode-scanning/build.gradle +++ b/wechat-qrcode-scanning/build.gradle @@ -39,7 +39,7 @@ dependencies { androidTestImplementation "androidx.test.ext:junit:$versions.androidExtJunit" androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espressoCore" - api "com.github.jenly1314:CameraScan:$versions.cameraScan" + api "com.github.jenly1314:camera-scan:$versions.cameraScan" api "com.github.jenly1314:viewfinderview:$versions.viewfinderview" compileOnly project(path: ':opencv') diff --git a/wechat-qrcode-scanning/src/main/java/com/king/wechat/qrcode/scanning/analyze/WeChatScanningAnalyzer.java b/wechat-qrcode-scanning/src/main/java/com/king/wechat/qrcode/scanning/analyze/WeChatScanningAnalyzer.java index acf5d2b..5568b30 100644 --- a/wechat-qrcode-scanning/src/main/java/com/king/wechat/qrcode/scanning/analyze/WeChatScanningAnalyzer.java +++ b/wechat-qrcode-scanning/src/main/java/com/king/wechat/qrcode/scanning/analyze/WeChatScanningAnalyzer.java @@ -92,7 +92,7 @@ public void analyze(@NonNull ImageProxy imageProxy, @NonNull Analyzer.OnAnalyzeL * 检测并识别二维码 * * @param nv21 - * @param isOutputVertices + * @param isOutputVertices 是否输出二维码顶点坐标 * @return */ @Nullable diff --git a/wechat-qrcode/src/main/java/com/king/wechat/qrcode/WeChatQRCodeDetector.java b/wechat-qrcode/src/main/java/com/king/wechat/qrcode/WeChatQRCodeDetector.java index 651ea63..526172b 100644 --- a/wechat-qrcode/src/main/java/com/king/wechat/qrcode/WeChatQRCodeDetector.java +++ b/wechat-qrcode/src/main/java/com/king/wechat/qrcode/WeChatQRCodeDetector.java @@ -19,15 +19,16 @@ * * @author Jenly */ +@SuppressWarnings("unused") public final class WeChatQRCodeDetector { private static final String TAG = "WeChatQRCodeDetector"; private static final String MODEL_DIR = "models"; - private static final String DETECT_PROTOTXT = "detect.prototxt"; - private static final String DETECT_CAFFEMODEL = "detect.caffemodel"; - private static final String SR_PROTOTXT = "sr.prototxt"; - private static final String SR_CAFFEMODEL = "sr.caffemodel"; + private static final String DETECT_PROTO_TXT = "detect.prototxt"; + private static final String DETECT_CAFFE_MODEL = "detect.caffemodel"; + private static final String SR_PROTO_TXT = "sr.prototxt"; + private static final String SR_CAFFE_MODEL = "sr.caffemodel"; private static WeChatQRCode sWeChatQRCode; @@ -51,7 +52,7 @@ public static void init(Context context) { private static void initWeChatQRCode(Context context) { try { String saveDirPath = getExternalFilesDir(context, MODEL_DIR); - String[] models = new String[]{DETECT_PROTOTXT, DETECT_CAFFEMODEL, SR_PROTOTXT, SR_CAFFEMODEL}; + String[] models = new String[]{DETECT_PROTO_TXT, DETECT_CAFFE_MODEL, SR_PROTO_TXT, SR_CAFFE_MODEL}; File saveDir = new File(saveDirPath); boolean exists = saveDir.exists(); @@ -63,9 +64,8 @@ private static void initWeChatQRCode(Context context) { break; } } - } else { - saveDir.mkdirs(); } + if (!exists) { // 模型文件只要有一个不存在,则遍历拷贝 for (String model : models) {