| 19 | // ASM search, but also ensuring that the rect is in the image boundaries. |
| 20 | |
| 21 | static Rect RoiRect( |
| 22 | const DetectorParameter& detpar, // in |
| 23 | int nimgcols, // in |
| 24 | int nimgrows, // in |
| 25 | bool flip, // in: mirror the ROI |
| 26 | double botfrac, // in: distance from center to bottom marg |
| 27 | double leftfrac, // in: dist from center to left marg |
| 28 | double topfrac, // in |
| 29 | double rightfrac) // in |
| 30 | { |
| 31 | int ixmin, ixmax; |
| 32 | if (flip) |
| 33 | { |
| 34 | ixmin = MAX(0, cvRound(detpar.x - rightfrac * detpar.width)); |
| 35 | ixmax = MIN(nimgcols, cvRound(detpar.x + leftfrac * detpar.width)); |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | ixmin = MAX(0, cvRound(detpar.x - leftfrac * detpar.width)); |
| 40 | ixmax = MIN(nimgcols, cvRound(detpar.x + rightfrac * detpar.width)); |
| 41 | } |
| 42 | const int iymin = MAX(0, cvRound(detpar.y - botfrac * detpar.height)); |
| 43 | const int iymax = MIN(nimgrows, cvRound(detpar.y + topfrac * detpar.height)); |
| 44 | |
| 45 | Rect roi; |
| 46 | |
| 47 | roi.x = ixmin; |
| 48 | roi.y = iymin; |
| 49 | roi.width = ixmax - ixmin; |
| 50 | roi.height = iymax - iymin; |
| 51 | |
| 52 | CV_Assert(roi.width > 0); |
| 53 | CV_Assert(roi.height > 0); |
| 54 | |
| 55 | return roi; |
| 56 | } |
| 57 | |
| 58 | static bool IsRoiEntireImg( |
| 59 | const Rect& roi, // in |
no outgoing calls
no test coverage detected