1

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 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.