for int version use cv::boundingRect(points);
| 8 | |
| 9 | // for int version use cv::boundingRect(points); |
| 10 | Rect2f boundingRect(const std::vector<Point2f>& points) |
| 11 | { |
| 12 | assert(points.size() >= 3); |
| 13 | #if 1 |
| 14 | const Point2f& p0 = points[0]; |
| 15 | float left = p0.x, right = p0.x, top = p0.y, bottom = p0.y; |
| 16 | for(const Point2f& point: points) |
| 17 | { |
| 18 | if(point.x < left) |
| 19 | left = point.x; |
| 20 | else if(point.x > right) |
| 21 | right = point.x; |
| 22 | |
| 23 | if(point.y < top) |
| 24 | top = point.y; |
| 25 | else if(point.y > bottom) |
| 26 | bottom = point.y; |
| 27 | } |
| 28 | |
| 29 | #else |
| 30 | assert(points.size() == 81); // from 0 to 80 |
| 31 | float left = std::min(points[0].x, points[1].x); |
| 32 | float right = std::max(points[11].x, points[12].x); |
| 33 | float top = points[16].y + 1; |
| 34 | float bottom = points[6].y + 1; |
| 35 | |
| 36 | # ifndef NDEBUG |
| 37 | for(const Point2f& point: points) |
| 38 | { |
| 39 | assert(left <= point.x && point.x < right); |
| 40 | assert(top <= point.y && point.y < bottom); |
| 41 | } |
| 42 | # endif // NDEBUG |
| 43 | #endif |
| 44 | |
| 45 | return Rect2f(left, top, right - left, bottom - top); |
| 46 | } |
| 47 | |
| 48 | float distance(const cv::Point2f& pt0, const cv::Point2f& pt1) |
| 49 | { |
no outgoing calls
no test coverage detected