Files
opencv-MIRROR/modules/objdetect/test
Hardik K 3fef633bcc objdetect(hog): validate image size in compute() and guard windowsInImage() (#31168)
When HOGDescriptor::compute() is called without explicit locations on an image whose padded dimensions are smaller than winSize, HOGCache::windowsInImage() computes a negative window count along the undersized axis:

If one dimension is smaller than winSize (for example, 16 x 193 with default 64 x 128 winSize), windowsInImage().area() is negative and wraps to a huge size_t in nwindows, causing descriptors.resize(dsize * nwindows) to throw std::length_error (vector<T> too long).
If both dimensions are smaller than winSize, windowsInImage().area() becomes positive ((-w) * (-h)).
If a dimension is 1 to winStride - 1 pixels smaller than winSize, truncating integer division yields (size - winSize) / winStride + 1 == 1 instead of 0.
2026-12-02 17:58:49 +05:30
..
2021-05-25 11:28:23 +03:00