Ask Your Question
0

DNN Superres & Video

asked 2020-06-20 03:38:15 -0600

User284093 gravatar image

DNN Superres works fine on images but when I try and use video it creates a 1KB empty video file? (No errors otherwise)

sr = dnn_superres.DnnSuperResImpl_create()

path = "FSRCNN_x3.pb"
sr.readModel(path)
sr.setModel("fsrcnn", 3)

capture = cv2.VideoCapture('./outtest.mp4')

width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
currentfps = int(capture.get(cv2.CAP_PROP_FPS))
frames = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
Duration = int(frames/currentfps)
fps = 2*currentfps 

out = cv2.VideoWriter('./Output.mp4', cv2.VideoWriter_fourcc(*'avc1'), (currentfps), (width,height), 0)

while(capture.isOpened()):
    ret, frame = capture.read()
    if ret == True:

        result = sr.upsample(frame)
        out.write(result)

    else:
        break

capture.release()
out.release()
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-06-20 03:42:36 -0600

berak gravatar image

the framesize of your upsampled video images does not match the size you gave to the VideoWriter, so it will reject writing frames

(out.write() has a return value, too, just saying ...)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-06-20 03:38:15 -0600

Seen: 540 times

Last updated: Jun 20 '20