import numpy as np
import argparse
import time
import cv2
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video",
help = "path to the (optional) video file")
args = vars(ap.parse_args())
# define the upper and lower boundaries for a color
# to be considered "blue"
blueLower = np.array([100,67,0],dtype="uint8")
blueUpper = np.array([255,128,50],dtype="uint8")
# load the video
if not args.get("video"):
camera = cv2.VideoCapture(0)
else:
camera = cv2.VideoCapture(args["video"])
我们将使用NumPy进行数值处理,使用argparse解析命令行参数,使用cv2进行OpenCV绑定。time包是可选的。
我们只需要一个命令行参数,--video,也就是我们视频的路径。
我们将在视频中追踪的对象是蓝色物体。由于除了该物体外,蓝色在视频中的任何其他位置都不常见,因此我们希望跟踪蓝色阴影