Last active
February 3, 2024 23:05
-
-
Save im-noob/490f467175715b616055453fa8de8f4b to your computer and use it in GitHub Desktop.
Tapo Camera TP Link Live Stream in Python in Open CV2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
# Replace the following with your camera's IP address and RTSP stream URL | |
user = 'ACCOUNT_PASSWORD_USER' | |
password = "ACCOUNT_PASSWORD" | |
RTSP_URL = f'rtsp://{user}:{password}@192.168.0.15:554/stream1' # High Quality | |
# RTSP_URL = f'rtsp://{user}:{password}@192.168.0.15:554/stream2' # Low Quality | |
# Create a VideoCapture object | |
capture = cv2.VideoCapture(RTSP_URL) | |
# Check if the camera is opened successfully | |
if not capture.isOpened(): | |
print('Could not open camera') | |
while True: | |
try: | |
# Read the frame | |
status, frame = capture.read() | |
if not status: | |
print('Error while reating the frame...') | |
break | |
frame = cv2.resize(frame, None, None, fx=0.5, fy=0.5) | |
# Display the frame | |
cv2.imshow('Live Stream', frame) | |
# Wait for a key press | |
if cv2.waitKey(1) & 0xFF == 27: | |
break | |
except cv2.error as e: | |
print("Error in Processing... ", e) | |
# Release the camera | |
capture.release() | |
# Destroy all windows | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment