-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
219 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,12 @@ import android.graphics.Bitmap | |
import android.graphics.Canvas | ||
import android.graphics.Color | ||
import android.graphics.Paint | ||
import com.king.camera.scan.util.LogUtils | ||
import com.king.logx.LogX | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
fun Bitmap.drawRect(block: (canvas: Canvas,paint: Paint) -> Unit): Bitmap { | ||
val result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) | ||
|
@@ -24,7 +26,7 @@ fun Bitmap.drawRect(block: (canvas: Canvas,paint: Paint) -> Unit): Bitmap { | |
canvas.save() | ||
canvas.restore() | ||
} catch (e: Exception) { | ||
LogUtils.w(e.message) | ||
LogX.w(e.message) | ||
} | ||
return result | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import androidx.appcompat.app.AppCompatActivity | |
import androidx.core.app.ActivityOptionsCompat | ||
import androidx.lifecycle.lifecycleScope | ||
import com.king.camera.scan.CameraScan | ||
import com.king.camera.scan.util.LogUtils | ||
import com.king.logx.LogX | ||
import com.king.opencv.qrcode.OpenCVQRCodeDetector | ||
import com.king.wechat.qrcode.WeChatQRCodeDetector | ||
import kotlinx.coroutines.Dispatchers | ||
|
@@ -21,6 +21,8 @@ import org.opencv.OpenCV | |
/** | ||
* 示例 | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
class MainActivity : AppCompatActivity() { | ||
|
||
|
@@ -74,13 +76,13 @@ class MainActivity : AppCompatActivity() { | |
if (result.isNotEmpty()) {// 不为空,则表示识别成功 | ||
// 打印所有结果 | ||
for ((index, text) in result.withIndex()) { | ||
LogUtils.d("result$index:$text") | ||
LogX.d("result$index:$text") | ||
} | ||
// 一般需求都是识别一个码,所以这里取第0个就可以;有识别多个码的需求,可以取全部 | ||
Toast.makeText(getContext(), result[0], Toast.LENGTH_SHORT).show() | ||
} else { | ||
// 为空表示识别失败 | ||
LogUtils.d("result = null") | ||
LogX.d("result = null") | ||
} | ||
} else { | ||
val result = withContext(Dispatchers.IO) { | ||
|
@@ -89,18 +91,18 @@ class MainActivity : AppCompatActivity() { | |
} | ||
|
||
if (!result.isNullOrEmpty()) {// 不为空,则表示识别成功 | ||
LogUtils.d("result$result") | ||
LogX.d("result: $result") | ||
Toast.makeText(getContext(), result, Toast.LENGTH_SHORT).show() | ||
} else { | ||
// 为空表示识别失败 | ||
LogUtils.d("result = null") | ||
LogX.d("result = null") | ||
} | ||
} | ||
|
||
} | ||
|
||
} catch (e: Exception) { | ||
LogUtils.w(e) | ||
LogX.w(e) | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ import com.king.opencv.qrcode.scanning.analyze.OpenCVScanningAnalyzer | |
* OpenCV二维码扫描实现示例 | ||
* | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
class OpenCVQRCodeActivity : OpenCVCameraScanActivity() { | ||
override fun onScanResultCallback(result: AnalyzeResult<MutableList<String>>) { | ||
|
@@ -31,7 +33,6 @@ class OpenCVQRCodeActivity : OpenCVCameraScanActivity() { | |
result.result.forEachIndexed{ index, data -> | ||
buffer.append("[$index] ").append(data).append("\n") | ||
} | ||
Log.w(TAG, "123456cols: ${result.points.cols()}, rows: ${result.points.rows()}") | ||
|
||
for (i in 0 until result.points.rows()) { | ||
result.points.row(i).let { mat -> | ||
|
@@ -79,7 +80,7 @@ class OpenCVQRCodeActivity : OpenCVCameraScanActivity() { | |
} | ||
|
||
override fun createAnalyzer(): Analyzer<MutableList<String>> { | ||
// 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可 | ||
// 如果需要返回结果二维码位置信息,则初始化分析器时,isOutputVertices参数传 true 即可 | ||
return OpenCVScanningAnalyzer(true) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ import com.king.wechat.qrcode.scanning.analyze.WeChatScanningAnalyzer | |
* 微信多二维码扫描实现示例 | ||
* | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
class WeChatMultiQRCodeActivity : WeChatCameraScanActivity() { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ import com.king.wechat.qrcode.scanning.analyze.WeChatScanningAnalyzer | |
* 微信二维码扫描实现示例 | ||
* | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
class WeChatQRCodeActivity : WeChatCameraScanActivity() { | ||
|
||
|
@@ -29,8 +31,8 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() { | |
// 停止分析 | ||
cameraScan.setAnalyzeImage(false) | ||
Log.d(TAG, result.result.toString()) | ||
val width = result.bitmapWidth | ||
val height = result.bitmapHeight | ||
val width = result.imageWidth | ||
val height = result.imageHeight | ||
|
||
// 当初始化 WeChatScanningAnalyzer 时,如果是需要二维码的位置信息,则可通过 WeChatScanningAnalyzer.QRCodeAnalyzeResult 获取 | ||
if (result is WeChatScanningAnalyzer.QRCodeAnalyzeResult) { // 如果需要处理结果二维码的位置信息 | ||
|
@@ -92,7 +94,7 @@ class WeChatQRCodeActivity : WeChatCameraScanActivity() { | |
override fun createAnalyzer(): Analyzer<MutableList<String>> { | ||
// 分析器默认不会返回结果二维码的位置信息 | ||
// return WeChatScanningAnalyzer() | ||
// 如果需要返回结果二维码位置信息,则初始化分析器时,参数传 true 即可 | ||
// 如果需要返回结果二维码位置信息,则初始化分析器时,isOutputVertices参数传 true 即可 | ||
return WeChatScanningAnalyzer(true) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## 版本记录 | ||
|
||
#### v2.2.0:2024-7-11 | ||
* 更新CameraScan至v1.2.0 | ||
* 更新ViewfinderView至v1.2.0 | ||
* 使用[LogX](https://github.com/jenly1314/LogX) 来统一管理日志 | ||
* 优化一些细节 | ||
|
||
#### v2.1.0:2024-1-13 | ||
* 更新OpenCV至v4.9.0 | ||
* 更新CameraScan至v1.1.0 | ||
* 更新compileSdkVersion至34 | ||
* 更新Gradle至v8.0 | ||
|
||
#### 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) | ||
* 优化扫描分析过程的性能体验(优化帧数据分析过程) | ||
|
||
#### v1.3.0:2023-4-16 | ||
* 新增OpenCV二维码扫码识别库(opencv-qrcode和opencv-qrcode-scanning) | ||
* 更新mlkit-camera-core至v1.4.0 | ||
* 更新compileSdkVersion至33 | ||
* 更新Gradle至v7.5 | ||
|
||
#### v1.2.1:2023-2-27 | ||
* 优化细节 | ||
|
||
#### v1.2.0:2022-8-4 | ||
* 更新OpenCV至v4.6.0 | ||
|
||
#### v1.1.1:2021-11-2 | ||
* 优化细节 | ||
* 更新mlkit-camera-core至v1.0.3 | ||
|
||
#### v1.1.0:2021-8-6 | ||
* 编译多种ABI支持 | ||
* 更新mlkit-camera-core至v1.0.2 | ||
|
||
#### v1.0.0:2021-7-24 | ||
* WeChatQRCode初始版本 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
* 通过继承 {@link OpenCVCameraScanActivity}或{@link OpenCVCameraScanFragment}可快速实现二维码扫描 | ||
* | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
public abstract class OpenCVCameraScanActivity extends BaseCameraScanActivity<List<String>> { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
* 通过继承 {@link OpenCVCameraScanActivity}或{@link OpenCVCameraScanFragment}可快速实现二维码扫描 | ||
* | ||
* @author <a href="mailto:[email protected]">Jenly</a> | ||
* <p> | ||
* <a href="https://github.com/jenly1314">Follow me</a> | ||
*/ | ||
public abstract class OpenCVCameraScanFragment extends BaseCameraScanFragment<List<String>> { | ||
|
||
|
Oops, something went wrong.