Ask Your Question
0

goodfeaturestoTrack with Mask

asked 2015-04-11 18:38:31 -0500

215 gravatar image

How do i use the mask parameter for the GoodFeatureToTrack function?..

right now i give it this

goodFeaturesToTrack(grayframe, points, 500, 0.01, 10, Mat(frame,faces.back()), 3, 0, 0.04);

Which give me this error which i seem to be stuck with.

OpenCV Error: Assertion failed (mask.empty() || (mask.type() == CV_8UC1 && mask.size() == image.size())) in goodFeaturesToTrack...
edit retag flag offensive close merge delete

Comments

what is Mat(frame,faces.back()) ? looks like some kind of ROI. ?

try this:

Mat mask(frame.size(),CV_8U,Scalar(0));
mask(faces.back()).setTo(Scalar(255));
goodFeaturesToTrack(grayframe, points, 500, 0.01, 10, mask, 3, 0, 0.04);
berak gravatar imageberak ( 2015-04-12 03:01:57 -0500 )edit

I tried what you suggested, but it gives out a error message saying.

OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/opencv-2.4.10/modules/core/src/matrix.cpp, line 323
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /opt/local/var/macports/build/_opt_mports_dports_graphics_opencv/opencv/work/opencv-2.4.10/modules/core/src/matrix.cpp:323: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat

Frame is a Mat, and faces.back() is a rect from a vector.

215 gravatar image215 ( 2015-04-12 08:34:27 -0500 )edit

sorry, probably grayframe, not frame

berak gravatar imageberak ( 2015-04-12 08:55:09 -0500 )edit

The size of both frame is the same. Grayframe is just a copy of frame, converted to grayscale.

215 gravatar image215 ( 2015-04-12 09:14:07 -0500 )edit
1

please check if faces actually contains something before.

berak gravatar imageberak ( 2015-04-12 10:27:33 -0500 )edit

ok.. I tried put something together but it seem not to work as expected.. For some reason it will not apply the Lukas kanade using the points.. I am bit confused on why this problem is occurring at all... http://pastebin.com/CtrTfFeA

215 gravatar image215 ( 2015-04-12 14:59:53 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-04-12 02:50:05 -0500

This assertion is rather self-explanatory: If you pass a mask, it has to be of type CV_8UC1 and has to have the same size as your input image.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-04-11 18:38:31 -0500

Seen: 4,055 times

Last updated: Apr 12 '15