2016-06-08 17 views
0

我想要訪問我的無人機攝像頭的流。從無人機Parrot 2.0流視頻。 Python + cv2

這裏我的代碼:

import cv2 
import numpy 
import libardrone 

drone = libardrone.ARDrone() 
cap = drone.image 

while(True): 
    cap = drone.image 
    if not cap: 
     continue 
    ret, frame = convert 
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 
    cv2.imshow('frame',gray) 
    if cv2.waitKey(1) & 0xFF == ord('q'): 
     break 

cap.release() 
cv2.destroyAllWindows() 

它不工作。它沒有打開任何框架,我可以看到我的無人機攝像頭的流式視頻。 有什麼問題?你有什麼建議嗎?

謝謝!

回答

1
import cv2 
cam = cv2.VideoCapture('tcp://192.168.1.1:5555') 
running = True 
while running: 
    # get current frame of video 
    running, frame = cam.read() 
    if running: 
     cv2.imshow('frame', frame) 
     if cv2.waitKey(1) & 0xFF == 27: 
      # escape key pressed 
      running = False 
    else: 
     # error reading frame 
     print 'error reading video feed' 
cam.release() 
cv2.destroyAllWindows() 

試試這個代碼...這對我有用。