How the use the HistogramBasedTracker without it exploding

1 view (last 30 days)
I'm trying to adapt the code from http://www.mathworks.co.uk/help/vision/examples/face-detection-and-tracking-using-camshift.html to track some heads from a profile view. Simple.
When I try to initialize the (vision.HistogramBasedTracker) object using initializeObject(), I'm to pass an initial detection in the form of a bounding box as the third arg. No problem. EXCEPT that in the tracker object there are some validateattributes() calls to ensure that the pixel locations I pass as the bounding box parameters are integers. So I convert them to integers using int32 (I've also tried int16 and int64, in case it matters).
Except then I get an error:
"Error using max Mixed inputs must either be single and double, or integer and scalar double. All other combinations are no longer allowed."
at this line of code (vision.HistogramBasedTracker, 350): upperLeft = max(upperLeft, [1, 1]);
Now I know exactly what's going on - the comparison of the int32 vector with the double vector is not allowed anymore. But then how in God's name am I to satisfy the requirements that this argument be integer-valued BUT I can't compare it with a vector of doubles? This isn't some external toolbox, this is built-in code, FCS.

Answers (1)

Dima Lisin
Dima Lisin on 9 May 2014
Hi Sanj,
What is happening here is that the bounding box is expected to be represented by integer values. In other words, it is ok for the data type to be double, but the values must be integers. You should be able to fix this problem by using round() instead of converting the bounding box to int32.
  1 Comment
John D'Errico
John D'Errico on 9 May 2014
And the point is, there is a difference between integer valued and a value that is stored as explicitly an integer type. You need only the first here, so round is the answer.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!