Giter Site home page Giter Site logo

mobilevisionbarcodescanner's Introduction

MobileVisionBarcodeScanner

Barcode Scanner supported by Mobile Vision Api

Android Arsenal Download

Lib Sample

Update 2.0.0

  • Bug fixes and Better Performance
  • Capturing scanned screen
  • support two or more barcode format
  • release a barcode detector
  • use the front camera for scanning
  • immediate refresh functionality
  • update to 11.0.4 mobile vision sdk

adding as a dependency

on JCenter

dependencies {
	        implementation ''xyz.belvi.mobilevision:barcodescanner:2.0.3''

	}

on JitPack

Step 1.

Add the JitPack repository to your build file in your root build.gradle at the end of repositories:

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

Add the dependency

dependencies {
        compile 'com.github.KingsMentor:MobileVisionBarcodeScanner:2.0.0'
}

Supported Attributes

        <attr name="gvb_show_text" format="boolean" />
        <attr name="gvb_draw" format="boolean" />
        <attr name="gvb_multiple" format="boolean" />
        <attr name="gvb_touch" format="boolean" />
        <attr name="gvb_auto_focus" format="boolean" />
        <attr name="gvb_flash" format="boolean" />
        <attr name="gvb_rect_colors" format="reference" />
        <attr name="gvb_camera_facing" format="enum">
            <enum name="back" value="0"></enum>
            <enum name="front" value="0"></enum>
        </attr>
        <attr name="gvb_code_format">
            <flag name="all_format" value="0"></flag>
            <flag name="code_128" value="1"></flag>
            <flag name="code_39" value="2"></flag>
            <flag name="code_93" value="4"></flag>
            <flag name="code_bar" value="8"></flag>
            <flag name="data_matrix" value="16"></flag>
            <flag name="ean_13" value="32"></flag>
            <flag name="ean_8" value="64"></flag>
            <flag name="itf" value="128"></flag>
            <flag name="qr_code" value="256"></flag>
            <flag name="upc_a" value="512"></flag>
            <flag name="upc_e" value="1024"></flag>
            <flag name="pdf417" value="2028"></flag>
            <flag name="aztec" value="4029"></flag>
        </attr>

What are the attibutes for :

  • gvb_draw - enable rect drawn around codes when scanning
  • gvb_multiple - want the camera to return as many qr codes that was scanned. This works with gvb_touch attribute. it only returns result when the screen is clicked or touch
  • gvb_touch - turn on touch listener for screen
  • gvb_auto_focus - support auto focus
  • gvb_flash - turn on flash
  • gvb_rect_colors - arrays of colors to draw rect
  • gvb_code_format - barcode format that should be support . Default is all_format

Note these attributes can also be initialised from java code . We would look into that later

Using the Mobile Vision Powered Camera.

Step 1 - Add layout in xml:
<fragment
            android:id="@+id/barcode"
            android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            app:gvb_auto_focus="true"
            app:gvb_code_format="all_format"
            app:gvb_flash="false"
            app:gvb_rect_colors="@array/rect_color" />

and this is rect_color in colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="color_green">#14808d</color>
    <color name="color_brown">#343838</color>
    <color name="color_orange">#f38a32</color>
    <color name="color_blue">#1479b7</color>
    <color name="divider_grey">#e4e4e5</color>

    <array name="rect_color">
        <item>@color/color_blue</item>
        <item>@color/color_brown</item>
        <item>@color/color_green</item>
        <item>@color/divider_grey</item>
        <item>@color/color_orange</item>
    </array>
</resources>
Step 2 - Initialise in java
BarcodeCapture barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.barcode);
barcodeCapture.setRetrieval(this);

also make sure your java class implements BarcodeRetriever

public class MainActivity extends AppCompatActivity implements BarcodeRetriever {

...


    // for one time scan
  @Override
    public void onRetrieved(final Barcode barcode) {
        Log.d(TAG, "Barcode read: " + barcode.displayValue);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
                        .setTitle("code retrieved")
                        .setMessage(barcode.displayValue);
                builder.show();
            }
        });


    }

    // for multiple callback
    @Override
    public void onRetrievedMultiple(final Barcode closetToClick, final List<BarcodeGraphic> barcodeGraphics) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                String message = "Code selected : " + closetToClick.displayValue + "\n\nother " +
                        "codes in frame include : \n";
                for (int index = 0; index < barcodeGraphics.size(); index++) {
                    Barcode barcode = barcodeGraphics.get(index).getBarcode();
                    message += (index + 1) + ". " + barcode.displayValue + "\n";
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
                        .setTitle("code retrieved")
                        .setMessage(message);
                builder.show();
            }
        });

    }

    @Override
    public void onBitmapScanned(SparseArray<Barcode> sparseArray) {
        // when image is scanned and processed
    }

    @Override
    public void onRetrievedFailed(String reason) {
        // in case of failure
    }
}

as you can see, BarcodeRetriever interface handles the callback when a code is scanned successfully based on specified attributes.

Extras

  • To scan a bitmap,
BarcodeBitmapScanner.scanBitmap(this, bitmap, Barcode.ALL_FORMATS, this);
  • Set attributes from java - Use the BarcodeCapture instance to reference setter methods
barcodeCapture.setShowDrawRect(true);
  • Stop barcode detection
barcodeCapture.stopScanning();
  • Retrieve Image of Scanned Screen. This will return a Camera object that you can use to retrieve other neccessary information:
barcodeCapture.retrieveCamera();
  • Refresh - make update to barcodeCapture and use refresh for immediate screen update.
                    barcodeCapture.setShowDrawRect(drawRect.isChecked())
                            .setSupportMultipleScan(supportMultiple.isChecked())
                            .setTouchAsCallback(touchBack.isChecked())
                            .shouldAutoFocus(autoFocus.isChecked())
                            .setShowFlash(flash.isChecked())
                            .setBarcodeFormat(Barcode.ALL_FORMATS)
                            .setCameraFacing(frontCam.isChecked() ? CameraSource.CAMERA_FACING_FRONT : CameraSource.CAMERA_FACING_BACK)
                            .setShouldShowText(drawText.isChecked());
                    barcodeCapture.refresh();

Resources and Credits

Contributions

Contributions are welcome. Generally, contributions are managed by issues and pull requests.

  1. Submit an issue describing your proposed fix or feature.
  2. If your proposed fix or feature is accepted then, fork, implement your code change.
  3. Ensure your code change follows the accepted code style and structure.
  4. Ensure your code is properly tested.
  5. Ensure your commits follow the accepted commit message style
  6. Submit a pull request.

#License The MIT License (MIT). Please see the License File for more information.

mobilevisionbarcodescanner's People

Contributors

guuilp avatar kingsmentor avatar mickey35vn avatar silviorp avatar zapploft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mobilevisionbarcodescanner's Issues

Crash on some cod scanning

Thanks for this cool library.
Qr Code.pdf

I am checking it on some QR codes and its crashing without any message in log. Its working for some other codes. Attaching file for with QR codes that are not working. Please help.

Flash nos turning off!

public void flashlight(View view){
        Boolean flashIsOn = barcodeCapture.isShowFlash();
        if(!flashIsOn){
            barcodeCapture.setShowFlash(true);
        }else{
            barcodeCapture.setShowFlash(false);
        }
        barcodeCapture.refresh();
 }

I'm implementing a button inside the view that when clicked, checks the flash status and if off, turns it off and if on, turns it off.

The turning ON part is ok, but turning OFF doesn't work.

Can you help me?

Multiple dex files define Lcom/google/android/gms/...

I'm not sure on what to do.. I used com.google.zxing before importing this library. I tried this lib, everything seemed to work. After I removed the google lib I started receiving this error and I'm not sure how I can get rid of it. Any help is appreciated.

Crash on infating

java.lang.ClassCastException: com.edwardvanraak.materialbarcodescanner.CameraSourcePreview cannot be cast to com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSourcePreview

Error when adding in Fragment

Hi,

I was trying to use your library in our project but got this error when I open the MainActivity that holds the fragment. I hope you can help me as soon as possible.

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.samples.vision.barcodereader.BarcodeCapture.setRetrieval(xyz.belvi.mobilevisionbarcodescanner.BarcodeRetriever)' on a null object reference at ca.easyreg.easyexhibitor.fragments.BarcodeScanner.onCreateView(BarcodeScanner.java:108)

Thanks in Advance!

J

Problem dependecies

Hi!
I'm trying to use your library (it's good).
But I'm having the following error:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;

This are my dependecies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:recyclerview-v7:25.0.0'
    compile 'com.roughike:bottom-bar:2.0.2'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile group: 'com.google.zxing', name: 'core', version: '2.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.google.firebase:firebase-messaging:9.6.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile('com.github.KingsMentor:MobileVisionBarcodeScanner:v1.2') { transitive = true; }
    apply plugin: 'com.google.gms.google-services'
    testCompile 'junit:junit:4.12'
}

Detecting imaginary codes

Hi, when I leave the mobile on the table, and the camera can't detect anything (black screen), it sometimes read an imaginary barcode, randomly.

update Google mobile vision library to latest version

I have used your library in one of my project, the apps is crashing in some devices like samsung galaxy S7, S8 ,edge,

Here is the log
#00 pc 000000000001bf44 /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#01 pc 000000000001110c /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#02 pc 0000000000005bf4 /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#03 pc 00000000000076f4 /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#04 pc 0000000000003624 /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#05 pc 0000000000004c8c /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
 
#06 pc 00000000003bb074 /data/user_de/0/com.google.android.gms/app_chimera/m/00000035/oat/arm64/DynamiteModulesA_GmsCore_prodmnc_alldpi_release.odex

QR Code scanner is not Retrieval

Hello, Thanks for your great work!
barcodeCapture open camera and preview camera but not work retrieval on samsung device (J7 pro), but work on huawei or samsung j7!

code:
`barcodeCapture.setShowDrawRect(true);
barcodeCapture.setAllowEnterTransitionOverlap(true);
barcodeCapture.setShowDrawRect(true);
barcodeCapture.setSupportMultipleScan(false);
barcodeCapture.setTouchAsCallback(false);
barcodeCapture.shouldAutoFocus(true);
barcodeCapture.setBarcodeFormat(Barcode.ALL_FORMATS);
barcodeCapture.setCameraFacing(CameraSource.CAMERA_FACING_BACK);

    barcodeCapture.setRetrieval(new BarcodeRetriever() {
                @Override
                public void onRetrieved(Barcode barcode) {
                     _barcode_value = barcode.displayValue;
                    _func_send_barcode();
                }

                @Override
                public void onRetrievedMultiple(Barcode closetToClick, List<BarcodeGraphic> barcode) {
                    _barcode_value = barcode.get(0).getBarcode().displayValue;
                    _func_send_barcode();
                }

                @Override
                public void onBitmapScanned(SparseArray<Barcode> sparseArray) {

                }

                @Override
                public void onRetrievedFailed(String reason) {
                }

                @Override
                public void onPermissionRequestDenied() {

                }
            });

    barcodeCapture.refresh();`

409 error when downloading dependency from https://repo.jfrog.org/artifactory/libs-release-bintray/com/google/android/gms/play-services-basement-license/11.4.2/play-services-basement-license-11.4.2.pom?referrer

The error is:

{ "errors" : [ { "status" : 409, "message" : "Failed to read POM for 'com/google/android/gms/play-services-basement-license/11.4.2/play-services-basement-license-11.4.2.pom': expected START_TAG or END_TAG not TEXT (position: TEXT seen ...</packaging>\\n \\ua0<l... @7:5) ." } ] }

How read qrCode from frontal camera?

Hi, I would like to change between two cameras to read qrcode.

Does this library allow you to read the code with the both cameras?

Thanks in advance!

Camera preview is not takin the entire screen

Hi I just want to start saying how much I like this library and how helpful it's been to me.

Let's get down to business:
I'm attaching the barcodeCapture to my activity but the camera preview is showing an empty space the size of the actionBar and the statusBar combined at the bottom.
How can I make the camera preview full screen?

Error received: "Detector processor must first be set with setProcessor in order to receive detection results."

I imported your example on my project (beside the fact that few methods from the example are not available in the latest version from gradle), and the logs are spammed with this error:

E/OpenCameraSource: Exception thrown from receiver.
java.lang.IllegalStateException: Detector processor must first be set with setProcessor in order to receive detection results.
at com.google.android.gms.vision.Detector.receiveFrame(Unknown Source)
at com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource$FrameProcessingRunnable.run(CameraSource.java:1222)
at java.lang.Thread.run(Thread.java:762)
E/OpenCameraSource: Exception thrown from receiver.
java.lang.IllegalStateException: Detector processor must first be set with setProcessor in order to receive detection results.
at com.google.android.gms.vision.Detector.receiveFrame(Unknown Source)
at com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource$FrameProcessingRunnable.run(CameraSource.java:1222)
at java.lang.Thread.run(Thread.java:762)
E/OpenCameraSource: Exception thrown from receiver.
java.lang.IllegalStateException: Detector processor must first be set with setProcessor in order to receive detection results.
at com.google.android.gms.vision.Detector.receiveFrame(Unknown Source)
at com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource$FrameProcessingRunnable.run(CameraSource.java:1222)
at java.lang.Thread.run(Thread.java:762)

Does scanning bitmap feature working?

I have to use this feature because there shouldn't be any interface for the user and he/she only sees a little preview placed carefully on the WebView.
I get bitmap from camera like this:

camera.setPreviewCallback(new Camera.PreviewCallback() {
            @Override
            public void onPreviewFrame(byte[] data, Camera camera) {
                // Convert to JPG
                Camera.Size previewSize = camera.getParameters().getPreviewSize();
                YuvImage yuvimage = new YuvImage(data, ImageFormat.NV21, previewSize.width, previewSize.height, null);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                yuvimage.compressToJpeg(new Rect(0, 0, previewSize.width, previewSize.height), 100, baos);
                byte[] jdata = baos.toByteArray();
                scanBarcode(BitmapFactory.decodeByteArray(jdata, 0, jdata.length));
            }
        });

And use bitmap:

BarcodeBitmapScanner.scanBitmap(view.getActContext(), bMap, Barcode.ALL_FORMATS, new BarcodeRetriever() {
            @Override
            public void onRetrieved(Barcode barcode) {
                Log.e("kek", "onRetrieved: " + barcode.displayValue + "; " + barcode.rawValue);
            }

            @Override
            public void onRetrievedMultiple(Barcode barcode, List<BarcodeGraphic> list) {

            }

            @Override
            public void onBitmapScanned(SparseArray<Barcode> sparseArray) {
                Log.e("kek", "onBitmapScanned: " + sparseArray.toString());
            }

            @Override
            public void onRetrievedFailed(String s) {
                Log.e("kek", "onRetrievedFailed: " + s);
            }
        });

From this I'm getting only constant onBitmapScanned callback with {-1498705798=com.google.android.gms.vision.barcode.Barcode@3f3a12cb} this content. No other callbacks are invoked. Can you help me with this?

Multiple Errors, need help

First of all, after searching many websites and youtube videos, I'd finally got to know how to use that valueFormat option as nowhere it is mentioned in your library or in the official one or in any answer/question of StackOverflow. Even I got no answers on StackOverflow for the same.
But for now, four errors I've faced after handling many:

  1. Camera View always looks compressed or distorted from sides and looks unnatural when compared to default camera app.
  2. URL QR code does not work as code.url.url returns no value same as code.url.title (rawValue does the work here).
  3. It is mentioned nowhere that how you can get the scanned barcode through the camera (takePicture()). Please provide that.
  4. Gradle build error when updating to 2.0.3. I had to downgrade it to 2.0.0 as failed to resolve library is what I see every time.
    Please help.

Manual camera focus

Hi! This is a great project! It would be very useful to have a manual focus option. Thanks

Rectange draw did not works

Great work 👍
i have used your sample but unable to draw a rectangle while accessing QR and any other type of barcode while scanning.

i am using this app:gvb_rect_colors="@array/rect_color" but no help.

Device using is Xiomi note 3 , android version 4.4;

Dependency issue while deploying apk .

After adding the dependency, build gets generated. But when its deployed to device. Following error occurs. Is it due to some cyclic dependency available in multiple libs? Help needed slightly urgent....

02-20 04:54:26.502 6422-6422/com.softcell.gonogo.gonogohdbfs E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.softcell.gonogo.gonogohdbfs, PID: 6422
java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/app/com.softcell.gonogo.gonogohdbfs-1/split_lib_dependencies_apk.apk:classes11.dex)
at com.google.firebase.provider.FirebaseInitProvider.zza(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

These are my dependencies:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('src/main/libs/android-async-http-1.4.4.jar')
compile('com.github.afollestad.material-dialogs:core:0.8.5.7@aar') {
transitive = true
}
// for joda

// For realm with observable in jackson

//PDF library

//    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
// Toast on network library error

//disk lru cache

// PDF library for Lollipop
compile files('libs/protobuf_2_4_1.jar')
compile files('libs/SamsungIndiaIdentity.jar')
compile files('libs/xom-1.2.10.jar')
// Testing dependency
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
    exclude group: 'com.android.support', module: 'appcompat'
    exclude group: 'com.android.support', module: 'support-v4'
    exclude module: 'recyclerview-v7'
}
compile project(':gradle-git-version-master')
configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:23.1.0'
}
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:design:23.4.0'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mobsandgeeks:android-saripaar:2.0.3'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'joda-time:joda-time:2.9.2'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.4'
compile 'com.github.nisrulz:easydeviceinfo:2.0.1'
compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
compile 'cat.ereza:customactivityoncrash:1.5.0'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'es.voghdev.pdfviewpager:library:1.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'

compile('com.github.KingsMentor:MobileVisionBarcodeScanner:v1.2') { transitive = true; } // This is for barcode and QR code reader


testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support:support-annotations:23.3.0'

}

Camera2 implementation.

I wonder why even googlesamples use old deprecated camera api...
However, contributing to their samples is a bit useless in my opinion (I can be mistaken of course), that's why I suggest implementing Camera2 API to your lib.

Fragment not in full screen

I caught this on Android 7.

my xml layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/transparent">

    <fragment
        android:id="@+id/ActivityScanner_camera_frame"
        android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentEnd="true"
        app:gvb_auto_focus="true"
        app:gvb_code_format="qr_code"
        app:gvb_rect_colors="@array/rect_color" />

       <android.support.v7.widget.Toolbar
        android:id="@+id/ActivityScanner_toolbar"
        android:layout_width="match_parent"
        android:layout_height="?android:actionBarSize"
        android:background="@android:color/transparent">

        <ImageView
            android:id="@+id/ActivityScanner_flash"
            android:layout_width="20dp"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:layout_marginEnd="16dp"
            android:src="@drawable/flash" />
    </android.support.v7.widget.Toolbar>
</RelativeLayout>

java code:

barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.ActivityScanner_camera_frame);
        barcodeCapture.setRetrieval(this);

@Override
    public void onRetrieved(final Barcode barcode) { ...

image

exception when call barcodeCapture.stopScanning()

when I call stopScanning function, i have this error many times
OpenCameraSource: Exception thrown from receiver. java.lang.IllegalStateException: Detector processor must first be set with setProcessor in order to receive detection results. at com.google.android.gms.vision.Detector.receiveFrame(Unknown Source) at com.google.android.gms.samples.vision.barcodereader.ui.camera.CameraSource$FrameProcessingRunnable.run(CameraSource.java:1222) at java.lang.Thread.run(Thread.java:818)

I used the last version 2.0.0

java.lang.NoClassDefFoundError: BarcodeDetectorOptions

java.lang.NoClassDefFoundError: com.google.android.gms.vision.barcode.internal.client.BarcodeDetectorOptions

I'm with gradle import like:
compile('com.github.KingsMentor:MobileVisionBarcodeScanner:v1.2') { transitive = true; }

Activity Start and Close very slow

I have implemented the library in an activity like you have shown us in sample. But When I click on or press the back button it gives a bit lag and then close the activity.

Barcode is not retrieved!

Hello,

Thanks for your great work!

I don´t know why, but The QR-Code in Preview is not Scanned when i hold the Phone in the Code...

It just doesn´t do anything. I have written a Log in the retrieve method but there is no Log and no detection abviously.

What am I doing wrong?

Heres my Activity:
`public class WelcomeActivity extends AppCompatActivity implements BarcodeRetriever {

//Apache License for Scanner:
//http://www.apache.org/licenses/LICENSE-2.0

final int REQUEST_CAMERA_PERSMISSION = 1001;

RequestQueue queue;

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    switch(requestCode){
        case REQUEST_CAMERA_PERSMISSION:
            if (grantResults[0] == PackageManager.PERMISSION_GRANTED){
                if(ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED){
                    return;
                }else{

                }

            }
    }
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);

    queue = Volley.newRequestQueue(this);


    BarcodeCapture barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.barcode_fragment);
    barcodeCapture.setRetrieval(WelcomeActivity.this);

}

@Override
public void onRetrieved(Barcode barcode) {
    Log.d("simpleeeeeeeeeeee", "Barcode read: " + barcode.displayValue);
}

@Override
public void onRetrievedMultiple(Barcode barcode, List<BarcodeGraphic> list) {
    Log.d("simpleeeeeeeeeeee", "multiple Barcode read: " + barcode.displayValue);
}

@Override
public void onBitmapScanned(SparseArray<Barcode> sparseArray) {

}

@Override
public void onRetrievedFailed(String s) {
    Log.i("faileddddd", "retrieve of barcode failed...");
}

}`

Can't open camera first time

Hi
I'm using your library.I have one problem.First time i can't open camera in marshmallow.I clicked Allow but i can't open camera,Second time camera working perfect

Barcode auto scan not working

Hello Sir,
The library is very useful for me. But i am facing one issue while scanning barcode. In some devices barcode not getting scanned automatically. I have to click on camera to get that code. Samsung devices having this issue. Even for some MI devices Redmi 1S, MI 3.
I have given my code. Please check and let me know if i did something wrong.
Code as below :

  1. This is java code :

barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.barcode);
barcodeCapture.setRetrieval(this);

@Override
public void onRetrieved(final Barcode barcode) {
    Log.d("Barcode", "Barcode read: " + barcode.displayValue);
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            AlertDialog.Builder builder = new AlertDialog.Builder(ScanBarcodeActivity.this)
                    .setTitle("code retrieved")
                    .setMessage(barcode.displayValue)
                    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            arrayListBarcode.add(barcode.displayValue);
                            dialog.dismiss();
                        }
                    })
                    .setCancelable(false);
            builder.show();
        }
    });
}

XML Code :
<fragment android:id="@+id/barcode" android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" app:gvb_auto_focus="true" app:gvb_code_format="all_format" app:gvb_flash="true" app:gvb_rect_colors="@array/rect_color"/>

I am waiting for response. I have an urgent solution for it.

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[11.0.4,11.0.4], [15.0.1,15.0.1]], but resolves to 15.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-P'
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.job.darasastudent"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        //Enabling multidex support.
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
    implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
    implementation 'com.android.support:support-v4:28.0.0-alpha1'

    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    //If your minSdkVersion is lower than 21
    implementation 'com.android.support:multidex:1.0.3'

    //firebase
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-firestore:17.0.4'

    //location access
    //implementation 'com.google.android.gms:play-services-location:15.0.1'

    //qr scanner
    implementation 'com.github.KingsMentor:MobileVisionBarcodeScanner:2.0.0'

    // ViewModel and LiveData
    implementation "android.arch.lifecycle:extensions:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
}

apply plugin: 'com.google.gms.google-services'

plugin com.google.gms.google-services is used by firebase and disabling will mean i can't use firebase ?

Customized Rect on Scanner

Hi,

I would like to ask if how I can customized the Rectangle in Scanner? Also, I would like to only display one rectangle even of there are many codes displayed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.