【发布时间】:2022-10-06 06:50:40
【问题描述】:
我正在尝试实时面罩检测代码,但我偶然发现流代码中的错误如下所示。关于修复的任何想法?提前致谢
print(\"[INFO] starting video stream...\")
vs = VideoStream(src=1).start()
while True:
frame = vs.read()
frame = imutils.resize(frame, width = 500)
(locs, preds) = detect_and_predict_mask(frame, faceNet, maskNet)
for (box, pred) in zip(locs, preds):
(startX, startY, endX, endY) = box
(mask, withoutMask) = pred
label = \"Mask\" if mask > withoutMask else \"No Mask\"
color = (0, 255, 0) if label == \"Mask\" else (0, 0, 255)
label = \"{}: {:.2f}%\".format(label, max(mask, withoutMask) * 100)
cv2.putText(frame, label, (startX, startY - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.45, color, 2)
cv2.rectangle(frame, (startX, startY), (endX, endY), color, 2)
cv2.imshow(\"Frame\", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord(\"q\"):
break ```
/usr/local/lib/python3.7/dist-packages/imutils/convenience.py in resize(image, width, height, inter)
---> 69 (h, w) = image.shape[:2]
AttributeError: \'NoneType\' object has no attribute \'shape\'
标签: python google-colaboratory