2016-06-08 72 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() 

试试这个代码...这对我有用。