How the use the HistogramBasedTracker without it exploding
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Dima Lisin
2014-5-9
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 个评论
John D'Errico
2014-5-9
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!