xxxxxxxxxx
#made a mistake @BloodyBeaver line 9
import cv2
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow('webcam feed' , frame)
if cv2.waitKey(1) and 0xFF == ord(' '):
break
cap.release()
cv2.destroyAllWindows()
#by using the spacebar you will be able to finish the process of video capturing
#in opencv and the window will closeeeeee
xxxxxxxxxx
# import the opencv library
import cv2
# define a video capture object
vid = cv2.VideoCapture(0)
while(True):
# Capture the video frame
# by frame
ret, frame = vid.read()
# Display the resulting frame
cv2.imshow('frame', frame)
# the 'q' button is set as the
# quitting button you may use any
# desired button of your choice
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()
xxxxxxxxxx
import cv2
frameWidth = 640
frameHeight = 480
cap = cv2.VideoCapture(0)
cap.set(3, frameWidth)
cap.set(4, frameHeight)
cap.set(10,150)
while True:
success, img = cap.read()
cv2.imshow("Result", img)
if cv2.waitKey(1) and 0xFF == ord('q'):
break
xxxxxxxxxx
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()
xxxxxxxxxx
import cv2
cap = cv2.videoCapture(0)
#check if the webcam ic opened correctly
if not cap.isopened():
raise IOError("Cannot open webcam")
while true:
ret, frame = cap.read()
frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA)
cv2.imshow('input',frame)
c = cv2.waitKey(1)
if c ==27:
cap.release()
cv2..destroyAllWindows()