2017-03-16 164 views

回答

2

在Hero4和更新,你可以通过获取此URL启动UDP流:

http://10.5.5.9/gp/gpControl/execute?p1=gpStream&a1=proto_v2&c1=restart 

这将打开一个UDP流:

udp://10.5.5.9:8554 

阅读本流是有点麻烦。 This Python script使用FFMPEG打开流。请注意此脚本定期发送的“保持活动”消息:如果没有这些消息,相机将很快停止流式传输。

我使用该脚本的元素,以及OpenCV VideoCapture对象以编程方式访问Hero5会话中的流。相关代码如下所示:

cap = cv2.VideoCapture("udp://:8554", cv2.CAP_FFMPEG) 
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 
last_message = time.time() 

while some_condition(): 

    # Get an image 
    ret, img = cap.read() 

    # Do something with img 
    cv2.imshow("My Window", img) 
    cv2.waitKey(1) 

    # Keep alive. 
    current_time = time.time() 
    if current_time - last_message >= keep_alive_period/1000: 
     logger.info("Sending keep alive message to %s.", self.host) 
     sock.sendto(message, ("10.5.5.9", 8554)) 
     last_message = current_time 

cv2.destroyWindow(window_name) 
cap.release() 

更多信息here