Problem: I have an image ROI (submat) that I want to examine with a HoG detector, though the ROI is smaller than the HoG winsize, which results in an error (see error below). The winsize is 64x128 and the ROI (after initial resizing) is 48x96.
Approach: I used .convert() in an attempt to to scale the image up to twice the size, though there was no apparent scaling that took place. (see code and output below)
Question: How do I scale an image ROI to be at least as large as the HoG winsize?
Error when ROI is smaller than the HoG winsize;
OpenCV Error: Assertion failed ((unsigned)pt.x <= (unsigned)(grad.cols - blockSize.width) && (unsigned)pt.y <= (unsigned)(grad.rows -blockSize.height)) in getBlock, file /home/will/opencv-2.4.9-7u71/modules/objdetect/src/hog.cpp, line 630 Exception in thread "Thread-0" java.lang.Exception: std::exception: /home/will/opencv-2.4.9-7u71/modules/objdetect/src/hog.cpp:630: error: (-215) (unsigned)pt.x <=(unsigned)(grad.cols - blockSize.width) && (unsigned)pt.y <= (unsigned)(grad.rows - blockSize.height) in function getBlock
Code segment;
// if resized window is not big enough for HoG window, scale it up
if (resizedWindow.size().height < hogDetector.getWinSize().height || resizedWindow.size().width < hogDetector.getWinSize().width){
logger.debug("resizedWindow size is too small, convert to 2 times the size");
frameToExamine.submat(resizedWindow).convertTo(ROImat, -1, 2.0);
} else {
ROImat= frameToExamine.submat(resizedWindow);
}
logger.debug("original ROI = {}", ROI);
logger.debug("resizedWindow = {} and ROImat {}", resizedWindow, ROImat.size());
return ROImat;
Output;
21:42:13.975 [Thread-0] DEBUG a.i.MatUtilities - resizedWindow size is too small, convert to 2 times the size 21:42:13.975 [Thread-0] DEBUG a.i.MatUtilities - original ROI = {254, 789, 93x44}
21:42:13.975 [Thread-0] DEBUG a.i.MatUtilities - resizedWindow = {253, 787, 96x48} and ROImat 96x48