dm77 / barcodescanner Goto Github PK
View Code? Open in Web Editor NEWBarcode Scanner Libraries for Android
License: Other
Barcode Scanner Libraries for Android
License: Other
HI! If i reduce view size from xml it doesn't recognize any qrcode, while if i set height and width to match_parent it recognize them. How can i do?
I have a Lenovo A269i device. It has a 2mp camera and no autofocus. Need to make barcode scanning on this phone only as it is a requirement. Any suggestions? Please help
using only pure zxing lib does not allow to have such immersive scan view
best regards
In my project manifest i have targetSdkVersion 10, and Android Studio compilation failed due to error
01:13:23.198 [WARN] [org.gradle.api.Project] [D:\android projects......\src\main\AndroidManifest.xml:3, C:\Users\0C18~1\AppData\Local\Temp\manifestMerge4183381711556281919.xml:2] Main manifest has but library uses targetSdkVersion='19'
Can you please make your targetSdkVersion to 8 or 10, i am just using this old target version for the old style menu.
Is there a way to offset ViewFinderView? It would also be nice to be able to set my own styles/colors for the laser, border etc.
Note: I mean when using as a library as opposed to importing and altering/forking the source myself.
Hi,
The fragment is in the top of the screen, and the frame in the middle of the screen, so It appears cuted. I'ts very annoying and make the library useless.
any help thanks how to change the scanner view size
how do i implement to be come OCR ??
I'm getting W/CameraBase﹕ An error occurred while connecting to camera when the app opens up, a black screen with the red scan line appears.
What's causing this?
I'm using Nexus 4 with Android Lollipop 5.0
Hello there,
Im using your ZBar library but i have little problem or maybe missunderstanding.
If I create xml layout where, for example, i put two LinearLayouts which have dynamic width
first
android:layout_width="0dp"
android:layout_weight="0.6"
and second
android:layout_width="0dp"
android:layout_weight="0.4"
and i put ZBarScannerView into first layout, the image show as preview is distorted, have wrong aspect ratio
How to fix it? I have tried to call requestLayout and invalidate but no help
i was checking a code a little bit, but it looks it uses only Display resolutions and not current View container?
Thx
Hello,
Thanks for your easy to implement ZBar scanner! I am having a problem though, when I run this code on the Sony Experia Z (Also tested on Nexus 5 without problems):
mScannerView = new ZBarScannerView(this); // Programmatically initialize the scanner view
List<BarcodeFormat> formats = new ArrayList<BarcodeFormat>();
formats.add(BarcodeFormat.QRCODE);
mScannerView.setFormats(formats);
mScannerView.setFlash(false);
mScannerView.setAutoFocus(false);
setContentView(mScannerView); // Set the scanner view as the content view
As you can see I explicitly set autofocus to false, but after 1-2 seconds, the exception gets thrown:
java.lang.RuntimeException: autoFocus failed
at android.hardware.Camera.native_autoFocus(Native Method)
at android.hardware.Camera.autoFocus(Camera.java:975)
at me.dm7.barcodescanner.core.CameraPreview$1.run(CameraPreview.java:196)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Do you have any idea how I can fix this? Thanks in advance!
Hi, I import project in Eclipse using zbar. All it's OK but i get errors in ViewFinderView.java
Line 67: paint.setColor(resources.getColor(R.color.viewfinder_mask));
Error: R cannot to be resolved to a variable
Line 81: paint.setColor(resources.getColor(R.color.viewfinder_border));
Line 83: paint.setStrokeWidth(resources.getInteger(R.integer.viewfinder_border_width));
Line 84: int lineLength = resources.getInteger(R.integer.viewfinder_border_length);
Error: R cannot to be resolved to a variable
Any ideas?
Thanks
Hi,
made each step, one by one from readme.
It works very good, but it also scan black spaces. Then I put my phone on table, it scanned barcode and return Barcode: 0149141685971267 ; Type: DATABAR. Or then I focus keyboard, it also return fake datas.
How to avoid this situation?
Thanks.
Hi there,
Many thanks for this awesome library! I'm wondering if there's a way to alter the frame of the viewfinder via the ZBarScannerView class (without forking)? We're exclusively scanning QR codes in our app, and would like the frame to be square instead of landscape.
Thanks in advance for any help!
This is my code: https://gist.github.com/ZNickq/49605d299dbabb321c28
And the layout file looks like this: https://gist.github.com/ZNickq/aabb05a91bc676f186b3
Basically if the fragment is not fullscreen, the view is stretched out. A library i used on iOS just cropped some parts of the screen, so it maintained a good aspect ratio, any way to do this here too? Or does anyone have any code to make the fragment maintain its aspect ratio, while being under certain constraints?
But with the code i provided, it still never scans, even though it is full-screen.. the onresult method never runs, if i point it at a qr code it doesn't do anything, any idea what i'm doing wrong?
I am using v1.6 of your library and on certain devices specifically the PantechP9070 and ZTE V768 I am getting a NullPointerException
which happens at ZXingScannerView.java:90. It seems like there is an issue with creating the camera preview, how can I solve this?
java.lang.NullPointerException
at me.dm7.barcodescanner.zxing.ZXingScannerView.onPreviewFrame(ZXingScannerView.java:90)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:603)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3818)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
at dalvik.system.NativeStart.main(NativeStart.java)
Hey! Because of the delay when fetching an camera instance. Is it possible to run ZXingScannerView.startCamera on a different thread than the UI thread? That would make the switching through an activity to the camera activity look a bit smoother.
This is what you get when you run gradle dependencies
on a project using this library
+--- me.dm7.barcodescanner:zxing:1.4
| +--- com.google.zxing:core:3.1.0
| \--- me.dm7.barcodescanner:core:1.3
| \--- com.android.support:support-v4:20.0.0
| \--- com.android.support:support-annotations:20.0.0
well, maybe i'm too stupid because i really don't understand
can you more explain, step-by-step how it so i can use as library?
thank you
I have data embedded into json string into qrcode. i would like to get the scan result from the data into json decoded string. let me know how to extract it into individual form.
Thanks.
There is any way to read an image from disk?
I have this code working on other project with zbar, but I don't find the way to do this with your project.
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), selectedImage);
Image barcode = new Image(bitmap.getWidth(), bitmap.getHeight(), "RGB4");
// get bytes array from image
int bytes = bitmap.getWidth()*bitmap.getHeight()*4;
ByteBuffer buffer = ByteBuffer.allocate(bytes);
bitmap.copyPixelsToBuffer(buffer);
// pass image as bytes to zbar
barcode.setData(buffer.array());
// convert to Y800
barcode = barcode.convert("Y800");
// prepare scanner
createScanner();
// scan image to find a qr in it
mScanner.scanImage(barcode)
I got the following crash in our crashlytics:
java.lang.RuntimeException: Unable to resume activity {xxxxx/xxxxx.activity.ScannerActivity}: java.lang.RuntimeException: setParameters failed
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2854)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2883)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Camera.java)
at android.hardware.Camera.setParameters(Camera.java:1551)
at me.dm7.barcodescanner.core.BarcodeScannerView.setFlash(SourceFile:91)
at xxxxx.activity.ScannerActivity.onResume(SourceFile:69)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
at android.app.Activity.performResume(Activity.java:5211)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2844)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2883)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(NativeStart.java)
in ZBar sample.
The view finder uses the size of the devices screen to calculate the offsets to use when drawing the view. This causes an issue if the barcode scanner is used in a view that does not take up the full activity. Here is a screenshot of the problem I am seeing. (I believe this causes the issue seen in Issue #16)
The flash is not working on my devices, if i use:
String flag = String.valueOf( this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH));
Toast.makeText(this, flag, Toast.LENGTH_LONG).show();
It gives me true, but if i use this:
String flag = String.valueOf(mScannerView.getFlash());
Toast.makeText(this, flag, Toast.LENGTH_LONG).show();
It gives me false, so, what can i do to activate flash?
Thanks
Hi there, how can I switch between front and back camera?
Android Studio is still in Beta, and until then I would suggest that you don't answer people's request for instructions on how to build or use your project with suggestions that they use a 'beta' product.
I also agree that projects should transition to maven now (and gradle at some point or at least, once A.S. goes live), but that doesn't help the developer who doesn't have time to learn a 3rd party build system like gradle, before using the library they wish to.
Only having http://mvnrepository.com/artifact/me.dm7.barcodescanner/zxing/1.1 the .aar file up for download from there... really doesn't help anyone who doesn't want to YET use beta software(Android Studio).
Hello. I found this project in GitHub https://github.com/dm77/barcodescanner2. I want to import it from GitHub to eclipse. I dowloaded zip and unzip. I already had gradle and grdale plugin in eclipse. I creat local.properties file in root directory of project barcodescanner-master with path to android-sdk. In cmd from root direcoty of project i run
gradle eclipse
but i have error
Task eclipse not found in root project barcodescanner-master
I guess i have to add
apply plugin: 'eclipse'
somewhere in build.gradle file. But i don't know where.
If i add in first line of gradle.build i have this error
Task eclipse not found in project barcodescanner. Some candidates are: 'eclipse'
It looks little bit differ. Addition is Some candidates are: 'eclipse'
Please help me. Thank you
ZXing lib seems never scaned any QR code.
It always said NotFoundException.
I want to increase the size of the scanning area in the scanner view, how can I do this?
Thanks
This is what I had to do in order to get it working with maven:
<dependency>
<groupId>me.dm7.barcodescanner</groupId>
<artifactId>zxing</artifactId>
<version>1.0</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>me.dm7.barcodescanner</groupId>
<artifactId>core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>me.dm7.barcodescanner</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
<type>aar</type>
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>2.2</version>
</dependency>
Am I doing something wrong?
Currently it's only possible to use the back camera it would be nice if you could make it configurable to use the front camera
I really like this lib but need to read barcodes using front camera
Without this lib I cannot use barcode scanner in full screen (immersive) mode
Is there any hack to use front camera or will it be very problematic to add support for it when zxing supports it?
Regards
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
signingConfigs {
}
}
dependencies {
compile 'com.github.pedrovgs:renderers:1.0.9'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:r7'
compile 'me.dm7.barcodescanner:zxing:1.0'
compile 'me.dm7.barcodescanner:zbar:1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
repositories {
}
I had the configuration on the build gradle file and I got an error from the console. Are there anything I need correct??
Error:com.android.support:support-v4:19.0.1 (double-click here to find usages.)
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.android.support:support-v4:19.0.1.
Required by:
doctordemo:app:unspecified
> Could not find com.android.support:support-v4:19.0.1.
Required by:
doctordemo:app:unspecified > com.android.support:appcompat-v7:19.0.0
> Could not find com.android.support:support-v4:19.0.1.
Required by:
doctordemo:app:unspecified > me.dm7.barcodescanner:zbar:1.0 > me.dm7.barcodescanner:core:1.0
Hi,
the barcodescanner initially works fine but after trying to auto focus two to three times i get a RuntimeException: autoFocus failed:
java.lang.RuntimeException: autoFocus failed
at android.hardware.Camera.native_autoFocus(Native Method)
at android.hardware.Camera.autoFocus(Camera.java:975)
at me.dm7.barcodescanner.core.CameraPreview$1.run(CameraPreview.java:196)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
any idea how to fix that?
Thanks
Criss
There is an error showing like this in eclipse like this in the res/values/styles.xml like this:
Error: No resource found that matches the given name: attr 'windowActionBarOverlay'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
Also when I added the support library android support v7 appcompat, the above errrors are solved, but when running the app, force closes and shows an error like this in logcat:
Caused by: java.lang.ClassNotFoundException: Didn't find class "me.dm7.barcodescanner.zbar.sample.MainActivity" on path: DexPathList[[zip file "/data/app/me.dm7.barcodescanner.zbar.sample-1.apk"],nativeLibraryDirectories=[/data/app-lib/me.dm7.barcodescanner.zbar.sample-1, /vendor/lib, /system/lib, /system/lib/arm]]
What does this mean? What do I have to do to clear these errors?
When I scan a code with the original ZXing app on android it is showing yellow dot's where it's recognizing a barcode. In my project we need to scan QR codes in a dark enviroment and this will help me determine how well the scanner is performing in low light. And the dots look cool too! Is it possible to enable them with this library too?
Thanks!
Hi, could you please rename folder names in native lib jars?
This is ok:
$ jar vtf zbar/zbar/libs/armeabi.jar
0 Sun Feb 23 19:28:22 MSK 2014 lib/
6148 Sun Feb 23 19:28:22 MSK 2014 lib/.DS_Store
0 Sun Feb 23 19:28:22 MSK 2014 __MACOSX/
0 Sun Feb 23 19:28:22 MSK 2014 __MACOSX/lib/
120 Sun Feb 23 19:28:22 MSK 2014 __MACOSX/lib/._.DS_Store
0 Sun Feb 23 19:26:58 MSK 2014 lib/armeabi/
900820 Sun Feb 23 19:26:58 MSK 2014 lib/armeabi/libiconv.so
113208 Sun Feb 23 19:26:58 MSK 2014 lib/armeabi/libzbarjni.so
This is not (armeabi-v7a -> lib):
$ jar vtf zbar/zbar/libs/armeabi-v7a.jar
0 Sun Feb 23 19:28:48 MSK 2014 armeabi-v7a/
6148 Sun Feb 23 19:28:48 MSK 2014 armeabi-v7a/.DS_Store
0 Sun Feb 23 19:28:52 MSK 2014 __MACOSX/
0 Sun Feb 23 19:28:52 MSK 2014 __MACOSX/armeabi-v7a/
120 Sun Feb 23 19:28:48 MSK 2014 __MACOSX/armeabi-v7a/._.DS_Store
0 Sun Feb 23 19:26:58 MSK 2014 armeabi-v7a/armeabi-v7a/
896728 Sun Feb 23 19:26:58 MSK 2014 armeabi-v7a/armeabi-v7a/libiconv.so
106816 Sun Feb 23 19:26:58 MSK 2014 armeabi-v7a/armeabi-v7a/libzbarjni.so
And this too (x86 -> lib):
$ jar vtf zbar/zbar/libs/x86.jar
0 Sun Feb 23 19:29:04 MSK 2014 x86/
0 Sun Feb 23 19:26:58 MSK 2014 x86/x86/
929388 Sun Feb 23 19:26:58 MSK 2014 x86/x86/libiconv.so
170816 Sun Feb 23 19:26:58 MSK 2014 x86/x86/libzbarjni.so
I have a valid QR code that gets read in iOS (using a different library) but fails to be read in Android. I have followed the example verbatim and still not getting it. Please advise -- Is there anything I'm doing wrong? Perhaps in generating the QR code? But it works in iOS?
I have attached my QR code below:
When i change screen orientation it doesn't scan barcode.
I tested with Nexus 4 and Galaxy Note 3. If i don't change orientation, i have no problem.
I added the following dependency line compile 'me.dm7.barcodescanner:zxing:1.1' but it seems it is not working for me.I keep getting this error:-Failed to find:me.dm7.barcodescanner:zxing:1.1.Btw i am using android studio 0.8.2
Nexus 7 front cam doesn't work. It works with the zxing library. Could you please look at this issue.
Good work.
thanks.
Hi
I need to parse vin code.Is it possible to parse vin code using this api?
Thanks
How can i use front camera? I want switch cameras with button.
compile 'me.dm7.barcodescanner:zbar:1.0'
can't find
compile 'me.dm7.barcodescanner:zxing:1.0'
it's work
Hi dm77,
May i know how to add AmbientLight,return bitmap to your ZXing sample As ZXing Barcodescanner did?
I using your zxing sample (ScannerFragment).
Thanks.
I really cant figure how to import this in to eclipse or build a library from this project. I tried so much... COnverted to Eclipse with Gradle... didnt work. Import project with SpringTeams GradleEclipse pugin didnt work.
I noticed several crashes in our crashlytics where autoFocus failed:
java.lang.RuntimeException: autoFocus failed
at android.hardware.Camera.native_autoFocus(Camera.java)
at android.hardware.Camera.autoFocus(Camera.java:1120)
at me.dm7.barcodescanner.core.CameraPreview$1.run(SourceFile:203)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5137)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:718)
at dalvik.system.NativeStart.main(NativeStart.java)
I already check if the device has autoFocus (hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS)). If not, the Auto-Focus Button is disabled.
Affected devices:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.