CameraScan

abstract class CameraScan<T> : ICamera, ICameraControl

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

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

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

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

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

Author

Jenly

Follow me

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
扫描结果回调

Properties

Link copied to clipboard
val ASPECT_RATIO_16_9: Float = 1.7777778f
纵横比:16:9
Link copied to clipboard
val ASPECT_RATIO_4_3: Float = 1.3333334f
纵横比:4:3
Link copied to clipboard
protected open var isNeedTouchZoom: Boolean
是否需要支持触摸缩放
Link copied to clipboard
A camera on the device facing the opposite direction as the device's screen.
Link copied to clipboard
A camera on the device facing the same direction as the device's screen.
Link copied to clipboard
扫描返回结果的key;解析方式可参见:parseScanResult

Functions

Link copied to clipboard
绑定手电筒,绑定后可根据光照传感器,动态显示或隐藏手电筒。
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
解析扫描结果
Link copied to clipboard
abstract fun release()
释放
Link copied to clipboard
abstract fun setAnalyzeImage(analyze: Boolean): CameraScan<T>
设置是否分析图像,默认为:true;通过此方法可以动态控制是否分析图像;在连续扫描识别时,可能会用到。 如:当分析图像成功一次之后,如需继续连扫,可以在结果回调函数中等处理了自己的业务后,继续调用此方法并设置为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; 大多数情况下,单次扫描的场景应用较多;很容易忘记主动调用 setAnalyzeImage 来停止分析。 如果设置为:true;即:启用了自动停止分析图像:当分析图像成功一次之后;那么设置的分析图像会自动停止;如果此时 需要继续分析图像,可以在结果回调里面调用 setAnalyzeImage 来控制是否继续分析图像。 如果设置为:false;即:禁用了自动停止分析图像:当分析图像成功一次之后;不会有任何变化;会继续分析图像。
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
设置扫描结果回调
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)
缩放到指定比例