| 1425 | } |
| 1426 | |
| 1427 | cv::Mat resize(const cv::Mat& image, const Point2f& pivot, |
| 1428 | float left_scale, float right_scale, float top_scale, float bottom_scale, |
| 1429 | int interpolation/* = INTER_LINEAR*/) |
| 1430 | { |
| 1431 | int pivot_x = cvRound(pivot.x), pivot_y = cvRound(pivot.y); |
| 1432 | LOGI("pivot: %d %d, image(%dx%d)", pivot_x, pivot_y, image.cols, image.rows); |
| 1433 | assert(0 <= pivot_x && pivot_x < image.cols); |
| 1434 | assert(0 <= pivot_y && pivot_y < image.rows); |
| 1435 | |
| 1436 | cv::Mat top, bottom; // seperate the whole image vertically |
| 1437 | image(Rect2i(0, 0, image.cols, pivot_y)).copyTo(top);LOGI("resize 1.0"); |
| 1438 | image(Rect2i(0, pivot_y, image.cols, image.rows - pivot_y)).copyTo(bottom);LOGI("resize 0111111"); |
| 1439 | |
| 1440 | const cv::Size EMPTY(0, 0); |
| 1441 | cv::resize(top, top, EMPTY, 1.0f, top_scale, interpolation); |
| 1442 | cv::resize(bottom, bottom, EMPTY, 1.0f, bottom_scale, interpolation); |
| 1443 | |
| 1444 | cv::Mat result; |
| 1445 | cv::vconcat(top, bottom, result); |
| 1446 | |
| 1447 | cv::Mat left, right; // seperate the whole image horizontally |
| 1448 | result(Rect2i(0, 0, pivot_x, result.rows)).copyTo(left); |
| 1449 | result(Rect2i(pivot_x, 0, result.cols - pivot_x, result.rows)).copyTo(right); |
| 1450 | |
| 1451 | cv::resize(left, left, EMPTY, left_scale, 1.0f, interpolation); |
| 1452 | cv::resize(right, right, EMPTY, right_scale, 1.0f, interpolation); |
| 1453 | |
| 1454 | cv::hconcat(left, right, result); |
| 1455 | return result; |
| 1456 | } |
| 1457 | |
| 1458 | Vec4f calcuateDistance(Point2f& pivot, const Point2f& left, const Point2f& right, const Point2f& top, const Point2f& bottom) |
| 1459 | { |