DecodeConfig

open class DecodeConfig

解码配置:主要用于在扫码识别时,提供一些配置,便于扩展。通过配置可决定内置分析器的能力,从而间接的控制并简化扫码识别的流程

设置解码 [setHints]内置的一些解码可参见如下:

[DecodeFormatManager.DEFAULT_HINTS] [DecodeFormatManager.ALL_HINTS] [DecodeFormatManager.CODE_128_HINTS] [DecodeFormatManager.QR_CODE_HINTS] [DecodeFormatManager.ONE_DIMENSIONAL_HINTS] [DecodeFormatManager.TWO_DIMENSIONAL_HINTS] [DecodeFormatManager.DEFAULT_HINTS]

如果不满足您也可以通过DecodeFormatManager.createDecodeHints自己配置支持的格式

识别区域可设置的方式有如下几种: [setFullAreaScan] 设置是否支持全区域扫码识别,优先级比识别区域高 [setAnalyzeAreaRect] 设置需要分析识别区域,优先级比识别区域比例高,当设置了指定的分析区域时,识别区域比例和识别区域偏移量相关参数都将无效 [setAreaRectRatio] 设置识别区域比例,默认[DEFAULT_AREA_RECT_RATIO],设置的比例最终会基于分析图像帧上裁减出此比例的一个矩形进行扫码识别,优先级最低

以上几种识别区域都是基于[androidx.camera.core.ImageAnalysis] 配置的分析目标分辨率作为参照的;请注意区分 [androidx.camera.core.Preview] 与 [androidx.camera.core.ImageAnalysis]配置的区别。

即判定区域分析的优先级顺序为:[setFullAreaScan] -> [setAnalyzeAreaRect] -> [setAreaRectRatio]

Author

Jenly

Follow me

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

获取需要分析识别的区域。

Link copied to clipboard

获取识别区域水平方向偏移量,支持负数。 大于 0 时,居中向右偏移;小于 0 时,居中向左偏移。

Link copied to clipboard

获取识别区域比例,默认 DEFAULT_AREA_RECT_RATIO

Link copied to clipboard

获取识别区域垂直方向偏移量,支持负数。 大于 0 时,居中向下偏移;小于 0 时,居中向上偏移。

Link copied to clipboard
fun getHints(): Map<DecodeHintType, Any>?

获取配置的解码支持类型 DecodeHintType

Link copied to clipboard

是否支持全区域扫码识别。

Link copied to clipboard

是否支持使用多解码。

Link copied to clipboard

是否支持识别反色码(黑白颜色反转)。

Link copied to clipboard

是否支持识别反色码(条码黑白颜色反转的码)并使用多解码。

Link copied to clipboard

是否支持扫垂直的条码。

Link copied to clipboard

是否支持垂直的条码并使用多解码。

Link copied to clipboard
fun setAnalyzeAreaRect(analyzeAreaRect: Rect?): DecodeConfig

设置需要分析识别区域。

Link copied to clipboard
fun setAreaRectHorizontalOffset(areaRectHorizontalOffset: Int): DecodeConfig

设置识别区域水平方向偏移量,支持负数。 大于 0 时,居中向右偏移;小于 0 时,居中向左偏移。

Link copied to clipboard
fun setAreaRectRatio(@FloatRange(from = 0.5, to = 1.0) areaRectRatio: Float): DecodeConfig

设置识别区域比例,默认 DEFAULT_AREA_RECT_RATIO

Link copied to clipboard
fun setAreaRectVerticalOffset(areaRectVerticalOffset: Int): DecodeConfig

设置识别区域垂直方向偏移量,支持负数。 大于 0 时,居中向下偏移;小于 0 时,居中向上偏移。

Link copied to clipboard

设置是否支持全区域扫码识别,优先级高于识别区域相关配置。

Link copied to clipboard
fun setHints(hints: Map<DecodeHintType, Any>?): DecodeConfig

设置解码 Hint。

Link copied to clipboard

设置是否支持使用多解码。

Link copied to clipboard
fun setSupportLuminanceInvert(supportLuminanceInvert: Boolean): DecodeConfig

设置是否支持识别反色码(黑白颜色反转)。

Link copied to clipboard
fun setSupportLuminanceInvertMultiDecode(supportLuminanceInvertMultiDecode: Boolean): DecodeConfig

设置是否支持识别反色码(条码黑白颜色反转的码)并使用多解码。

Link copied to clipboard
fun setSupportVerticalCode(supportVerticalCode: Boolean): DecodeConfig

设置是否支持扫垂直的条码。

Link copied to clipboard
fun setSupportVerticalCodeMultiDecode(supportVerticalCodeMultiDecode: Boolean): DecodeConfig

设置是否支持垂直的条码并使用多解码。

Link copied to clipboard
open override fun toString(): String