2 Star 4 Fork 0

fplei / HeathCodeReg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.MD 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
fplei 提交于 2022-11-26 03:37 . update README.MD.

健康码识别(红/黄/蓝/绿)

使用场景:后台将通过收集的所有健康码图片进行批量识别后,将红马、黄码人员通知到指定人,以便后续跟踪 环境:ubuntu20 python3.9 opencv4.5 jdk8

通过Java调用脚本的传参形式实现java和python交互

class:CmdProcessUtils
    /**
     * 执行python脚本
     * @param pythonFile
     * @param url
     * @return
     */
    public synchronized static String invokePython(String pythonFile,String url){
        if(org.apache.commons.lang3.StringUtils.isEmpty(url)){
            return null;
        }
        try {
            String pythonPath=pythonFile;
            String[] args = new String[] { "python3", pythonPath, url};
            Process proc = Runtime.getRuntime().exec(args);// 执行py文件
            BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            StringBuffer buffer=new StringBuffer();
            while ((line = in.readLine()) != null) {
                buffer.append(line);
            }
            in.close();
            proc.waitFor();
            return buffer.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

将脚本上传至服务器,直接调用,将脚本输出的json结果进行接受解析即可 String _regResult = CmdProcessUtils.invokePython("xxx/HeathCodeReg.py", localPath);

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fplei/heath-code-reg.git
git@gitee.com:fplei/heath-code-reg.git
fplei
heath-code-reg
HeathCodeReg
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891