【问题标题】:NoneType error has no shape error on face mask detectionNoneType 错误在面罩检测中没有形状错误
【发布时间】: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


    【解决方案1】:

    嘿,你找到解决问题的方法了吗?几个星期以来我一直有同样的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-24
      • 2019-07-01
      • 2022-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多