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

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 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题