首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试运行openalpr错误,但此错误遇到OSError:[Errno 2]没有这样的文件或目录

尝试运行openalpr错误,但此错误遇到OSError:[Errno 2]没有这样的文件或目录
EN

Stack Overflow用户
提问于 2017-04-23 22:07:57
回答 1查看 213关注 0票数 0

我尝试运行python程序,其中我想要扫描车牌使用我的笔记本电脑的网络摄像头,但我得到这个错误,当我试图运行它。为此,我使用了OpenALPR和OpenCV。

我附上了一个错误的截图。

错误图像:

下面是程序代码的链接。

代码语言:javascript
复制
import json, shlex, subprocess

class PlateReader:


    def __init__(self):
        #webcam subprocess args
        webcam_command = "fswebcam -r 640x480 -S 20 --no-banner --quiet alpr.jpg"
        self.webcam_command_args = shlex.split(webcam_command)

        #alpr subprocess args
        alpr_command = "alpr -c eu -t hr -n 300 -j alpr.jpg"
        self.alpr_command_args = shlex.split(alpr_command)


    def webcam_subprocess(self):
        return subprocess.Popen(self.webcam_command_args, stdout=subprocess.PIPE)


    def alpr_subprocess(self):
        return subprocess.Popen(self.alpr_command_args, stdout=subprocess.PIPE)


    def alpr_json_results(self):
        self.webcam_subprocess().communicate()
        alpr_out, alpr_error = self.alpr_subprocess().communicate()

        if not alpr_error is None:
            return None, alpr_error
        elif "No license plates found." in alpr_out:
            return None, None

        try:
            return json.loads(alpr_out), None
        except ValueError, e:
            return None, e


    def read_plate(self):
        alpr_json, alpr_error = self.alpr_json_results()

        if not alpr_error is None:
            print alpr_error
            return

        if alpr_json is None:
            print "No results!"
            return

        results = alpr_json["results"]

        ordinal = 0
        for result in results:
            candidates = result["candidates"]

            for candidate in candidates:
                if candidate["matches_template"] == 1:
                    ordinal += 1
                    print "Guess {0:d}: {1:s} {2:.2f}%".format(ordinal, candidate["plate"], candidate["confidence"])


if __name__=="__main__":
    plate_reader = PlateReader()
    plate_reader.read_plate()

(附言:我花了很多时间来解决这个StackOverflow的代码缩进问题,但是我做不到)

EN

回答 1

Stack Overflow用户

发布于 2018-06-20 06:40:18

我也用过类似的代码。只需从alpr_command = "alpr -c eu -t hr -n 300 -j alpr.jpg"中删除此属性-t hr即可。这段代码应该可以工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43572180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档