错误信息如下:
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)