コード例 #1
0
    print "ARMED"


def open_camera():
    # yuck - opencv has no way to count # of cameras, so do this hack of looking for /dev/video*
    numCameras = len(
        filter(lambda s: s.startswith("video"), os.listdir("/dev")))

    c = cv2.VideoCapture()
    # We start our search with higher numbered (likely external) cameras
    for cnum in range(0, numCameras):
        c.open(numCameras - cnum - 1)
        if c.isOpened():
            return c

    raise Exception('No cameras found')


print "DroneScript - Visual-Follow Running"
v = get_vehicle()

while True:
    if mustarm:
        wait_for_arm(v)

    video_in = open_camera()
    homedir = os.path.expanduser("~")
    logger = Logger(path=homedir + "/Videos/")

    process_stream(video_in, logger, vehicle=v, require_arming=mustarm)
コード例 #2
0
    while not v.armed:
        time.sleep(0.001)
    print "ARMED"


def open_camera():
    # yuck - opencv has no way to count # of cameras, so do this hack of looking for /dev/video*
    numCameras = len(filter(lambda s: s.startswith("video"), os.listdir("/dev")))

    c = cv2.VideoCapture()
    # We start our search with higher numbered (likely external) cameras
    for cnum in range(0, numCameras):
        c.open(numCameras - cnum - 1)
        if c.isOpened():
            return c

    raise Exception('No cameras found')

print "DroneScript - Visual-Follow Running"
v = get_vehicle()

while True:
    if mustarm:
        wait_for_arm(v)    
    
    video_in = open_camera()
    homedir = os.path.expanduser("~")
    logger = Logger(path= homedir + "/Videos/")
    
    process_stream(video_in, logger, vehicle=v, require_arming=mustarm)
コード例 #3
0
import argparse
import cv2


from polyphemus import process_stream
from file_utils import Logger


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Track a red blob and adjust camera gimbal to follow")
    parser.add_argument('-r', '--record', action="store_true", default=False, help='record the output of the program to ../vids/demo_X.avi')
    parser.add_argument('-i', '--input', action="store", help='use a video filename as an input instead of a webcam')
    args = parser.parse_args()
    
    video_in = cv2.VideoCapture()
    
    if args.input != None:
        video_in.open(args.input)
    else:
        video_in.open(0)
    
    if args.record:
        logger = Logger()
    else:
        logger = None  
    try:
        process_stream(video_in, logger)
    except KeyboardInterrupt:
        print "KeyboardInterrupt detected."