api_output = detect_text(frame)
recoq = []
for text in api_output :
recoq.append(text.description)
# # print(recoq[0])
pattern = "[0-9]{2}[ga-he]\s[0-9]{4}"
pattern2 = "[0-9]{4}"
match_pattern = re.search(pattern, recoq[0])
match_number_list = re.findall(pattern2, recoq[0])
if match_pattern :
labels.append(match_pattern.group())
label = match_pattern.group()
elif not match_number_list :
label = " none "
else :
label = labels[-1]
# # print("searched : ",label)
#label = match_pattern.group()
b,g,r,a = 0,0,0,0
img_pil = Image.fromarray(frame)
draw = ImageDraw.Draw(img_pil)
draw.text((10, 10), label, font=font, fill=(b,g,r,a))
img = np.array(img_pil)
# # Remove the bounding boxes with low confidence
img = postprocess(img, outs)
File "dr.py", line 238, in <module>
label = labels[-1]
IndexError: list index out of range
Please help me get this result I don't understand If you turn this around,
python
labels[-1]
is the last element in the labels
list. If index out of range
error occurred here, the reason is that labels
is an empty list. (If you had one element, you could bring anything.)
© 2024 OneMinuteCode. All rights reserved.