STEPS: for video capture using opencv python
import cv2
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print("Error opening camera")
print("Error opening camera")
ret, frame = cap.read()
cv2.imshow("Frame", frame)
key = cv2.waitKey(1)
if key == ord('q'):
break
break
cap.release()
cv2.destroyAllWindows()
Source Code for Video Capturing
import cv2
# Open the default camera
cap = cv2.VideoCapture(0)
# Check if camera is opened successfully
if not cap.isOpened():
print("Error opening camera")
# Read the frames from the camera
while True:
ret, frame = cap.read()
if not ret:
print("Error reading frame")
break
# Show the frame
cv2.imshow("Frame", frame)
# Break the loop if the 'q' key is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the camera and close all windows
cap.release()
cv2.destroyAllWindows()
# Open the default camera
cap = cv2.VideoCapture(0)
# Check if camera is opened successfully
if not cap.isOpened():
print("Error opening camera")
# Read the frames from the camera
while True:
ret, frame = cap.read()
if not ret:
print("Error reading frame")
break
# Show the frame
cv2.imshow("Frame", frame)
# Break the loop if the 'q' key is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the camera and close all windows
cap.release()
cv2.destroyAllWindows()
No comments:
Post a Comment
Tell us how you like it.