CameraScan

abstract class CameraScan<T : Any> : ICamera, ICameraControl

相机扫描基类定义;内置的默认实现见:BaseCameraScan

快速实现扫描识别主要有以下几种方式:

1、通过继承 [BaseCameraScanActivity]或者[BaseCameraScanFragment]或其子类,可快速实现扫描识别。 (适用于大多数场景,自定义布局时需覆写getLayoutId方法)

2、在你项目的Activity或者Fragment中实例化一个[BaseCameraScan]。(适用于想在扫描界面写交互逻辑,又因为项目 架构或其它原因,无法直接或间接继承[BaseCameraScanActivity]或[BaseCameraScanFragment]时使用)

3、继承[CameraScan]自己实现一个,可参照默认实现类[BaseCameraScan],其他步骤同方式2。(高级用法,谨慎使用)

Author

Jenly

Follow me

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard

扫描结果回调

Functions

Link copied to clipboard
abstract fun bindFlashlightView(v: View?): CameraScan<T>

绑定手电筒,绑定后可根据光照传感器,动态显示或隐藏手电筒。

Link copied to clipboard
abstract fun enableTorch(torch: Boolean)

设置闪光灯(手电筒)是否开启

Link copied to clipboard
abstract fun getCamera(): Camera?

获取 Camera

Link copied to clipboard

获取扩展参数:当CameraScan的默认实现不满足你的需求时,你可以通过自定义实现一个CameraScan; 然后通过此方法获取扩展参数,进行扩展参数的传递;需使用时直接在实现类中获取 mExtras即可。

Link copied to clipboard
abstract fun hasFlashUnit(): Boolean

是否支持闪光灯

Link copied to clipboard
abstract fun isTorchEnabled(): Boolean

闪光灯(手电筒)是否开启

Link copied to clipboard
abstract fun lineZoomIn()

线性放大

Link copied to clipboard
abstract fun lineZoomOut()

线性缩小

Link copied to clipboard
abstract fun lineZoomTo(@FloatRange(from = 0.0, to = 1.0) linearZoom: Float)

线性缩放到指定比例

Link copied to clipboard
abstract fun release()

释放

Link copied to clipboard
abstract fun setAnalyzeImage(analyze: Boolean): CameraScan<T>

设置是否分析图像,默认为:true;通过此方法可以动态控制是否分析图像;在连续扫描识别时,可能会用到。

Link copied to clipboard
abstract fun setAnalyzer(analyzer: Analyzer<T>?): CameraScan<T>

设置分析器,如果内置的一些分析器不满足您的需求,你也可以自定义Analyzer, 自定义时,切记需在startCamera之前调用才有效。

Link copied to clipboard
abstract fun setAutoStopAnalyze(autoStopAnalyze: Boolean): CameraScan<T>

设置是否自动停止分析图像;默认为:true;

Link copied to clipboard
abstract fun setBrightLightLux(lightLux: Float): CameraScan<T>

设置光照强度足够明亮的阈值(单位:lux),需要通过bindFlashlightView绑定手电筒才有效

Link copied to clipboard
abstract fun setCameraConfig(cameraConfig: CameraConfig): CameraScan<T>

设置相机配置,请在startCamera之前调用

Link copied to clipboard
abstract fun setDarkLightLux(lightLux: Float): CameraScan<T>

设置光照强度足够暗的阈值(单位:lux),需要通过bindFlashlightView绑定手电筒才有效

Link copied to clipboard
fun setNeedTouchZoom(needTouchZoom: Boolean): CameraScan<T>

设置是否需要支持触摸缩放

Link copied to clipboard

设置扫描结果回调

Link copied to clipboard
abstract fun setPlayBeep(playBeep: Boolean): CameraScan<T>

设置是否播放提示音

Link copied to clipboard
abstract fun setVibrate(vibrate: Boolean): CameraScan<T>

设置是否振动

Link copied to clipboard
abstract fun startCamera()

启动相机预览

Link copied to clipboard
abstract fun stopCamera()

停止相机预览

Link copied to clipboard
abstract fun zoomIn()

放大

Link copied to clipboard
abstract fun zoomOut()

缩小

Link copied to clipboard
abstract fun zoomTo(ratio: Float)

缩放到指定比例