Я написал код для создания видео с ограничительными рамками. Мой текущий код читает и загружает видео с ограничительной рамкой. Есть ли способ сохранить видео вместо закрытия всех открытых видео.
Вот мой фрагмент кода. Любая помощь приветствуется
fvs = FileVideoStream('./test_videos/video.mp4').start()
time.sleep(2.0)
pcount = 0
evencount = 0
print("Model input preparation finished....")
user = input("\nTo proceed to analysis press y\n")
out = cv2.VideoWriter('outputjcf.mp4',cv2.VideoWriter_fourcc('m','p','4','v'), fps, (300,300))
while (fvs.more() and pcount < 477):
frame = fvs.read()
if(evencount %2 == 0):
(h, w) = frame.shape[:2]
blob = cv2.dnn.blobFromImage(cv2.resize(frame, (300, 300)), 1.0, (300, 300), (104.0, 177.0, 123.0))
conf_threshold = 0.4
net.setInput(blob)
detections = net.forward()
bboxes = []
confidence = detections[0, 0, 0, 2]
if(confidence > conf_threshold):
x1 = int(detections[0, 0, 0, 3] * w)
y1 = int(detections[0, 0, 0, 4] * h)
x2 = int(detections[0, 0, 0, 5] * w)
y2 = int(detections[0, 0, 0, 6] * h)
if(p[pcount] < 0.85):
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 255), 2)
else:
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
else:
continue
evencount += 2
pcount += 1
out.write(frame)
cv2.imshow('Video', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
fvs.stop()
cv2.destroyAllWindows()
out.release()