All Projects → yanzhenjie → android-zbar-sdk

yanzhenjie / android-zbar-sdk

Licence: LGPL-2.1 license
🔗 android-zbar-sdk, provide jni source, so file and jar file used alone, gradle/maven remote dependencies.

Projects that are alternatives of or similar to android-zbar-sdk

Zxinglite
🔥 ZXing的精简版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
Stars: ✭ 2,117 (+580.71%)
Mutual labels:  qrcode, barcode, zbar, qrcode-scanner, barcode-scanner
BarcodeReader
Simple multi-format barcode reader for Windows
Stars: ✭ 26 (-91.64%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
barcode-server
Barcode Server for Barcode Client-Server android application
Stars: ✭ 40 (-87.14%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
barcode scan2
[reborned barcode_scan] A flutter plugin for reading 2D barcodes and QR codes.
Stars: ✭ 43 (-86.17%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
barcode-detector
Spec compliant polyfill of the Barcode Detection API 🤳
Stars: ✭ 31 (-90.03%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Efqrcode
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.
Stars: ✭ 4,121 (+1225.08%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (+215.76%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Barcodescanner.xf
Barcode Scanner using GoogleVision API for Xamarin Form
Stars: ✭ 82 (-73.63%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
Scannermapp
A QR-code and barcode acanner app built in Delphi using ZXing and TFrameStand
Stars: ✭ 65 (-79.1%)
Mutual labels:  qrcode, barcode, qrcode-scanner, barcode-scanner
koder
QR/bar code scanner for the Browser
Stars: ✭ 73 (-76.53%)
Mutual labels:  qrcode, barcode, zbar
Barcode To Pc App
Barcode to PC app
Stars: ✭ 121 (-61.09%)
Mutual labels:  barcode, qrcode-scanner, barcode-scanner
garden.zbarcam
Migrated to https://github.com/kivy-garden/zbarcam
Stars: ✭ 49 (-84.24%)
Mutual labels:  qrcode, barcode, zbar
Swiftscan
A barcode and qr code scanner( 二维码/条形码扫描、生成,仿微信、支付宝)
Stars: ✭ 293 (-5.79%)
Mutual labels:  qrcode, barcode, qrcode-scanner
Czxing
C++ port of ZXing and ZBar for Android.
Stars: ✭ 854 (+174.6%)
Mutual labels:  qrcode, barcode, qrcode-scanner
Qzxing
Qt/QML wrapper library for the ZXing library. 1D/2D barcode image processing library
Stars: ✭ 401 (+28.94%)
Mutual labels:  qrcode, barcode, barcode-scanner
React Native Qrcode Scanner
A QR code scanner component for React Native.
Stars: ✭ 1,796 (+477.49%)
Mutual labels:  qrcode, barcode, qrcode-scanner
Segno
Python QR Code and Micro QR Code encoder
Stars: ✭ 144 (-53.7%)
Mutual labels:  qrcode, barcode
Rxtool
Android开发人员不得不收集的工具类集合 | 支付宝支付 | 微信支付(统一下单) | 微信分享 | Zip4j压缩(支持分卷压缩与加密) | 一键集成UCrop选择圆形头像 | 一键集成二维码和条形码的扫描与生成 | 常用Dialog | WebView的封装可播放视频 | 仿斗鱼滑动验证码 | Toast封装 | 震动 | GPS | Location定位 | 图片缩放 | Exif 图片添加地理位置信息(经纬度) | 蛛网等级 | 颜色选择器 | ArcGis | VTPK | 编译运行一下说不定会找到惊喜
Stars: ✭ 11,567 (+3619.29%)
Mutual labels:  qrcode, barcode
Barcode
barcode.php - Generate barcodes from a single PHP file. MIT license.
Stars: ✭ 141 (-54.66%)
Mutual labels:  qrcode, barcode
Bardecoder
Detect and decode QR Codes, written in 100% Rust.
Stars: ✭ 145 (-53.38%)
Mutual labels:  qrcode, qrcode-scanner

Zbar and libiconv are based on LGPL-2.1 open source, based on LGPL-2.1, I organized the Android platform for the ZBar, to facilitate the use of developers.

中文文档

Most Android developers are relatively unfamiliar to jni, especially in the compilation of Zbar need to compile libiconv, so I have sorted out the full jni code.

I have the Zbar available, the following you can choose to use:

  1. can be directly ndk-build compiled JNI source
  2. Jar packages and so files that can be used alone
  3. can be remotely dependent on the native Zbar
  4. Encapsulated Zbar can directly scan the camera

I used the libiconv is released at 2017-02-02 the latest version 1.15.

zbar: https://github.com/ZBar/ZBar
libiconv: https://www.gnu.org/software/libiconv

Usage

Only core function of ZBar

If you only want to identify the barcode/QRCode data in byte[], then you only need to rely on native ZBar.

Add dependencies:

  • jar file and so file jar file in the android-zbar-sdk/jar folder, so files in the android-zbar-sdk\zbar\src\main\jniLibs folder.

  • Gradle

compile 'com.yanzhenjie.zbar:zbar:1.0.0'
  • Maven
<dependency>
  <groupId>com.yanzhenjie.zbar</groupId>
  <artifactId>zbar</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

Note: The use of remote dependencies will load all the files so the platform, if you just want to rely on some of these platforms, then you need to add the compilation configuration:

defaultConfig {
    applicationId ...
    ...

    ndk {
        abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64', 'x86', 'x86_64'
    }
}

For example, you only need armeabi and armeabi-v7a:

ndk {
    abiFilters 'armeabi', 'armeabi-v7a'
}

Zbar's core recognition barcode/QRCode code is as follows.

byte[] imageData = ...;

Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(imageData);
// Set the image capture area.
// barcode.setCrop(startX, startY, width, height);

String qrCodeString = null;

int result = mImageScanner.scanImage(barcode);
if (result != 0) {
    SymbolSet symSet = mImageScanner.getResults();
    for (Symbol sym : symSet)
        qrCodeString = sym.getData();
}

if (!TextUtils.isEmpty(resultStr)) {
    // Successfully.
}

Not only that, you can also use the camera to combine this code to identify barcode/QRCode.

There are examples of camera scans in Demo.

Package of Camera and ZBar

If you are not familiar with the camera, you can also use my camera and ZBar package, will be very simple to use the camera to complete the two-dimensional code scan.

Add dependencies:

  • Gradle
compile 'com.yanzhenjie.zbar:camera:1.0.0'
  • Maven
<dependency>
  <groupId>com.yanzhenjie.zbar</groupId>
  <artifactId>camera</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

This is a simple example in Activity:

activity_scan.xml

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.yanzhenjie.zbar.camera.CameraPreview
        android:id="@+id/capture_preview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
<RelativeLayout/>

ScanActivity.java

private CameraPreview mPreview;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scan);
    
    mPreview = (CameraPreview) findViewById(R.id.capture_preview);
    mPreview.setScanCallback(callback);
}

/**
 * Start camera.
 */
private void startScan() {
    mPreview.start();
}

/**
 * Stop camera.
 */
private void stopScan() {
    mPreview.stop();
}

/**
 * Result.
 */
private ScanCallback callback = new ScanCallback() {
    @Override
    public void onScanResult(String content) {
        // Successfully.
    }
};

@Override
protected void onPause() {
    // Must be called here, otherwise the camera should not be released properly.
    stopScan();
    super.onPause();
}

The actual development you need to pay attention to the RunTime Permission, the camera is occupied and so on.

For RunTime-Permission, I recommend you use AndPermission:
https://github.com/yanzhenjie/AndPermission

Such as whether the camera started successfully:

/**
 * Start camera.
 */
private void startScan() {
    if(mPreview.start()) {
        // The camera starts successfully and you can start a scan animation.
    } else {
        // The camera starts failing and you can tell the user.
    }
}

For more examples please refer to sample.

Proguard-rules

If you already have this rule, then you do not have to add.

-keepclassmembers class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    native <methods>;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].