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

根据特征向量对证件号码进行识别 #6

Open
UserNamezhangxi opened this issue Aug 5, 2019 · 4 comments
Open

根据特征向量对证件号码进行识别 #6

UserNamezhangxi opened this issue Aug 5, 2019 · 4 comments

Comments

@UserNamezhangxi
Copy link

//根据特征向量对证件号码进行识别
public int recognitionChar(Mat charImage) {
String result = "";
File file = new File(FEATURE_FILE_PATH);
//遍历FEATURE_FILE_PATH 下的特征文件
File[] featureDataFiles = file.listFiles();
double minDistance = Double.MAX_VALUE;
//获取到特征数据
float[] fv = extractFeatureData(charImage);

    for (File f : featureDataFiles) {
        //readFeatureVector 方法计算与目标特征的最小距离
        double dist = calculateDistance(fv, readFeatureVector(f));
        if (minDistance > dist) {
            minDistance = dist;
            result = f.getName();
        }
    }
    Log.i("OCR-INFO", result);
    return Integer.parseInt(result.substring(0, 1));  
}

return 这里为什么返回的是文件名字的substring ,文件名为feature_0.txt ,这里就崩溃了,没有看懂这里的含义,能否解释一下呢,多谢大神!

@18601949127
Copy link
Owner

18601949127 commented Aug 5, 2019 via email

@UserNamezhangxi
Copy link
Author

result = f.getName(); // result = feature_0.txt
然后将其result.substring(0, 1) 返回,这块没懂。文件名是feature_0.txt ,代码执行后 结果是 “f” ,在对 ”f” 进行 Integer.parseInt 就异常了 。为什么是对文件名的第一位进行 整数解析呢?

@UserNamezhangxi
Copy link
Author

我的分析是,自己制作一个卡片 数字是0~9,然后进行分析,分析完后,手动的吧这些特征数据改名为
feature_0.txt -- >0.txt
feature_1.txt --->1.txt
....
feature_9.txt ---> 9.txt 必须和自己制作的卡片数字对应起来。
然后机器识别的时候匹配到对应的特征文本,就拿到文本的名(result = f.getName();),在进行
result.substring(0, 1) 就拿到了对应的数字,直接显示。这样子也是达到效果了

@18601949127
Copy link
Owner

18601949127 commented Aug 9, 2019 via email

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

2 participants