Project 8
Magna :
import cv2
# OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
import numpy as np # np is an alias for numpy
# general-purpose array-processing package.
# It provides a high-performance multidimensional array object,
# and tools for working with these arrays
#tracking features, Identifying corners through
#shi-tomasi corner detector method
def find_features(gray_image):
# Extracting the features from the gray scaled image using cv2.goodFeaturesToTrack method
# No masking
# Here Maximum Corners detection is 100
# Quality Level is 0.1
# Minimum distance between two features is 10 to avoid features that are closely spaced
# Window size is 5
points=cv2.goodFeaturesToTrack(gray_image,mask=None,maxCorners=100,qualityLevel=0.1,minDistance=10,blockSize=5)
return points
# Lucas Kanade sparse optical flow model
def LK_model(gray_t_1,gray_t,prev_points):
# Window size = (10,10)
# Max level means Level of the Pyramid
# Criteria is for setup to perform the operation
points,status,error = cv2.calcOpticalFlowPyrLK(gray_t_1,gray_t,prev_points,None,winSize=(10,10),maxLevel=2,criteria=(cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, 10, 0.03))
return (points,status,error)