xuyp4876 2021-05-22 18:28 采纳率: 33.3%
浏览 112

关于cv2.rectangle的问题

def draw_box(image, boxes, classes, scores, category_index, thresh=0.5, line_thickness=5):  # thresh为置信度
    box_to_display_str_map = collections.defaultdict(list)
    box_to_color_map = collections.defaultdict(str)

    filter_low_thresh(boxes, scores, classes, category_index, thresh, box_to_display_str_map, box_to_color_map)
    for box, color in box_to_color_map.items():
        xmin, ymin, xmax, ymax = box
        (left, right, top, bottom) = (xmin * 1, xmax * 1,
                                      ymin * 1, ymax * 1)
        image = cv2.rectangle(image, (left, top), (right, bottom), color, 2)
        image = cv2.putText(image, box_to_display_str_map, (left, top), cv2.FONT_HERSHEY_COMPLEX, 6, color, line_thickness)
Traceback (most recent call last):
  File "C:/Users/xuyp4876/Desktop/Faster-RCNN/摄像头2.py", line 79, in <module>
    main()
  File "C:/Users/xuyp4876/Desktop/Faster-RCNN/摄像头2.py", line 65, in main
    frame = draw_box(frame,
  File "C:\Users\xuyp4876\Desktop\Faster-RCNN\videodraw_box.py", line 60, in draw_box
    image = cv2.rectangle(image, (left, top), (right, bottom), color, 2)
TypeError: function takes exactly 4 arguments (2 given)
[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-71670poj\opencv\modules\videoio\src\cap_msmf.cpp (435) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
libpng warning: iCCP: cHRM chunk does not match sRGB

我看网上的rectangle都可以这样用,但是我的就不可以,请问有无解决办法?

  • 写回答

2条回答 默认 最新

  • 关注

    错误:libpng警告:iCCP:cHRM块与sRGB不匹配

    解决:若电脑使用的是QQ输入法,请替换成别的输入法。

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料