Skip to content

Commit

Permalink
发布v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jenly1314 committed Sep 13, 2023
1 parent 0f125a0 commit d887fc4
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 63 deletions.
62 changes: 33 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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)
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 8,
"versionName": "2.0.0",
"versionCode": 9,
"versionName": "2.0.1",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/king/wechat/qrcode/app/Function.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.king.camera.scan.util.LogUtils
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class OpenCVQRCodeActivity : OpenCVCameraScanActivity() {
}
}

override fun createAnalyzer(): Analyzer<MutableList<String>>? {
override fun createAnalyzer(): Analyzer<MutableList<String>> {
// 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可
return OpenCVScanningAnalyzer(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class WeChatMultiQRCodeActivity : WeChatCameraScanActivity() {
}
}

override fun createAnalyzer(): Analyzer<MutableList<String>>? {
override fun createAnalyzer(): Analyzer<MutableList<String>> {
// 分析器默认不会返回结果二维码的位置信息
// return WeChatScanningAnalyzer()
// 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) { // 如果需要处理结果二维码的位置信息
//取预览当前帧图片并显示,为结果点提供参照
Expand Down Expand Up @@ -94,7 +89,7 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() {
}
}

override fun createAnalyzer(): Analyzer<MutableList<String>>? {
override fun createAnalyzer(): Analyzer<MutableList<String>> {
// 分析器默认不会返回结果二维码的位置信息
// return WeChatScanningAnalyzer()
// 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可
Expand Down
2 changes: 2 additions & 0 deletions gitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk11
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opencv-qrcode-scanning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void analyze(@NonNull ImageProxy imageProxy, @NonNull Analyzer.OnAnalyzeL
* 检测并识别二维码
*
* @param nv21
* @param isOutputVertices
* @param isOutputVertices 是否输出二维码顶点坐标
* @return
*/
@Nullable
Expand All @@ -111,7 +111,7 @@ private AnalyzeResult<List<String>> detectAndDecode(byte[] nv21, FrameMetadata f
String result = mDetector.detectAndDecode(bgrMat, points);
bgrMat.release();
if (result != null && !result.isEmpty()) {
List<String> list = new ArrayList();
List<String> list = new ArrayList<>();
list.add(result);
return new QRCodeAnalyzeResult<>(nv21, ImageFormat.NV21, frameMetadata, list, points);
}
Expand All @@ -120,7 +120,7 @@ private AnalyzeResult<List<String>> detectAndDecode(byte[] nv21, FrameMetadata f
String result = mDetector.detectAndDecode(bgrMat);
bgrMat.release();
if (result != null && !result.isEmpty()) {
List<String> list = new ArrayList();
List<String> list = new ArrayList<>();
list.add(result);
return new QRCodeAnalyzeResult<>(nv21, ImageFormat.NV21, frameMetadata, list);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@SuppressWarnings("unused")
public class OpenCVQRCodeDetector extends QRCodeDetector {

/**
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

Expand Down
8 changes: 4 additions & 4 deletions versions.gradle
Original file line number Diff line number Diff line change
@@ -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 = [:]
Expand Down Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion wechat-qrcode-scanning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void analyze(@NonNull ImageProxy imageProxy, @NonNull Analyzer.OnAnalyzeL
* 检测并识别二维码
*
* @param nv21
* @param isOutputVertices
* @param isOutputVertices 是否输出二维码顶点坐标
* @return
*/
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
*
* @author <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@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;

Expand All @@ -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();
Expand All @@ -63,9 +64,8 @@ private static void initWeChatQRCode(Context context) {
break;
}
}
} else {
saveDir.mkdirs();
}

if (!exists) {
// 模型文件只要有一个不存在,则遍历拷贝
for (String model : models) {
Expand Down

0 comments on commit d887fc4

Please sign in to comment.