资源简介
光流法python代码实现
代码片段和文件信息
import numpy as np
import cv2
cap = cv2.VideoCapture(‘slow.flv‘)
# params for ShiTomasi corner detection
feature_params = dict( maxCorners = 100
qualityLevel = 0.3
minDistance = 7
blockSize = 7 )
# Parameters for lucas kanade optical flow
lk_params = dict( winSize = (1515)
maxLevel = 2
criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT 10 0.03))
# Create some random colors
color = np.random.randint(0255(1003))
# Take first frame and find corners in it
ret old_frame = cap.read()
old_gray = cv2.cvtColor(old_frame cv2.COLOR_BGR2GRAY)
p0 = cv2.goodFeaturesToTrack(old_gray mask = None **feature_params)
# Create a mask image for drawing purposes
mask = np.zeros_like(old_frame)
while(1):
评论
共有 条评论