File "Car_recognition.py", line 280, in <module> ori_img = draw_result(img, dict_list) File "Car_recognition.py", line 223, in draw_result orgimg = cv2ImgAddText(orgimg, car_color_str, rect_area[0], rect_area[1], (0, 255, 0), height_area) File "/home/zhxk/sufan/license_recognition_server/license_recognition_server/utils/cv_puttext.py", line 9, in cv2ImgAddText fontText = ImageFont.truetype( File "/home/zhxk/.local/lib/python3.8/site-packages/PIL/ImageFont.py", line 996, in truetype return freetype(font) File "/home/zhxk/.local/lib/python3.8/site-packages/PIL/ImageFont.py", line 993, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/zhxk/.local/lib/python3.8/site-packages/PIL/ImageFont.py", line 248, in __init__ self.font = core.getfont( OSError: cannot open resource
时间: 2024-01-03 08:03:42 浏览: 183
这个错误似乎是Pillow库在加载字体文件时出现问题。您可以尝试以下解决方法:
1. 检查字体路径是否正确:您需要在cv_puttext.py文件中检查字体路径是否正确。确保字体文件存在并且路径正确。
2. 安装所需的字体:如果字体文件确实存在但仍出现错误,请尝试在系统中安装所需的字体。命令如下:
```
sudo apt-get install ttf-mscorefonts-installer
```
3. 更新Pillow库:如果上述解决方法都无法解决问题,请尝试更新Pillow库。命令如下:
```
pip install -U Pillow
```
希望这些解决方法能够帮助您解决问题。
相关问题
Traceback (most recent call last): File "D:/yolov7-lpr/yolov7_plate-master/detect_rec_plate.py", line 228, in <module> dict_list = detect_Recognition_plate(model, img, device,plate_rec_model,opt.img_size) File "D:/yolov7-lpr/yolov7_plate-master/detect_rec_plate.py", line 158, in detect_Recognition_plate result_dict = get_plate_rec_landmark(orgimg, xyxy, conf, landmarks, class_num,device,plate_rec_model) File "D:/yolov7-lpr/yolov7_plate-master/detect_rec_plate.py", line 110, in get_plate_rec_landmark plate_number,rec_prob,plate_color,color_conf = get_plate_result(roi_img,device,plate_rec_model) #对车牌小图进行识别 File "D:\yolov7-lpr\yolov7_plate-master\plate_recognition\plate_rec.py", line 75, in get_plate_result preds = model(input) File "D:\Anaconda\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "D:\yolov7-lpr\yolov7_plate-master\plate_recognition\plate_rec.py", line 218, in forward x = torch.cat(global_context, 1) RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 9 but got size 8 for tensor number 1 in the list. 请详细解释错误原因
这个错误是因为在执行 torch.cat() 操作时,要求拼接的张量在除了第一维以外的其他维度的 size 必须一致。但是在你的代码中,拼接的张量的 size 不一致,预期是 size 为 9,但是实际上 size 为 8。具体来说,torch.cat() 操作的张量列表 global_context 中有一个张量的 size 不符合要求,导致拼接失败。
你需要查看一下 global_context 列表中每个张量的 size,找出 size 不符合要求的张量,并且修改其 size,使得所有张量的 size 在除了第一维以外的其他维度上都一致。
阅读全文
相关推荐









