Skip to main content
Removed fluff and typos fixed
Source Link
Greenonline
  • 2.8k
  • 5
  • 24
  • 36

capture Capture video for a certain time then quit and save to a folder using opencv3 on raspberry piOpenCV 3

I am using this sample code from opencvthe OpenCV documentation and what the code is simply doing is capturing a video and when itsit's interrupted it saves it to a folder what.

What I want to do it capture the video for a certain period of time and, quit, and then save it to the folder and I really don't know how to do it I will very much appreciate your help in advance if someone could assist me please am totally new to python and opencv so pardon me cheers.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
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

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

capture video for a certain time then quit and save to a folder using opencv3 on raspberry pi

am using this sample code from opencv documentation and what the code is simply doing is capturing a video and when its interrupted it saves it to a folder what I want to do it capture the video for a certain period of time and quit then save it to the folder and I really don't know how to do it I will very much appreciate your help in advance if someone could assist me please am totally new to python and opencv so pardon me cheers.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
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

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()

Capture video for a certain time then quit and save to a folder using OpenCV 3

I am using this sample code from the OpenCV documentation and what the code is simply doing is capturing a video and when it's interrupted it saves it to a folder.

What I want to do it capture the video for a certain period of time, quit, and then save it to the folder and I really don't know how to do it.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
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

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackRaspi/status/862829707707985924
Source Link
user3880651
  • 189
  • 2
  • 3
  • 9

capture video for a certain time then quit and save to a folder using opencv3 on raspberry pi

am using this sample code from opencv documentation and what the code is simply doing is capturing a video and when its interrupted it saves it to a folder what I want to do it capture the video for a certain period of time and quit then save it to the folder and I really don't know how to do it I will very much appreciate your help in advance if someone could assist me please am totally new to python and opencv so pardon me cheers.

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

# Define the codec and create VideoWriter object
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

# Release everything if job is finished
cap.release()
out.release()
cv2.destroyAllWindows()