Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
属性错误:';dict';python opencv和openalpr_Python_Opencv_Openalpr - Fatal编程技术网

属性错误:';dict';python opencv和openalpr

属性错误:';dict';python opencv和openalpr,python,opencv,openalpr,Python,Opencv,Openalpr,我只是用opencv和openalpr在网络摄像头流上画图,我让它们各自工作,但当我把它们加在一起时,我会出现这个错误 Invalid pattern provided: auwide Valid patterns are located in the auwide.patterns file Plate #1 Plate Confidence - 6U01 82.790466 Traceback (most recent call last): File "

我只是用opencv和openalpr在网络摄像头流上画图,我让它们各自工作,但当我把它们加在一起时,我会出现这个错误

Invalid pattern provided: auwide
Valid patterns are located in the auwide.patterns file
Plate #1
      Plate   Confidence
-         6U01   82.790466
Traceback (most recent call last):
File "C:/Users/Alex/PycharmProjects/displayrec/testing.py", line 31, in 
<module>
rec = plate.detectMultiScale(frame, 1.3, 5)
AttributeError: 'dict' object has no attribute 'detectMultiScale'

Process finished with exit code 1
import numpy as np
import cv2
import sys
import os
from openalpr import Alpr

alpr = Alpr("auwide", "openalpr.conf", "runtime_data")

if not alpr.is_loaded():
print("Error loading OpenALPR")
sys.exit(1)

alpr.set_top_n(1)
alpr.set_default_region("auwide")

plate = cv2.CascadeClassifier('au.xml')

vc = cv2.VideoCapture(0)

while True:
ret, frame = vc.read()

img_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
noise_removal = cv2.bilateralFilter(img_gray, 9, 75, 75)
equal_histogram = cv2.equalizeHist(noise_removal)
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
morph_image = cv2.morphologyEx(equal_histogram, cv2.MORPH_OPEN, kernel, 
iterations=15)
sub_morp_image = cv2.subtract(equal_histogram,morph_image)

rec = plate.detectMultiScale(frame, 1.3, 5)

for (x, y, w, h) in rec:
    cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
    roi_gray = frame[y:y + h, x:x + w]
    roi_color = frame[y:y + h, x:x + w]

cv2.imshow("Result",frame)

if cv2.waitKey(1) & 0xFF == ord('q'):
    break


if ret:
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

    cv2.imwrite("img.jpg", sub_morp_image)

    results = alpr.recognize_file("img.jpg")

    i = 0

    for plate in results['results']:
        i += 1
        print("Plate #%d" % i)
        print("   %12s %12s" % ("Plate", "Confidence"))
        for candidate in plate['candidates']:
            prefix = "-"
            if candidate['matches_template']:
                prefix = "*"

            print("  %s %12s%12f" % (prefix, candidate['plate'], 
candidate['confidence']))
else:
    break;

vc.release()
alpr.unload()
cv2.destroyAllWindows()