0
votes

I am new to OpenCV and trying to impliment the basic optical flow example here: https://docs.opencv.org/3.3.1/d7/d8b/tutorial_py_lucas_kanade.html

I only want goodFeaturesToTrack() to analyze a small static circular part of my webcam input. The goodFeaturesToTrack function takes a mask argument, to which I am trying to pass in a 1-channel .png image of the same size as the input with cv2.imread('mask.png',0), but with no luck (it returns a mask.empty() error).

I feel like I am going about this in the wrong way, perhaps. Am I missing something obvious here? Or would it be easier for me to draw a circle within OpenCV itself?

1

1 Answers

3
votes

For future searchers, here is how I got it working:

maskimage = cv2.imread('your_mask_file.png',0) #1-channel image, white area to be active
mask = np.uint8(maskimage)

Then the mask can simply be passed in as a variable.