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

Python 尝试运行openalpr错误,但此错误遇到OSError:[Errno 2]没有此类文件或目录,python,python-2.7,opencv,openalpr,Python,Python 2.7,Opencv,Openalpr,我试着运行python程序,在这个程序中,我想用笔记本电脑的网络摄像头扫描车牌,但当我试着运行它时,我遇到了这个错误。 我使用OpenALPR和OpenCV来实现这一点 我附上一个错误截图 错误图像: 下面是程序代码的链接 import json, shlex, subprocess class PlateReader: def __init__(self): #webcam subprocess args webcam_command = "fs

我试着运行python程序,在这个程序中,我想用笔记本电脑的网络摄像头扫描车牌,但当我试着运行它时,我遇到了这个错误。 我使用OpenALPR和OpenCV来实现这一点

我附上一个错误截图

错误图像:

下面是程序代码的链接

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()

(p.s-我花了很多时间来解决StackOverflow的代码缩进问题,但我做不到)

我也用过类似的代码。只需从
alpr\u command=“alpr-c eu-t hr-n 300-j alpr.jpg”
此atribute
-t hr
中删除即可。这段代码应该可以正常工作。

请发布您得到的错误回溯以及重现此错误所需的最小代码量。@dbliss我已经附上了错误的屏幕截图。是的,我认为最好只在您的帖子中包含文本。