| 705 | } |
| 706 | |
| 707 | void ForceRectIntoImg( // force rectangle into image |
| 708 | int& ix, // io |
| 709 | int& iy, // io |
| 710 | int& ncols, // io |
| 711 | int& nrows, // io |
| 712 | const Image& img) // in |
| 713 | { |
| 714 | ix = Clamp(ix, 0, img.cols-1); |
| 715 | |
| 716 | int ix1 = ix + ncols; |
| 717 | if (ix1 > img.cols) |
| 718 | ix1 = img.cols; |
| 719 | |
| 720 | ncols = ix1 - ix; |
| 721 | |
| 722 | CV_Assert(ix >= 0 && ix < img.cols); |
| 723 | CV_Assert(ix + ncols >= 0 && ix + ncols <= img.cols); |
| 724 | |
| 725 | iy = Clamp(iy, 0, img.rows-1); |
| 726 | |
| 727 | int iy1 = iy + nrows; |
| 728 | if (iy1 > img.rows) |
| 729 | iy1 = img.rows; |
| 730 | |
| 731 | nrows = iy1 - iy; |
| 732 | |
| 733 | CV_Assert(iy >= 0 && iy < img.rows); |
| 734 | CV_Assert(iy + nrows >= 0 && iy + nrows <= img.rows); |
| 735 | } |
| 736 | |
| 737 | void ForceRectIntoImg( // force rectangle into image |
| 738 | Rect& rect, // io |