【发布时间】:2017-02-13 16:41:44
【问题描述】:
我想在使用以下代码旋转图像后获取 cv::rect (ROI) 的新位置:
cv::Point2f center(image.cols/2.0, image.rows/2.0);
cv::Rect ROI = cv::Rect(100,200,50,100);
cv::Mat rot = cv::getRotationMatrix2D(center, angle, 1.0);
cv::Rect bbox = cv::RotatedRect(center,image.size(), angle).boundingRect();
rot.at<double>(0,2) += bbox.width/2.0 - center.x;
rot.at<double>(1,2) += bbox.height/2.0 - center.y;
cv::warpAffine(image, image, rot, bbox.size(),cv::INTER_LINEAR,cv::BORDER_CONSTANT,
cv::Scalar(255, 255, 255));
我该怎么做?
【问题讨论】:
标签: c++ opencv image-processing