电竞程序猿 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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算