基于Google ML Kit 快速集成二维码扫描,速度比zxing快,可配置相册,闪光灯,相机可以调整焦距放大缩小,自定义扫描线颜色,自定义背景颜色,自定义遮罩层,支持同时扫多个二维码和条形码

Related tags

GUI MNMLKitScanner
Overview

MNMLKitScanner 基于Google MLKit 快速集成二维码扫描,速度比zxing快

基于Google MLKit 快速集成二维码扫描,速度比zxing快,可配置相册,闪光灯,相机可以调整焦距放大缩小,自定义扫描线颜色,自定义背景颜色,自定义遮罩层,支持同时扫多个二维码和条形码

功能:

1:二维码扫描,手势缩放,无拉伸,样式自定义
2:相册中选取图片识别
3: 相机可以调整焦距放大缩小
4: 完全自定义遮罩层
5: 支持微信多个二维码/条形码同时扫描

截图:

如何添加

Gradle添加:

1.在Project的build.gradle中添加仓库地址

	allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

2.在Module目录下的build.gradle中添加依赖

	dependencies {

            implementation 'com.github.maning0303:MNMLKitScanner:V1.0.0'

	}

使用方法:

进入需要提前申请相机权限;进入需要提前申请相机权限;进入需要提前申请相机权限;

        1:开始扫描:
            //默认扫描
            MNScanManager.startScan(this, new MNScanCallback() {
                   @Override
                   public void onActivityResult(int resultCode, Intent data) {
                    switch (resultCode) {
                        case MNScanManager.RESULT_SUCCESS:
                            String resultSuccess = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
                            break;
                        case MNScanManager.RESULT_FAIL:
                            String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
                            break;
                        case MNScanManager.RESULT_CANCLE:
                            showToast("取消扫码");
                            break;
                    }
                   }
            });
            
            //自定义扫描
            MNScanConfig scanConfig = new MNScanConfig.Builder()
                    //设置完成震动
                    .isShowVibrate(true)
                    //扫描完成声音
                    .isShowBeep(true)
                    //显示相册功能
                    .isShowPhotoAlbum(true)
                    //显示闪光灯
                    .isShowLightController(true)
                    //打开扫描页面的动画
                    .setActivityOpenAnime(R.anim.activity_anmie_in)
                    //退出扫描页面动画
                    .setActivityExitAnime(R.anim.activity_anmie_out)
                    //自定义文案
                    .setScanHintText("xxxx")
                    .setScanHintTextColor("#FF0000")
                    .setScanHintTextSize(14)
                    //扫描线的颜色
                    .setScanColor("#FF0000")
                    //是否支持手势缩放
                    .setSupportZoom(true)
                    //扫描线样式
                    .setLaserStyle(MNScanConfig.LaserStyle.Grid/MNScanConfig.LaserStyle.Line)
                    //背景颜色
                    .setBgColor("")
                    //网格扫描线的列数
                    .setGridScanLineColumn(30)
                    //网格高度
                    .setGridScanLineHeight(300)
                    //是否全屏扫描,默认全屏
                    .setFullScreenScan(true)
                    //单位dp
                    .setResultPointConfigs(36, 12, 3, colorResultPointStroke, colorResultPoint)
                    //状态栏设置
                    .setStatusBarConfigs(colorStatusBar, true)
                    //自定义遮罩
                    .setCustomShadeViewLayoutID(R.layout.layout_custom_view, new MNCustomViewBindCallback() {
                        @Override
                        public void onBindView(View customView) {
                            //TODO:通过findviewById 获取View
                        }
                    })
                    .builder();
            MNScanManager.startScan(this, scanConfig, new MNScanCallback() {
                @Override
                public void onActivityResult(int resultCode, Intent data) {
                    switch (resultCode) {
                        case MNScanManager.RESULT_SUCCESS:
                            String resultSuccess = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
                            break;
                        case MNScanManager.RESULT_FAIL:
                            String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
                            break;
                        case MNScanManager.RESULT_CANCLE:
                            showToast("取消扫码");
                            break;
                    }
                }
            });

        2.提供扫描界面相关方法(自定义遮罩层会使用):
            /**
             * 关闭当前页面
             */
            MNScanManager.closeScanPage();

            /**
             * 打开相册扫描图片
             */
            MNScanManager.openAlbumPage();

            /**
             * 打开手电筒
             */
            MNScanManager.openScanLight();

            /**
             * 关闭手电筒
             */
            MNScanManager.closeScanLight();

            /**
             * 手电筒是否开启
             */
            MNScanManager.isLightOn();

感谢:

googlesamples/mlkit

jenly1314/MLKit

Ye-Miao/StatusBarUtil

感谢所有开源的人;

推荐:

Name Describe
GankMM (Material Design & MVP & Retrofit + OKHttp & RecyclerView ...)Gank.io Android客户端:每天一张美女图片,一个视频短片,若干Android,iOS等程序干货,周一到周五每天更新,数据全部由 干货集中营 提供,持续更新。
MNUpdateAPK Android APK 版本更新的下载和安装,适配7.0,简单方便。
MNImageBrowser 交互特效的图片浏览框架,微信向下滑动动态关闭
MNZXingCode 快速集成二维码扫描和生成二维码
MNMLKitScanner 基于Google MLKit 快速集成二维码扫描,速度比zxing快
MNPasswordEditText 类似微信支付宝的密码输入框。
MClearEditText 带有删除功能的EditText
MNCrashMonitor Debug监听程序崩溃日志,展示崩溃日志列表,方便自己平时调试。
MNProgressHUD MNProgressHUD是对常用的自定义弹框封装,加载ProgressDialog,状态显示的StatusDialog和自定义Toast,支持背景颜色,圆角,边框和文字的自定义。
SwitcherView 垂直滚动的广告栏文字展示。
MNVideoPlayer SurfaceView + MediaPlayer 实现的视频播放器,支持横竖屏切换,手势快进快退、调节音量,亮度等。------代码简单,新手可以看一看。
MNChangeSkin Android夜间模式,通过Theme实现
MNXUtilsDB xUtils3 数据库模块单独抽取出来,方便使用。
MNCalendar 简单的日历控件练习,水平方向日历支持手势滑动切换,跳转月份;垂直方向日历选取区间范围。
MNSwipeToLoadDemo 利用SwipeToLoadLayout实现的各种下拉刷新效果(饿了吗,京东,百度外卖,美团外卖,天猫下拉刷新等)。
You might also like...

React Native On-Device Machine Learning w/ Google ML Kit

React Native ML Kit React Native On-Device Machine Learning w/ Google ML Kit Supported Modules Module Android iOS Image Labeling ✅ ✅ Identify Language

Dec 29, 2022

Google's ML-Kit-Vision demo (android) for pre encoded video.

Google's ML-Kit-Vision demo (android) for pre encoded video.

Android ML Kit Vision demo with Video Google's ML-Kit-Vision demo (android) for pre encoded video. Demos for camera preview and still image are also i

Dec 29, 2022
Comments
  • EAN 128格式条码 扫码结果字符串里开头会多出

    EAN 128格式条码 扫码结果字符串里开头会多出"]C1"字符

    如题, 使用Demo测试了EAN 128编码的条码, 发现会多出"]C1"字符, barcode.getRawValue()得到的结果是包含"]C1"的, 作者不考虑用barcode.getDisplayValue()的值作为扫码结果吗. 🍰 条码生成网站: https://www.barcode-generator.de/V2/zh/index.jsp 测试条码类型: EAN 128编码 🍨 MLKit有类似issue https://github.com/googlesamples/mlkit/issues/348

    bug 
    opened by yeyesama 2
  • 17.0.2版本 ML Kit 扫描后崩溃

    17.0.2版本 ML Kit 扫描后崩溃

    17.0.2版本的Barcode已经移到com.google.mlkit.vision.barcode.common.Barcode

    MLKit版本

    com.google.mlkit:barcode-scanning:17.0.2

    相关包

        def camerax_version = "1.2.0-alpha02"
        implementation "androidx.camera:camera-core:${camerax_version}"
        implementation "androidx.camera:camera-camera2:${camerax_version}"
        implementation "androidx.camera:camera-lifecycle:${camerax_version}"
        implementation "androidx.camera:camera-view:${camerax_version}"
    
        implementation 'com.google.mlkit:barcode-scanning:17.0.2'
        implementation 'com.github.maning0303:MNMLKitScanner:V1.0.1'
    

    报错内容

    E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.yuyuko233.notificationsynchelper, PID: 18851
        java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/mlkit/vision/barcode/Barcode;
            at com.maning.mlkitscanner.scan.analyser.BarcodeAnalyser$3.onSuccess(BarcodeAnalyser.java:107)
            at com.maning.mlkitscanner.scan.analyser.BarcodeAnalyser$3.onSuccess(BarcodeAnalyser.java:97)
            at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.1:1)
            at android.os.Handler.handleCallback(Handler.java:938)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:236)
            at android.app.ActivityThread.main(ActivityThread.java:8168)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.mlkit.vision.barcode.Barcode" on path: DexPathList[[zip file "/data/app/~~elKMI1T8tIEHWdKbA1fPgg==/com.yuyuko233.notificationsynchelper-CcEORu9cUdfXuElgDSDkyw==/base.apk"],nativeLibraryDirectories=[/data/app/~~elKMI1T8tIEHWdKbA1fPgg==/com.yuyuko233.notificationsynchelper-CcEORu9cUdfXuElgDSDkyw==/lib/arm64, /data/app/~~elKMI1T8tIEHWdKbA1fPgg==/com.yuyuko233.notificationsynchelper-CcEORu9cUdfXuElgDSDkyw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            at com.maning.mlkitscanner.scan.analyser.BarcodeAnalyser$3.onSuccess(BarcodeAnalyser.java:107) 
            at com.maning.mlkitscanner.scan.analyser.BarcodeAnalyser$3.onSuccess(BarcodeAnalyser.java:97) 
            at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.1:1) 
            at android.os.Handler.handleCallback(Handler.java:938) 
            at android.os.Handler.dispatchMessage(Handler.java:99) 
            at android.os.Looper.loop(Looper.java:236) 
            at android.app.ActivityThread.main(ActivityThread.java:8168) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) 
    
    opened by yuyuko233 2
  • 崩溃报错

    崩溃报错

    原因可能在于我引用了一个第三方库也包含camera-camera2: 报错信息如下 java.lang.IllegalStateException: CameraX is not configured properly. The most likely cause is you did not include a default implementation in your build such as 'camera-camera2'. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2670) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2731) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6161) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) Caused by: java.lang.IllegalStateException: CameraX is not configured properly. The most likely cause is you did not include a default implementation in your build such as 'camera-camera2'. at androidx.camera.core.CameraX.getOrCreateInstance(CameraX.java:360) at androidx.camera.lifecycle.ProcessCameraProvider.getInstance(ProcessCameraProvider.java:154) at com.maning.mlkitscanner.scan.camera.CameraManager.startCamera(CameraManager.java:91) at com.maning.mlkitscanner.scan.ui.ScanPreviewActivity.startCamera(ScanPreviewActivity.java:129) at com.maning.mlkitscanner.scan.ui.ScanPreviewActivity.initPermission(ScanPreviewActivity.java:106) at com.maning.mlkitscanner.scan.ui.ScanPreviewActivity.onCreate(ScanPreviewActivity.java:73) at android.app.Activity.performCreate(Activity.java:6698) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)

    opened by billdizl 1
Releases(V1.0.4)
Owner
MaNing
MaNing
HUAWEI 3D Modeling Kit project contains a sample app. Guided by this demo, you will be able to implement full 3D Modeling Kit capabilities, including 3D object reconstruction and material generation.

HUAWEI 3D Modeling Kit Sample English | 中文 Introduction This project includes apps developed based on HUAWEI 3D Modeling Kit. The project directory is

HMS 59 Jan 1, 2023
Vert.x is a tool-kit for building reactive applications on the JVM

Vert.x Core This is the repository for Vert.x core. Vert.x core contains fairly low-level functionality, including support for HTTP, TCP, file system

Eclipse Vert.x 13.3k Jan 8, 2023
http-kit is a minimalist, event-driven, high-performance Clojure HTTP server/client library with WebSocket and asynchronous support

HTTP Kit A simple, high-performance event-driven HTTP client+server for Clojure CHANGELOG | API | current Break Version: [http-kit "2.5.3"] ; Publish

HTTP Client/Server for Clojure 2.3k Dec 31, 2022
Tencent Kona JDK11 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) with quarterly updates. Tencent Kona JDK11 is certified as compatible with the Java SE standard.

Tencent Kona JDK11 Tencent Kona JDK11 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) w

Tencent 268 Dec 16, 2022
Tencent Kona JDK17 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) with quarterly updates.

Tencent Kona JDK17 Tencent Kona JDK17 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) w

Tencent 59 Nov 30, 2022
The ByteSkript development kit, including resources for third-party libraries that are not contained within the standard runtime.

ByteSkript Development Kit Todo. The development kit is a set of advanced resources available for library creators. These are not available within the

null 1 Jan 8, 2022
JNDI-Exploit-Kit

JNDI-Exploit-Kit Disclaimer This is a forked modified version of the great exploitation tool created by @welk1n

puckie 20 Dec 7, 2022
Mod development kit for the Tecknix Client Modding API

Tecknix Mod Loader API THIS API IS NOT COMPLETE AND WILL NOT YET ALLOW YOU TO MOD THE CLIENT What is this? This is our modding MDK for Tecknix Client.

Tecknix Client 6 Sep 12, 2022
GitHub Action to download and install Oracle's Java Development Kit builds

oracle-actions/setup-java This action downloads a Java Development Kit (JDK) built by Oracle and installs it using actions/setup-java. JDKs built by O

Oracle GitHub Actions 43 Dec 15, 2022
The VAST ad sample code provided by HUAWEI Ads Kit describes how to display linear ads by integrating the HUAWEI VAST SDK into your app.

HMS Ads Demo for VAST English | 中文 Table of Contents Introduction Installation Configuration Supported Environments Sample Code Result License Introdu

HMS 11 Jul 16, 2022