3
我想将我的投资回报率调整为一个比例因子。 我想这一点:如何调整投资回报率?
std::cout << roi.x << ", " << roi.y << std::endl;
std::cout << roi.x + roi.width << ", " << roi.y + roi.height << std::endl;
std::cout << img.size().width << ", " << img.size().height << std::endl << std::endl;
scale = 0.1; // 10%
cv::Rect new_size(
roi.x*(1-scale),
roi.y*(1-scale),
(roi.x + roi.width)*(1+scale),
(roi.y + roi.height)*(1+scale));
cv::Mat tmp = img(new_size);
它打印:
828, 142
892, 206
2048, 1150
281, 173
356, 248
2048, 1150
1025, 168
1100, 243
2048, 1150
和:
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /tmp/opencv-TqF1/opencv-2.4.7.1/modules/core/src/matrix.cpp, line 323
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-TqF1/opencv-2.4.7.1/modules/core/src/matrix.cpp:323: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat
嗯,我想我正在尝试设置重叠我的形象边界的ROI 。我的问题是:我必须手动执行此操作吗?如果是,如何进行缩放直至触及边界? OpenCV应该为此提供一种方法,对吗?我一直在寻找,我可以找到adjustROI,但我不知道如何使用它。
是什么类型的投资回报率? – Engine
这是一个cv :: Rect –
它应该是2d或2f点! – Engine