Guest User

Untitled

a guest
Mar 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #requires python3
  2. import cv2
  3. import numpy as np
  4. from time import time
  5. import socket
  6. from goprocam import GoProCamera
  7. from goprocam import constants
  8.  
  9. #Initialise GoPro
  10. gpCam = GoProCamera.GoPro()
  11. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  12. t=time()
  13. gpCam.livestream("start")
  14. cap = cv2.VideoCapture("udp://10.5.5.9:8554")
  15. while True:
  16. ret, frame = cap.read()
  17. if ret:
  18. cv2.imshow("GoPro Stream Test", frame)
  19. if cv2.waitKey(1) & 0xFF == ord('q'):
  20. break
  21. if time() - t >= 2.5:
  22. #send UDP message to GoPro so stream is not closed
  23. sock.sendto("_GPHD_:0:0:2:0.000000\n".encode(), ("10.5.5.9", 8554))
  24. t=time()
  25. # When everything is done, release the capture
  26. cap.release()
  27. cv2.destroyAllWindows()
Add Comment
Please, Sign In to add comment