项目作者: tssA8

项目描述 :
barcode detector
高级语言: Java
项目地址: git://github.com/tssA8/Camera2MediaCodec.git
创建时间: 2018-03-19T08:08:55Z
项目社区:https://github.com/tssA8/Camera2MediaCodec

开源协议:

下载


Camera2MediaCodec

=================================

  1. 1.use async mediaCodec
  2. 2.use camera2
  3. 3.use zbar to scan barcode

Gradle dependency

  1. //zbar
  2. compile 'com.yanzhenjie.zbar:zbar:1.0.0'
  3. compile 'com.yanzhenjie.zbar:camera:1.0.0'
  4. compile 'com.yanzhenjie:permission:1.0.7'
  5. //draw the view if you want
  6. compile 'com.github.ChillingVan:android-openGL-canvas:v1.2.2.3'
  7. //event bus
  8. compile 'org.greenrobot:eventbus:3.1.1'

Usage

*camera2

  1. first: init camera2
  2. if(usingFrontCamera){
  3. FrontCamera frontCamera = new FrontCamera();
  4. frontCamera.buildCamera2();// frontCamera.buildCamera1();
  5. }else{
  6. BackCamera backCamera = new BackCamera();
  7. backCamera.buildCamera2();// backCamera.buildCamera1();
  8. }
  9. second: startCamera when surfaceTexture is available or onSet
  10. `

*zbar detect resolution set

  1. can set resoluition to zbar library
  2. if your device support 1920*1080 . e.g STREAMING_RESOLUTION = 1920
  3. `

zbar Add interface callback code

  1. * init zbarProcessorRunnable

if(zbarProcessorRunnable == null && imageWidth >0 && imageHeight >0 ){
zbarProcessorRunnable = new ZbarProcessorRunnable(
imageWidth,//image width
imageHeight,
previewSize.getWidth(),//camera2 preview width
previewSize.getHeight()
);
}

  1. * set data to zbar

if(zbarProcessorRunnable!=null) {
zbarProcessorRunnable.setNextFrame(data);
}
`````

Preview

alt text