Computer Vision - VideoCapture()

 Introduction and Use

This is a function used to start capturing the video or starting the reading process or Simply opening the camera or start playing the video with imshow() 


for accurate : This is used to load the video in Memory
so we can read  and show the video frame by frame which is an another task 

code:

import cv2 as cv

cap  = cv.VideoCapture(0)

fourcc = cv.VideoWriter_fourcc(*'XVID')
output  = cv.VideoWriter("./output/myvideo.avi",fourcc,20.0,(640,480))

while cap.isOpened():

    ret, frame = cap.read()
    if not ret:
        break
    frame  = cv.flip(frame,0)
    cv.imshow("Video Capturing",frame)
    output.write(frame)
    if cv.waitKey(20) & 0xFF == ord('x'):
        print('Video saved Successfully in current Directory')
        break

#Now most important part releasing all the resourses to prevent the conflict between the resourses
output.release()
cap.release()
cv.destroyAllWindows()







this is the program where the fucntion have value 0 as argument and this is the camera numbers
while u can enter 0 to the number of camera connected to yr system and work on that
or simply can enter the path to the prerecorded video file in diffrent diffrent formats
like mp4,avi,mp42,osd etc

Comments

Pageviews