Ask Your Question

Exponential_Sinusoid's profile - activity

2016-08-15 12:10:04 -0600 commented question capture not remaining open

Finally got back to looking at this and found the problem right away. For some reason the bottom three lines were tabbed in and were being included in the while-loop. In my code I have a comment between the loop and those three; I must have tabbed after the comment. Thanks for taking a look anyway.

2016-07-11 19:07:01 -0600 asked a question capture not remaining open

I'm going through the tutorial code to get a good grip on the opencv functionality. I've run into a bit of an issue with my capture apparently not wanting to remain open. The code I'm using has been lifted from the tutorial pages at: link:http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html#exercises.

I get a single frame showing up in the output video, but as far as I can tell the code should just continue to capture.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))

while(cap.isOpened()):
    ret, frame = cap.read()
    if ret==True:
        frame = cv2.flip(frame,0)

        # write the flipped frame
        out.write(frame)

        cv2.imshow('frame',frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    else:
        break
cap.release()
out.release()
cv2.destroyAllWindows()

Ideas or hints about possible solutions would be appreciated. Running Ubuntu 16.xx.