It looks like a bug to me, but don't want to file it as a bug in case I read the code wrong, so asking question here.
In Detector.detectAtScale method, it says "if there is no hint of detection, then increase the step size".
But if I read the code correctly, if it detectes something then "result > 0". And "xstep = result == 0 ? smallStep : bigStep;" would get "bigStep" when something was detected.
Per OpenCV code, it has small step if something is detected, and big step if nothing is detected. Same logic as stated in the comment, but the code here seems to do otherwise.
Thanks,
Anthony
protected void detectAtScale(final SummedSqTiltAreaTable sat, final int startX, final int stopX, final int startY,
final int stopY, final float ystep, final int windowWidth, final int windowHeight,
final List<Rectangle> results)
{
for (int iy = startY; iy < stopY; iy++) {
final int y = Math.round(iy * ystep);
for (int ix = startX, xstep = 0; ix < stopX; ix += xstep) {
final int x = Math.round(ix * ystep);
final int result = cascade.classify(sat, x, y);
if (result > 0) {
results.add(new Rectangle(x, y, windowWidth, windowHeight));
}
// if there is no hint of detection, then increase the step size
xstep = result == 0 ? smallStep : bigStep;
}
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think you're right. I've just changed it to xstep = (result > 0 ? smallStep : bigStep) to better match the comment and the behaviour of OpenCV.
It might be better to do something a little more clever if the result is negative and large (i.e. if more than a certain proportion of the total number stages have passed, you should also use smallStep because it's likely that you're going to make a detection soon). This warrants further investigation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It looks like a bug to me, but don't want to file it as a bug in case I read the code wrong, so asking question here.
In Detector.detectAtScale method, it says "if there is no hint of detection, then increase the step size".
But if I read the code correctly, if it detectes something then "result > 0". And "xstep = result == 0 ? smallStep : bigStep;" would get "bigStep" when something was detected.
Per OpenCV code, it has small step if something is detected, and big step if nothing is detected. Same logic as stated in the comment, but the code here seems to do otherwise.
Thanks,
Anthony
I think you're right. I've just changed it to
xstep = (result > 0 ? smallStep : bigStep)
to better match the comment and the behaviour of OpenCV.It might be better to do something a little more clever if the result is negative and large (i.e. if more than a certain proportion of the total number stages have passed, you should also use smallStep because it's likely that you're going to make a detection soon). This warrants further investigation.