I am trying to use the method calcOpticalFlowPyrLK. The arguments are as follows:
cv2.calcOpticalFlowPyrLK(prevImg, nextImg, prevPts[, nextPts[, status[, err[, winSize[, maxLevel[, criteria[, flags[, minEigThreshold]]]]]]]])
Where the parameter prevPts is – vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
What I have is:
[x,y,w,h] = cv2.boundingRect(cont)
where cont is a countour detected in the image.
How do I manipulate [x,y,w,h] so I can input it as prevPts , i.e. make it a vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
The vector turned out to be nothing but the x,y coordinates. So I created a numpy array of these points with shape Nx2, where N denotes number of points to be tracked and each row contains x,y coordinates.