Advertisement
MrLunk

Use IP camera URL in OPENCV

Dec 13th, 2020
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. You can access most IP cameras using the method below.
  2.  
  3. import cv2
  4.  
  5. # insert the HTTP(S)/RSTP feed from the camera
  6. url = "http://username:password@your_ip:your_port/tmpfs/auto.jpg"
  7.  
  8. # open the feed
  9. cap = cv2.VideoCapture(url)
  10.  
  11. while True:
  12. # read next frame
  13. ret, frame = cap.read()
  14.  
  15. # show frame to user
  16. cv2.imshow('frame', frame)
  17.  
  18. # if user presses q quit program
  19. if cv2.waitKey(1) & 0xFF == ord("q"):
  20. break
  21.  
  22. # close the connection and close all windows
  23. cap.release()
  24. cv2.destroyAllWindows()
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement