A library to help implement barcode scanning

Overview

KBarcode

Maven Central

A library to help implement barcode scanning.





Why?

Another barcode library. Yawn.

We can understand why you may think that, but there are some key reasons we decided to write a new barcode library.

  • Quality We want this library to be a high quality production ready library.
  • Camera2 Many barcode libraries still use camera1 API's. These are now deprecated and although unlikely to be removed, you can get better performance and stability from camera2. You are also safe in the knowledge that Android will work to fix issues, and the library will have more longevity.
  • MLKit This library uses Google MLKit to process the frames and return barcodes. The Google team are committed to these API's and continue to work to improve them.
  • Tested We want this library to have tests. It's surprising how many don't.
  • Simple We want the implementation to be simple, but not try to hide away too much of the complexity of the task.

Download

implementation 'uk.co.brightec.kbarcode:kbarcode:$version'

Releases

See the releases section for details about each release and any migration steps required.

Releases requiring migration: 1.0.2, 1.0.3, 1.3.0

Releases with behaviour changes: 1.1.0, 1.2.3

Wiki

For a detailed look at the library and a full get started guide checkout the wiki

Community

We welcome community involvement with this library. We want this library to be useful for others, and of a high production quality.

Issues

Please do raise issues if you find problems with the library, sample or its documentation. We have provided a template to use.

Pull Requests

If you find an issue, why not try to fix it and create a pull request. We run CI checks on every pull request which must pass. To run these locally

./gradlew check connectedAndroidTest

This will run our code standards checks, lint, tests and instrumented tests.

If you're keen to help, why not fix someone else's issue.

Feature Requests

You can submit feature requests as issues. As mentioned above we want this library to be simple, high quality and production ready. We therefore may be selective about which features we wish to include in order to achieve these goals.

Before fully coding a feature, why not raise an issue to start a discussion with us.

License

See license

Author

Alistair Sykes - Github Medium Twitter

This library is maintained by the Brightec team

Comments
  • [BUG] App crash when returning to it

    [BUG] App crash when returning to it

    Describe the bug After just having used the scanning functionality, then closing the app, and the re-opening the app, I encountered the following exception:

    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: java.lang.reflect.InvocationTargetException        at java.lang.reflect.Method.invoke(Method.java:-2)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): checkPidStatus:1708: The camera device has been disconnected
            at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:728)
            at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:179)
            at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1135)
            at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:436)
            at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:662)
            at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:510)
            at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)
            at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)
            at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:143)
            at android.os.Handler.handleCallback(Handler.java:873)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:6718)
            at java.lang.reflect.Method.invoke(Method.java:-2)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    Caused by: android.os.ServiceSpecificException: checkPidStatus:1708: The camera device has been disconnected
            at android.os.Parcel.createException(Parcel.java:1964)
            at android.os.Parcel.readException(Parcel.java:1918)
            at android.os.Parcel.readException(Parcel.java:1868)
            at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.waitUntilIdle(ICameraDeviceUser.java:599)
            at android.hardware.camera2.impl.ICameraDeviceUserWrapper.waitUntilIdle(ICameraDeviceUserWrapper.java:177)
            at android.hardware.camera2.impl.CameraDeviceImpl.waitUntilIdle(CameraDeviceImpl.java:1135)
            at android.hardware.camera2.impl.CameraDeviceImpl.configureStreamsChecked(CameraDeviceImpl.java:436)
            at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSessionInternal(CameraDeviceImpl.java:662)
            at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:510)
            at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)
            at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)
            at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:143)
            at android.os.Handler.handleCallback(Handler.java:873)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:6718)
            at java.lang.reflect.Method.invoke(Method.java:-2)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
    

    I believe this is rather rare though, but it might be good if you handled this some better way that doesn't cause the app to crash.

    To Reproduce Steps to reproduce the behavior: Close app, and then re-open it. Doesn't happen all the time though.

    Expected behavior I expected the app to re-open with the camera view and the scanning started as normal. This is what happens most of the time, except this one time when I got the exception.

    Screenshots N/A

    Smartphone (please complete the following information):

    • Device: Google Pixel 2 XL
    • OS: Android 9, API 28

    Additional context None

    bug 
    opened by hsson 14
  • [BUG] Screen Lag every second

    [BUG] Screen Lag every second

    Describe the bug First of TnQ for this great lib. its simple and completely a clean solution. However There i an annoying bug. When camera shows up screen lags periodically every second. I think the problem is that you are processing bitmap on the main thread and when the device config is weak this bug happens.

    To Reproduce Run this lib on the mid level devices

    Expected behavior Camera must work without lag and calculating and processing must be in background thread

    Smartphone (please complete the following information):

    • Device: [Samsung Galaxy J5]
    • OS: [Android 28]
    • Version [1.0.3]
    bug 
    opened by TurKurT656 9
  • Surface had no valid native window. on barcodeView.start()

    Surface had no valid native window. on barcodeView.start()

    Once I grant the CAMERA permissions barcodeView.start() throws an error

    On Android Marshmallow is not needed call to start but on Android Pie

    I want to know if there is a way to know if the barcode is already started to avoid calling .start()

    E/AndroidRuntime: FATAL EXCEPTION: main Process: com.centinal.ivs.internal.debug, PID: 17159 java.lang.IllegalArgumentException: Surface was abandoned at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:70) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:97) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:71) at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:474) at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121) at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55) at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: android.hardware.camera2.legacy.LegacyExceptionUtils$BufferQueueAbandonedException at android.hardware.camera2.legacy.LegacyExceptionUtils.throwOnError(LegacyExceptionUtils.java:64) at android.hardware.camera2.legacy.LegacyCameraDevice.getSurfaceSize(LegacyCameraDevice.java:540) at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:68) at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:97)  at android.hardware.camera2.params.OutputConfiguration.(OutputConfiguration.java:71)  at android.hardware.camera2.impl.CameraDeviceImpl.createCaptureSession(CameraDeviceImpl.java:474)  at uk.co.brightec.kbarcode.camera.Camera2Source.createCaptureSession$kbarcode_release(Camera2Source.kt:121)  at uk.co.brightec.kbarcode.camera.Camera2Source$start$1.onOpened(Camera2Source.kt:55)  at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:134)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

    bug 
    opened by OmarJoya 7
  • [FEATURE] Ui test

    [FEATURE] Ui test

    Is your feature request related to a problem? Please describe.

    Reading documentation i don't see any topic on how to use this view with UI testing (like Espresso).

    Have you any tip that you can provide, so it's easy to do a test that request to scan a barcode?

    Describe the solution you'd like

    On test method:

    activity.findViewById<KBarcodeView>(R.id.barcodeScanner).doScan(mockBarcode)
    
    enhancement 
    opened by alorma 6
  • [FEATURE] Click to focus in barcode view

    [FEATURE] Click to focus in barcode view

    Is your feature request related to a problem? Please describe. No problem.

    Describe the solution you'd like Rather than relying autofocus, it would be nice to allow the user to click within the view to focus.

    Describe alternatives you've considered None really..

    Additional context None

    enhancement 
    opened by hsson 6
  • [FEATURE] Add a way to pause the camera preview, or clear the list of scanned barcodes.

    [FEATURE] Add a way to pause the camera preview, or clear the list of scanned barcodes.

    Right now, calling barcodeView.start() or lifecycle.addObserver(barcodeView) starts the camera preview. Calling barcodeView.pause() does pause the barcode scanning, but not the preview. In order to actually pause the view, I have to call barcodeView.release(). This kinda works, but when starting the barcode view again, the onBarcodeListener gets called with the previous scanned value instantly.

    Describe the solution you'd like It would be great to have a way to stop the preview and barcode scanning altogether, and restart it later, without it firing the onBarcodeListener when resuming.

    That would be possible through a pausePreview() and resumePreview method I suppose.

    enhancement 
    opened by maartenvang 4
  • [BUG] Manifest forces

    [BUG] Manifest forces "uses-feature"

    In the android manifest the "uses-feature" forces the application that uses this library to use them. An app could have the barcode scanning as optional feature, but by forcing these feature, the app cannot be installed because google play filters devices not matching.

    A possible solution could be a change of: <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />

    in: <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>

    Originally posted by @falkontre in https://github.com/brightec/KBarcode/issues/1#issuecomment-475076109

    bug good first issue 
    opened by alistairsykes 4
  • How to capture or retreive the Image frame being scanned

    How to capture or retreive the Image frame being scanned

    I want to preview or store the image that was used for scanning. Therefore I want to get scanned image along with the result code, is there any way I can get that? Thanks for the support in advance.

    opened by RAZA-ABBBASI 3
  • Fix crash

    Fix crash

    Fixes the "Processing image without camera facing" crash by making this property optional (we don't use it).

    Tested by deploying this change via mavenLocal to a client project and manually tested barcode scanning.


    This change is Reviewable

    opened by chrisleversuch 2
  • [FEATURE] FirebaseVisionBarcode is deprecated, migrate to ML Kit SDK

    [FEATURE] FirebaseVisionBarcode is deprecated, migrate to ML Kit SDK

    Describe the solution you'd like

    The FirebaseVisionBarcode class is deprecated. Google states:

    The standalone ML Kit SDK replaces this API. For more information, refer to the migration guide.

    Do you have plans to migrate your very well designed library?

    Describe alternatives you've considered

    I have considered the following alternatives if Brightec does not plan to do this migration.

    • Updating the library myself.
    • Using the ML Kit SDK instead of the KBarcode library.
    enhancement 
    opened by blazingcayenne 2
  • [BUG] Library doesn't work at all

    [BUG] Library doesn't work at all

    Describe the bug Current version of library doesnt work because it uses old dependecies that will throw exception on build

    Duplicate class com.google.android.gms.internal.vision.zze found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime (com.google.android.gms:play-services-vision-common:19.1.0)
    
    Go to the documentation to learn how to Fix dependency resolution errors.
    
    

    If you manually add newest version of play-services-vision then you will get runtime crash on library init

    E/AndroidRuntime: FATAL EXCEPTION: FirebaseMLHandler
        Process: com.p1ng2win.gabiapplication, PID: 7373
        java.lang.VerifyError: Superclass com.google.firebase.ml.vision.barcode.internal.zzj of com.google.firebase.ml.vision.barcode.BarcodeDetectorCreator is declared final (declaration of 'com.google.firebase.ml.vision.barcode.BarcodeDetectorCreator' appears in /data/app/com.p1ng2win.gabiapplication-KiY0_DnxVctfCKFLF5qfYg==/base.apk!classes2.dex)
            at java.lang.VMClassLoader.findLoadedClass(Native Method)
            at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            at com.google.android.gms.dynamite.DynamiteModule.instantiate(com.google.android.gms:play-services-basement@@17.3.0:257)
            at com.google.firebase.ml.vision.barcode.internal.zzc.zzqu(com.google.firebase:firebase-ml-vision@@24.1.0:25)
            at com.google.firebase.ml.vision.barcode.internal.zzc.zzow(com.google.firebase:firebase-ml-vision@@24.1.0:10)
            at com.google.android.gms.internal.firebase_ml.zzqz.zzf(com.google.firebase:firebase-ml-common@@22.1.2:53)
            at com.google.android.gms.internal.firebase_ml.zzqz$zza.zzoz(com.google.firebase:firebase-ml-common@@22.1.2:7)
            at com.google.android.gms.internal.firebase_ml.zzqz$zza.call(com.google.firebase:firebase-ml-common@@22.1.2:24)
            at com.google.android.gms.internal.firebase_ml.zzqf.zza(com.google.firebase:firebase-ml-common@@22.1.2:32)
            at com.google.android.gms.internal.firebase_ml.zzqe.run(Unknown Source:4)
            at android.os.Handler.handleCallback(Handler.java:883)
            at android.os.Handler.dispatchMessage(Handler.java:100)
            at android.os.Looper.loop(Looper.java:224)
            at android.os.HandlerThread.run(HandlerThread.java:67)
    

    To Reproduce Steps to reproduce the behavior: Literally try to use library

    My gradle

    
    
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'kotlin-kapt'
    apply plugin: 'com.google.gms.google-services'
    apply plugin: 'io.sentry.android.gradle'
    apply plugin: 'com.google.firebase.crashlytics'
    apply plugin: 'com.google.firebase.firebase-perf'
    apply plugin: "androidx.navigation.safeargs.kotlin"
    
    android {
        compileSdkVersion 29
        buildToolsVersion "29.0.3"
        defaultConfig {
            applicationId "com.p1ng2win.gabiapplication"
            minSdkVersion 21
            targetSdkVersion 29
            versionCode 68 //56
            versionName "1.820" //1.81
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                shrinkResources false
    
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            coreLibraryDesugaringEnabled true
    
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = "1.8"
        }
    
        packagingOptions {
            exclude 'META-INF/atomicfu.kotlin_module'
        }
    }
    
    androidExtensions {
        experimental = true
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'androidx.appcompat:appcompat:1.2.0'
        implementation 'androidx.core:core-ktx:1.3.2'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        implementation 'com.google.android.material:material:1.2.1'
        implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
        implementation 'com.android.support:multidex:1.0.3'
        implementation 'androidx.preference:preference-ktx:1.1.1'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    
        coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
    
        //arch
        implementation "androidx.lifecycle:lifecycle-runtime-ktx:$ktx_version"
        implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$ktx_version"
        implementation "androidx.lifecycle:lifecycle-livedata-ktx:$ktx_version"
        implementation "androidx.fragment:fragment-ktx:1.2.5"
    
        //navigation
        implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
        implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    
        //testing
        testImplementation 'junit:junit:4.13.1'
        androidTestImplementation 'androidx.test.ext:junit:1.1.2'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    
        //GooglePlay
        implementation 'com.google.android.play:core:1.8.3'
        implementation 'com.google.android.play:core-ktx:1.8.1'
        implementation 'com.google.android.gms:play-services-vision:20.1.2'
    
        //Firebase
        implementation platform('com.google.firebase:firebase-bom:26.1.0')
        implementation 'com.google.firebase:firebase-analytics-ktx'
        implementation 'com.google.firebase:firebase-crashlytics-ktx'
        implementation 'com.google.firebase:firebase-messaging-ktx'
        implementation 'com.google.firebase:firebase-perf-ktx'
    
        //LiveData, ViewModel
        implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
        implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
        implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
        implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    
        //Sentry (crash analytics)
        implementation 'io.sentry:sentry-android:3.1.0'
    
        //Retrofit
        implementation 'com.squareup.retrofit2:retrofit:2.9.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
        implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
        implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
    
        //Glide
        implementation 'com.github.bumptech.glide:glide:4.11.0'
        kapt 'com.github.bumptech.glide:compiler:4.11.0'
    
        //BarcodeScanner
        implementation 'uk.co.brightec.kbarcode:kbarcode:1.2.2'
        implementation('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
        implementation 'com.google.zxing:core:3.3.0'
    
        //LeakCanary
        debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
    
        //WebSocket
        implementation 'tech.gusavila92:java-android-websocket-client:1.2.2'
    
        //Grant Runtime Permission
        implementation 'com.androidisland.ezpermission:ezpermission:0.1.4'
    
        //SegmentedControl Button
        implementation 'com.github.trinnguyen:Android-SegmentView:master-SNAPSHOT'
    
        //Notification Builder
        implementation "io.karn:notify:1.3.0"
    
        implementation "androidx.room:room-runtime:$room_version"
        implementation "androidx.room:room-ktx:$room_version"
        kapt "androidx.room:room-compiler:$room_version"
    
        //KotlinX DateTime
        implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.1.0"
    
        //Timber (logs)
        implementation 'com.jakewharton.timber:timber:4.7.1'
    
        //AdapterDelegates
        implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.0'
        implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-layoutcontainer:4.3.0'
    
    }
    
    

    Smartphone (please complete the following information):

    • Device: Xiaomi mi 9t
    • OS: MIUI 11
    • Version kbarcode:1.2.2

    Additional context I think you should migrate to google ml kit because firebase ml kit was deprecated

    bug 
    opened by P1NG2WIN 2
  • [BUG] Detection stops working when toggling flash

    [BUG] Detection stops working when toggling flash

    Describe the bug The barcode detection stops working when i toggle the flash via setCameraFlashMode(). This is what i see in the error logs:

    2022-10-15 12:20:57.008 23489-23489/hu.egis.greta E/BarcodeImageProcessor: Barcode processing error
        com.google.mlkit.common.MlKitException: This detector is already closed!
            at com.google.mlkit.vision.common.internal.MobileVisionBase.processBase(com.google.mlkit:vision-common@@16.3.0:3)
            at com.google.mlkit.vision.barcode.internal.BarcodeScannerImpl.process(com.google.android.gms:play-services-mlkit-barcode-scanning@@16.1.5:1)
            at uk.co.brightec.kbarcode.processor.BarcodeImageProcessor.detectInImage$kbarcode_release(BarcodeImageProcessor.kt:1)
            at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase.startDetection$kbarcode_release(ImageProcessorBase.kt:30)
            at uk.co.brightec.kbarcode.processor.base.ImageProcessorBase$startDetection$1.invokeSuspend(Unknown Source:12)
            at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
            at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
            at android.os.Handler.handleCallback(Handler.java:938)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loopOnce(Looper.java:226)
            at android.os.Looper.loop(Looper.java:313)
            at android.app.ActivityThread.main(ActivityThread.java:8669)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
    

    I went through your code and i saw that the updateCameraFeature closes the BarcodeScanner, and it is not recreated. I saw that if i call setBarcodeFormats() then it will trigger a createScanner() so the barcode detection continues, but with this solution sometimes i get a crash:

    2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil: [AppErrors] null InputStream [CONTEXT service_id=254 ]
        java.io.IOException: null InputStream
            at bupm.c(:com.google.android.gms@[email protected] (190408-480654083):23)
            at buno.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
            at jxy.apply(:com.google.android.gms@[email protected] (190408-480654083):0)
            at jym.apply(:com.google.android.gms@[email protected] (190408-480654083):5)
            at clsc.a(:com.google.android.gms@[email protected] (190408-480654083):0)
            at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
            at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
            at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
            at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
            at clro.a(:com.google.android.gms@[email protected] (190408-480654083):4)
            at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
            at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
            at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
            at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
            at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
            at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
            at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
            at clrt.h(:com.google.android.gms@[email protected] (190408-480654083):4)
            at clsd.a(:com.google.android.gms@[email protected] (190408-480654083):0)
            at ctwm.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at cztz.d(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czub.run(:com.google.android.gms@[email protected] (190408-480654083):9)
            at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
            at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
            at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czub.g(:com.google.android.gms@[email protected] (190408-480654083):0)
            at clsa.a(:com.google.android.gms@[email protected] (190408-480654083):4)
            at ctwk.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czvr.a(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czxt.a(:com.google.android.gms@[email protected] (190408-480654083):2)
            at czwu.run(:com.google.android.gms@[email protected] (190408-480654083):3)
            at czxv.run(:com.google.android.gms@[email protected] (190408-480654083):0)
            at czvt.run(:com.google.android.gms@[email protected] (190408-480654083):7)
            at czvl.execute(:com.google.android.gms@[email protected] (190408-480654083):0)
            at czvt.execute(:com.google.android.gms@[email protected] (190408-480654083):9)
            at cztx.q(:com.google.android.gms@[email protected] (190408-480654083):1)
            at cztx.gn(:com.google.android.gms@[email protected] (190408-480654083):4)
            at czvv.c(:com.google.android.gms@[email protected] (190408-480654083):5)
            at clsi.c(:com.google.android.gms@[email protected] (190408-480654083):5)
            at clsi.b(:com.google.android.gms@[email protected] (190408-480654083):2)
            at com.google.android.gms.stats.service.DropBoxEntryAddedChimeraService.a(:com.google.android.gms@[email protected] (190408-480654083):32)
    2022-10-15 12:32:53.847 3210-26680/? E/DropBoxUtil:     at com.google.android.gms.framework.tracing.wrapper.TracingIntentService.onHandleIntent(:com.google.android.gms@[email protected] (190408-480654083):1)
            at gjl.handleMessage(:com.google.android.gms@[email protected] (190408-480654083):0)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loopOnce(Looper.java:226)
            at android.os.Looper.loop(Looper.java:313)
            at android.os.HandlerThread.run(HandlerThread.java:67)
    
    bug 
    opened by Hulcsa 2
  • [FEATURE] Add Data Safety information

    [FEATURE] Add Data Safety information

    Is your feature request related to a problem? Please describe. Add documentation detailing relevant information to consumers about any data collected within this SDK, as advised here https://support.google.com/googleplay/android-developer/answer/10787469

    Describe the solution you'd like Provide documentation

    Describe alternatives you've considered N/A

    Additional context None

    enhancement 
    opened by alistairsykes 0
  • Crash on back

    Crash on back

    When I press the back button the app crashes.

    I'm using jetpack navigation.

    1. Fragment A open fragment B (this is the fragment with the barcode viewer)
    2. from fragment B I press back button,

    Expected behavior the app back to fragment A, but it close, I can't see any log on logcat, it just crash with no reason and no messages this is the only log I found but I'm not sure it's releated:

    
    2021-10-28 17:20:29.917 3144-4100/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) dequeueBuffer: BufferQueue has been abandoned
        
        --------- beginning of crash
    2021-10-28 17:20:29.917 3144-3918/swaix.dev.xxxxxxx A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7bbc626f2d in tid 3918 (pool-3-thread-1), pid 3144 (dev.xxxxxxx )
    2021-10-28 17:20:29.997 3144-3166/swaix.dev.xxxxxxx  E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) queueBuffer: BufferQueue has been abandoned
    2021-10-28 17:20:30.031 3144-3144/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) cancelBuffer: BufferQueue has been abandoned
    2021-10-28 17:20:30.032 3144-3144/swaix.dev.xxxxxxx E/BufferQueueProducer: [ImageReader-4000x3000f23m3-3144-1](id:c4800000001,api:4,p:1129,c:3144) cancelBuffer: BufferQueue has been abandoned
    2021-10-28 17:20:30.226 3144-3144/swaix.dev.xxxxxxx E/BarcodeImageProcessor: Barcode processing error
        kotlinx.coroutines.JobCancellationException: StandaloneCoroutine was cancelled; job=StandaloneCoroutine{Cancelling}@d2bd765
    2021-10-28 17:20:31.148 3144-3144/swaix.dev.xxxxxxx E/BarcodeReaderFragment: *****---- ON PAUSE BARCODE
    
    

    it looks like it crashes after on pause.

    Smartphone (please complete the following information):

    • Device: Pixel 2xl, Samsung a50
    • OS: Android 11

    Additional context it works fine on emulator :|

    bug 
    opened by swaix 1
  • [FEATURE] Barcodes Filter

    [FEATURE] Barcodes Filter

    Is your feature request related to a problem? Please describe. No problem

    Describe the solution you'd like Similar to the already implemented sort feature, it would be great to add a filter, which would enable functionality such as only returning barcodes within a certain area (i.e. viewfinder).

    It would be great to provide a base class (similar to BarcodeComparator.kt) which can provide the FrameMetadata, in order to enable more functionality.

    Describe alternatives you've considered This can be done manually within the implementation listener, but would be simpler if it was integrated into the library.

    Additional context None

    enhancement 
    opened by alistairsykes 2
Releases(v1.3.0)
  • v1.3.0(Jul 12, 2021)

    Headline Features

    Tap to Focus, Camera Flash Mode, Firebase ML to Play Services MLKit

    Migration

    Migrating to version 1.3.0 of KBarcode does involve a couple of small changes to your code.

    ScaleType to PreviewScaleType

    We have renamed all uses of ScaleType to PreviewScaleType. This clarifies more precisely what this attribute does. It also means KBarcode shouldn't clash with camerax lib should you have both installed. The behaviour of this attribute hasn't changed.

    Depending on exactly how you've implemented KBarcode, you should simply be able to replace your use like for like. For example: XML: app:scaleType="centerInside" -> app:previewScaleType="centerInside" Kotlin: .scaleType(BarcodeView.CENTER_INSIDE) -> .previewScaleType(BarcodeView.CENTER_INSIDE)

    Deprecated setBarcodeFormats removal

    The deprecated setBarcodeFormats method which was deprecated in 1.0.3 has now been removed. Please make use of the IntArray replacement for this method. KBarcode/releases/tag/v1.0.3

    Changes

    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.3.0.aar(125.23 KB)
  • v1.2.3(Apr 9, 2021)

  • v1.2.2(Mar 13, 2020)

  • v1.2.1(Mar 11, 2020)

  • v1.2.0(Mar 11, 2020)

    We have fixed the sorting of barcodes not being used. We are now targeting Java8 in order to be able to use the latest tooling.

    Changes

    • Fixed bug where the sort wasn't being applied correctly
    • Now targeting Java 8
    • Updated our CI configuration
    • Updated our quality checking tools
    • Build tools 3.5.3 -> 3.6.1
    • Gradle 5.4.1 -> 5.6.4
    • Firebase Core 17.2.2 -> 17.2.3
    • Firebase ML 21.0.0 → 24.0.1
    • Added Firebase ML Barcode 16.0.2
    • Kotlin 1.3.61 → 1.3.70
    • Material 1.0.0 -> 1.1.0
    • Lifecycle 2.1.0 -> 2.2.0
    • Coroutines 1.3.2 -> 1.3.3
    • Updated various testing dependencies
    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.2.0.aar(14.82 KB)
  • v1.1.1(Jan 21, 2020)

    Changes

    • Added better exception handling for createCaptureSession()
    • Added causes and messages to some camera exceptions
    • Added better exception handling for openCamera()
    • Added better exception handling for createCaptureRequest() and setRepeatingRequest()
    • Moved the closing of the image reader to before the closing of the camera. This fixes a bug where, in a small number of cases there is no camera facing available in the onImageAvailable callback
    • Firebase Core 17.2.1 → 17.2.2
    • Kotlin 1.3.50 → 1.3.61
    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.1.1.aar(108.33 KB)
  • v1.1.0(Dec 13, 2019)

  • v1.0.5(Oct 22, 2019)

    We highly recommend updating from 1.0.4 to 1.0.5, since this update fixes a a couple of significant issues.

    Coroutine Fixes

    #23 Made some fixes to the way we use coroutines. Cancelled the current job rather than scope so that we can launch new coroutines from the same scope. Changed our Firebase call to be a suspend call.

    Surface Invalid

    #22 Added a check after opening the camera to ensure that the surfaces are still valid.

    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.0.5.aar(105.86 KB)
  • v1.0.4(Oct 15, 2019)

    Lag Fix [#19]

    There were some dropped frames in some cases. This was caused by FirebaseVisionImage.fromMediaImage(image, frameMetadata.rotation) taking too long. To solve we introduced coroutines to the project and made this run on a background thread.

    Miscellaneous

    Dependencies

    • Various test dependencies
    • Build tools 3.4.0 -> 3.5.1
    • Firebase core 16.0.9 -> 17.2.0
    • Various lifecycle dependencies
    • Google service 4.2.0 -> 4.3.2
    • Gradle 5.1.1 -> 5.4.1
    • Firebase ML Vision 20.0.0 -> 21.0.0
    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.0.4.aar(106.75 KB)
  • v1.0.3(May 10, 2019)

    IntArray

    We have changed the API to now use IntArray instead of Array for barcode formats. We did this because IntArray is more efficient. We have deprecated the previous method, and it will be removed in a future release. We have offered a quick fix replacement if you are using Android Studio. You may wish to consider making changes in your code to utilise IntArray and gain the efficiencies too.

    Just put your cursor on the method and use your shortcut for quick fix

    https://developer.android.com/studio/intro/keyboard-shortcuts Project quick fix (show intention actions and quick fixes) | Alt + Enter | Option + Enter

    start() Fixes

    #13 - See this issue for some more details

    In summary calling start() twice in quick succession caused issues because our Camera2Source was only tracking isStarted() and not "is starting". We have now added this in the form of isOpening(), meaning it should now be safe to call start() twice.

    Miscellaneous

    Dependencies

    • Kotlin: 1.3.21 -> 1.3.31
    • Build tools: 3.3.2 -> 3.4.0
    • Firebase Core: 16.0.8 -> 16.0.9
    • Firebase ML: 19.0.3 -> 20.0.0

    Quality

    We updated our quality config files to our latest standards here at Brightec. This caused a few minor changes in order to fix out some newly identified inefficiencies.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.2(Apr 1, 2019)

    Breaking Changes

    • Barcode.cornerPoints: Type change from Array to List. This enables collection functionality and is considered better practice.

    Other Changes

    • Added more functionality to the Barcode class, including access to type specific classes, for example CalendarEvent and WiFi
    • Updated some Firebase dependencies
    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.0.2.aar(98.55 KB)
  • v1.0.1(Mar 21, 2019)

    Bug fixes

    In this version we fixed some minor bugs and issues.

    #2 Slight tweaks to uses-feature in manifest #4 Report camera error rather than crash when no cameraIds in list #5 Ensured camera releases when surface is destroyed (only handled destroyed by lifecycle previously)

    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.0.1.aar(62.90 KB)
  • v1.0.0(Mar 13, 2019)

    A library to help implement barcode scanning.





    Why?

    Another barcode library. Yawn.

    We can understand why you may think that, but there are some key reasons we decided to write a new barcode library.

    • Quality We want this library to be a high quality production ready library.
    • Camera2 Many barcode libraries still use camera1 API's. These are now deprecated and although unlikely to be removed, you can get better performance and stability from camera2. You are also safe in the knowledge that Android will work to fix issues, and the library will have more longevity.
    • Firebase This library uses Firebase to process the frames and return barcodes. The Firebase team are committed to these API's and continue to work to improve them.
    • Tested We want this library to have tests. It's surprising how many don't.
    • Simple We want the implementation to be simple, but not try to hide away too much of the complexity of the task.
    Source code(tar.gz)
    Source code(zip)
    kbarcode-1.0.0.aar(62.82 KB)
Owner
Brightec
User-centred mobile app development
Brightec
Android app and Python library for turning mobile phone into a WebSocket-based, remotely controllable Barcode/QR code reader

Remote Barcode Reader suite Android app and Python library for turning mobile phone into a remotely controllable Barcode/QR code reader. It exposes a

Krystian Dużyński 3 Dec 6, 2022
Barcode Scanner Libraries for Android

Project Archived July 1 2020 This project is no longer maintained. When I first started this project in late 2013 there were very few libraries to hel

Dushyanth 5.4k Jan 3, 2023
QRAlarm - an Android alarm clock application lets the user turn off alarms by scanning the QR Code.

QRAlarm is an Android alarm clock application that does not only wake You up, but also makes You get up to disable the alarm by scanning the QR Code.

null 39 Jan 8, 2023
QrX: Camera with ML Kit QR/Barcode detection

QrX: Camera with ML Kit QR/Barcode detection This library allows you to easily add CameraX Preview with attached ML Kit to detect and display Qr codes

Mateusz Lutecki 1 Apr 7, 2022
⭐️ Quick and easy QR Code scanning app created using Jetpack Compose. ☘️

QR-Code-Scanner Scan your QR codes easily and quickly. ⭐️ Google Play Store : Screenshots of the app : ?? Libraries Used in The Project : // Jetpa

Nisa Efendioğlu 12 Oct 8, 2022
Android library for creating QR-codes with logo, custom pixel/eyes shapes, background image. Powered by ZXing.

custom-qr-generator Android library for creating QR-codes with logo, custom pixel/eyes shapes, background image. Powerd by ZXing. Installation To get

Alexander Zhirkevich 34 Dec 17, 2022
ZXing ("Zebra Crossing") barcode scanning library for Java, Android

Project in Maintenance Mode Only The project is in maintenance mode, meaning, changes are driven by contributed patches. Only bug fixes and minor enha

ZXing Project 30.5k Dec 27, 2022
SmartLens uses Google's ML Kit for Barcode scanning, Face recognition, Text recognition, and Image labeling.

SmartLens SmartLens uses Google's ML Kit for Barcode scanning, Face recognition, Text recognition, and Image labeling. ?? Screen Shots ?? Features It

Prince Fahad 2 Sep 14, 2022
Barcode scanner library for Android, based on the ZXing decoder

ZXing Android Embedded Barcode scanning library for Android, using ZXing for decoding. The project is loosely based on the ZXing Android Barcode Scann

JourneyApps 5.3k Jan 4, 2023
Android app and Python library for turning mobile phone into a WebSocket-based, remotely controllable Barcode/QR code reader

Remote Barcode Reader suite Android app and Python library for turning mobile phone into a remotely controllable Barcode/QR code reader. It exposes a

Krystian Dużyński 3 Dec 6, 2022
An Android library for scanning documents based on CameraX API and a tiny version of OpenCV

Document Scanner with tiny OpenCV example1.mp4 Document Scanner is an Android library (kotlin based) for scanning documents based on CameraX API and a

null 8 May 12, 2022
card.io provides fast, easy credit card scanning in mobile apps

card.io SDK for Android card.io provides fast, easy credit card scanning in mobile apps. Stay up to date Please be sure to keep your app up to date wi

card.io 2k Jan 1, 2023
android下自定义View之雷达扫描 The Radar (Scanning) View on Android 当扫描到对象的时候,通过水波纹的方式显示扫描到的对象,可以动态的随机添加,并且扫描到的对象是可以点击的……

RadarScanView 自定义View之雷达扫描 原理 关键是使用SweepGradient进行扫描渲染 关键代码如下: Shader shader = new SweepGradient(centerX, centerY, Color.TRANSPARENT, tailColo

郭攀峰 615 Dec 1, 2022
Barcode Scanner Libraries for Android

Project Archived July 1 2020 This project is no longer maintained. When I first started this project in late 2013 there were very few libraries to hel

Dushyanth 5.4k Jan 3, 2023
Barcode Scanner Libraries for Android

Project Archived July 1 2020 This project is no longer maintained. When I first started this project in late 2013 there were very few libraries to hel

Dushyanth 5.4k Jan 9, 2023
OpenNoteScanner - Android application for scanning and manipulating handwritten notes and documents.

OpenNoteScanner This little application provides a way on scanning handwritten notes and printed documents. It automatically detect the edge of the pa

Claudemir Todo Bom 1.2k Jan 1, 2023
Yet another barcode scanner for Android

Binary Eye Yet another barcode scanner for Android. As if there weren't enough. This one is free, without any ads and open source. Works in portrait a

Markus Fisch 802 Dec 31, 2022
This app contains feature barcode and QR scanner, and video recording in-app.

BarcodeQRScannerAndVideoRecord This app contains feature barcode and QR scanner, and video recording in-app. Scanner using ML Kit and CameraX. Video R

Abdullah Fahmi 1 Dec 23, 2021
✈ 🗼 Explore Landmarks 🗼 ✈An app that allows to explore landmarks by scanning landmark images

ExploreLandmarksAllFeatures.mp4 Screenshots ?? Introduction Explore Landmarks is a reference application for HMS Kits to p

null 35 Dec 23, 2022
QRAlarm - an Android alarm clock application lets the user turn off alarms by scanning the QR Code.

QRAlarm is an Android alarm clock application that does not only wake You up, but also makes You get up to disable the alarm by scanning the QR Code.

null 39 Jan 8, 2023