我在OpenCV python中编写一个项目。它基本上是一个交通监控的最后一年项目..现在我已编码到目前为止,它运行时识别视频中的车辆,并在这些车辆上绘制矩形和质心。现在我想要做的是绘制运动矢量或仅跟踪上面找到的轮廓,即车辆。在opencv光流功能中,我无法确定这种情况下的参数。任何人都可以帮助我吗?谢谢..这是代码的轮廓查找部分..
image, contours, hierarchy = cv2.findContours(fgmask.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_NONE)
try: hierarchy = hierarchy[0]
except: hierarchy = []
#Drawing Rectangles arround contours (Vehicles)
for contour, hier in zip(contours, hierarchy):
(x,y,w,h) = cv2.boundingRect(contour)
if w > 8 and h > 8:
cv2.rectangle(frame, (x,y), (x+w,y+h), (255, 0, 0), 2)
答案 0 :(得分:0)
我不认为你可以使用OpticalFlow来做到这一点。我会想你看看KalmanFilter
。通过它,您可以跟踪,平滑和预测历史中的运动矢量。
答案 1 :(得分:0)