目标跟踪是计算机视觉中的一个重要研究方向,有着广泛的应用,如:视频监控,无人驾驶等。
本文介绍的目标跟踪方法,即通过Opencv-Python中的图像处理方法,实现对摄像头视频中移动目标的简单定位,并进行后续处理。
1. 运动目标跟踪
实现当摄像头中物体移动时,绘制对应的区域的边界框,并进行跟踪检测。import cv2
import numpy as np
getStructuringElement
camera = cv2.VideoCapture(0)
'''
cv2.getStructuringElement(shape, ksize[, anchor]) → retval
Returns a structuring element of the specified size and shape for morphological operations.
Parameters:
shape – Element shape that could be one of the following:
(1) MORPH_RECT - a rectangular structuring element:
(2)MORPH_ELLIPSE - an elliptic structuring element, that is, a filled ellipse inscribed into the rectangle Rect(0, 0, esize.width, 0.esize.height)
(3) MORPH_CROSS - a cross-shaped structuring element
(4)CV_SHAPE_CUSTOM - custom structuring element (OpenCV 1.x API)
ksize – Size of