电竞程序猿 2019-06-25 14:31 采纳率: 0%
浏览 2405

python使用opencv处理视频流调用cv2.resizeWindow方法报错?

错误信息如下:
Traceback (most recent call last):
File "./tools/test.py", line 36, in
cv2.resizeWindow("enhanced", 640, 360);
cv2.error: OpenCV(4.1.0) /io/opencv/modules/highgui/src/window_QT.cpp:592: error: (-27:Null pointer) NULL guiReceiver (please create a window) in function 'cvResizeWindow'

代码:

# -*- coding: utf-8 -*-



import PIL

import cv2



if __name__ == '__main__':

    writeVideo_flag = True 

    video_src = "rtsp://admin:Admin123@85.18.13.222"

    video_capture = cv2.VideoCapture(video_src)

    source_file = '/approot1/ioth/ai/tf-faster-rcnn-master'

    print(video_capture.isOpened())

    if writeVideo_flag:

    # 将检测的视频结果输出到output.avi,detection.txt

    # Define the codec and create VideoWriter object

        w = int(video_capture.get(3))

    print(w)

        h = int(video_capture.get(4))

    print(h)

        fourcc = cv2.VideoWriter_fourcc(*'MJPG')

        out = cv2.VideoWriter(source_file + '/img/output.avi', fourcc, 15, (w, h))

        list_file = open(source_file + '/img/detection.txt', 'w')

        frame_index = -1 



    fps = 0.0

    fpscount = 0





    #while True:

    ret, frame = video_capture.read()  # frame shape 640*480*3

    print(frame)

    while True:



        if ret == True:

            #窗口可以随意调整大小
                        #这行报错
            cv2.resizeWindow("detect Inout", 640, 360);

            fpscount += 1

        else:

            break;

        if fpscount % 1 == 0:

            image = PIL.Image.fromarray(frame)
  • 写回答

2条回答 默认 最新

  • Asssshzy 2022-10-22 23:37
    关注

    在前面加一行
    cv2.namedWindow('detect Inout',0)

    评论

报告相同问题?

悬赏问题

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