2017-03-16 75 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