diff --git a/examples/opencv_gopro/ffmpegless-preview.py b/examples/opencv_gopro/ffmpegless-preview.py new file mode 100644 index 0000000..90d5524 --- /dev/null +++ b/examples/opencv_gopro/ffmpegless-preview.py @@ -0,0 +1,24 @@ +#This is the script without the need of a FFmpeg installation, pure OpenCV +#This is not useful for image processing (eg: find faces) as there will be more lag, around 6 seconds added. +import cv2 +import numpy as np +from time import time +import socket +from goprocam import GoProCamera +from goprocam import constants +gpCam = GoProCamera.GoPro() +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +t=time() +gpCam.livestream("start") +cap = cv2.VideoCapture("udp://10.5.5.9:8554") +while True: + nmat, frame = cap.read() + cv2.imshow("GoPro OpenCV", frame) + if cv2.waitKey(1) & 0xFF == ord('q'): + break + if time() - t >= 2.5: + sock.sendto("_GPHD_:0:0:2:0.000000\n".encode(), ("10.5.5.9", 8554)) + t=time() +# When everything is done, release the capture +cap.release() +cv2.destroyAllWindows()