Skip to content

Instantly share code, notes, and snippets.

@shellkore
Created February 26, 2020 16:49
Show Gist options
  • Save shellkore/5050560fc03b1146cc1e3560540e7169 to your computer and use it in GitHub Desktop.
Save shellkore/5050560fc03b1146cc1e3560540e7169 to your computer and use it in GitHub Desktop.
using ipcam to access it over RPi
import cv2
import time
ipcam_ip = "192.168.43.1"
ipcam_port = "8080"
ipcam_url = f"rtsp://{ipcam_ip}:{ipcam_port}/h264_ulaw.sdp"
cam = cv2.VideoCapture(ipcam_url)
cv2.namedWindow("ipcam")
while True:
ret, frame = cam.read()
cv2.imshow("ipcam", frame)
if not ret:
break
k = cv2.waitKey(1)
if k%256 == 27:
# ESC pressed
print("Escape hit, closing...")
break
elif k%256 == 32:
# SPACE pressed - Replace this with IR sensor logic.
imageNumber = str(int(time.time()))
img_name = f"opencv_frame_{imageNumber}.png"
cv2.imwrite(img_name, frame)
print(f"{img_name} saved!!!")
cam.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment