Skip to content

Instantly share code, notes, and snippets.

@badjano
Created October 26, 2020 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badjano/27c870b45ffd936fa8088b7b43a0e81d to your computer and use it in GitHub Desktop.
Save badjano/27c870b45ffd936fa8088b7b43a0e81d to your computer and use it in GitHub Desktop.
Foscam Open CV Stream
from threading import Thread
import cv2
def connect(user, pwd, ip="192.168.0.1", port=88):
cap = cv2.VideoCapture('rtsp://%s:%s@%s:%d/videoMain' % (user, pwd, ip, port))
while True:
ret, frame = cap.read()
cv2.imshow("Cam: %s" % ip, frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
def all():
threads = []
user = "user"
pwd = "pwd"
port = 88
for ip in ["192.168.0.1", "192.168.0.2"]:
thread = Thread(target=connect, args=(user, pwd, ip, port,))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment