Paddle OCR not working for live video feed #12278
Replies: 3 comments
-
Hello, please check if the result is normal. You can print and paste the result here for a look. |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks a lot for replying but the result is not printed at all. Issue I guess is with video frames. It worked well for images for me because when images are attached as JPEG or PDF, there are no empty values. But for video frames, it is probably giving out empty arrays and I tried to solve around it but it didn't work for me so far. Hence, this issue: TypeError: object of type 'NoneType' has no len(). Code: import cv2 Start video capturecap = cv2.VideoCapture(0) Use a default fontfont_path = ImageFont.load_default()
cap.release() Output: [2024/04/18 10:25:20] ppocr DEBUG: dt_boxes num : 0, elapsed : 0.9545092582702637 |
Beta Was this translation helpful? Give feedback.
-
It seems that there is no target during the detection stage, which leads to an error in obtaining the length of the boxes. You can check whether the OCR detection model parameter configuration is correct, or whether the current frame contains text targets. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue: I have experimented a lot for several weeks but I am pasting a simple code version to understand if logic is failing at any point. I request the community's help at the earliest. Ofc, Paddle OCR worked well with images and I was able to fetch very good results but I need it to work for live video feed.
Error:
Traceback (most recent call last):
File "D:\01_IAV-Codes\02_OCR-Models\test_01.py", line 22, in
frame = draw_ocr(frame, line, font_path=font_path)
File "C:\Users\I011786\Miniconda\envs\env-paddle\lib\site-packages\paddleocr\tools\infer\utility.py", line 384, in draw_ocr
scores = [1] * len(boxes)
TypeError: object of type 'NoneType' has no len()
My code:
import cv2
from paddleocr import PaddleOCR, draw_ocr
from PIL import Image, ImageFont
Start video capture
cap = cv2.VideoCapture(0)
Use a default font
font_path = ImageFont.load_default()
ocr = PaddleOCR(use_gpu=True, use_angle_cls=True, lang='en') # need to run only once to download and load model into memory
while True:
# Capture frame-by-frame
ret, frame = cap.read()
if not ret:
break
cap.release()
cv2.destroyAllWindows()
Beta Was this translation helpful? Give feedback.
All reactions