2017-03-16 6 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를 사용하여 스트림을 엽니 다. 이 스크립트가 정기적으로 보내는 "keep alive"메시지에 유의하십시오. 이러한 메시지가 없으면 카메라가 곧 스트리밍을 중단합니다.

저는 스크립트의 요소와 함께 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.