Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否支持只扫描扫码框的码 #140

Closed
itsgm opened this issue Apr 12, 2021 · 5 comments
Closed

是否支持只扫描扫码框的码 #140

itsgm opened this issue Apr 12, 2021 · 5 comments

Comments

@itsgm
Copy link

itsgm commented Apr 12, 2021

这个太灵敏了,经常出现扫错的时候,扫描二维码一部分就出结果了,能否设置只识别扫码框的

@jenly1314
Copy link
Owner

jenly1314 commented Apr 12, 2021

        //初始化解码配置
        DecodeConfig decodeConfig = new DecodeConfig();
        decodeConfig.setAreaRectRatio(0.625f);//设置识别区域比例,默认0.8,减少识别区域,设置识别区域比例为:0.625,与默认预览的框最接近的比例
        getCameraScan().setAnalyzer(new MultiFormatAnalyzer(decodeConfig))//设置分析器
                .startCamera();//启动预览

@itsgm
Copy link
Author

itsgm commented Apr 16, 2021

@jenly1314 我用的1.9.9的版本,没有这个api

@jenly1314
Copy link
Owner

v1.x版本

 getCaputreHelper().framingRectRatio(0.625f);

@qweenhool
Copy link

qweenhool commented Sep 15, 2022

        //初始化解码配置
        DecodeConfig decodeConfig = new DecodeConfig();
        decodeConfig.setAreaRectRatio(0.625f);//设置识别区域比例,默认0.8,减少识别区域,设置识别区域比例为:0.625,与默认预览的框最接近的比例
        getCameraScan().setAnalyzer(new MultiFormatAnalyzer(decodeConfig))//设置分析器
                .startCamera();//启动预览

最新的2.2版本的demo,将QRCodeActivity里的setAreaRectRatio设置为0.625f,二维码不在识别框里就识别出来了。

@jenly1314
Copy link
Owner

        //初始化解码配置
        DecodeConfig decodeConfig = new DecodeConfig();
        decodeConfig.setAreaRectRatio(0.625f);//设置识别区域比例,默认0.8,减少识别区域,设置识别区域比例为:0.625,与默认预览的框最接近的比例
        getCameraScan().setAnalyzer(new MultiFormatAnalyzer(decodeConfig))//设置分析器
                .startCamera();//启动预览

最新的2.2版本的demo,将QRCodeActivity里的setAreaRectRatio设置为0.625f,二维码不在识别框里就识别出来了。

设置识别区域为:0.625f 只是理论上最接近的比例,并没有说是完全等于;因为预览框的默认比例是0.625f,其比例参照物是基于PreviewView的宽高(宽与高较小的那一个;一般为手机屏幕的宽度,平板的高度),而上面所说的设置识别区域为:0.625f,其比例参照物是基于分析图像的宽高;只有当手机屏幕的可预览宽高比与分析图像的宽高比一致的情况下,这种场景才最具有说明性。

更细节的说明:当Camera的预览区域呈现在手机屏幕上时,因为预览的分辨率与手机屏幕的分辨率的比例不一致时,为了保证预览不变形,所以在展示时真实的预览大小可能会被裁减一部分后呈现在手机屏幕上;而分析图像时的分辨率可能和真实的预览也不一样,但理论上宽高比是一样的;由于预览区域被裁减了一部分,导致用户所能预览到的范围比最终分析的图像范围要小。
而此时,识别区域就可能会比预览框区域大。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants