从无人机Parrot 2.0流视频。 Python + cv2

时间:2016-06-08 21:23:12

标签: python opencv ar.drone drone

我正试图访问无人机相机的视频流。

这是我的代码:

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 个答案:

答案 0 :(得分: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()

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