在轮廓和垫子上应用同件
Apply homography on contours as well as Mat
当前我正在使用以下序列
vector<vector<Point>> contours
1. findContours(srcMat, contours, ...)
2. convert contours to Point2f
3. findHomography(src, dst, RANSAC)
4. warpPerspective(srcMat, destMat, homo)
5. findContours
我想避免步骤#4,同时还要转换垫子,因为我使用转换垫的轮廓使用一些ROI。
运行warpperspective的答案,但在轮廓上使用CV :: Perspectivetransform与Translation Matrix使用。限制是它一次只能转换一个轮廓。下面的样本。
vector<vector<Point2f>> contours; // from findContours
Mat trnsmat = getPerspectiveTransform(srcPoints, destPoints);
for (int i=0; i< contours.size(); i++)
cv::perspectiveTransform(contours[i], contours[i], trnsmat);
我认为您的目标是在不使用整个图像的情况下将轮廓坐标投影到变换的空间中?
将轮廓坐标加载到roimat结构中,并将其乘以使用您的FindHomography函数计算的同构矩阵。无需将整个原始图像扭曲。
如果要查看图像上转换的ROI,则可能从原始图像中选择一些兴趣点(参考(并将其添加到Roimat结构中。
在python中,您可以将每个轮廓与以下代码隔离,然后在每个轮廓上执行任何处理。
contours, hierarchy = cv2.findContours(image, cv2.RETR_CCOMP, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
x, y, w, h = cv2.boundingRect(cnt)
contor_img = image[y:y+h, x:x+w]
现在您可以单独处理每个轮廓(contor_img(
相关文章:
- 试图在visual studio上用C++创建一个桌面应用程序
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- c++r值引用应用于函数指针
- 在C应用程序中运行C++(带有STL)函数
- 使用VerQueryValue检索应用程序的文件描述
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用调试/崩溃报告将应用程序部署到客户端
- C++控制台应用程序阻止退出
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 将应用程序从32位移植到64位时出现问题
- 有没有任务栏API可以立即应用注册表更改
- 如何改变c++应用程序的视觉效果
- WM_CTLCOLORSTATIC从未在WIN32应用程序中触发
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 示例外壳应用程序显示的 V8 "segmentation fault (core dumped)"错误
- phytec phyBOARD iMX-6在从闪存而不是SD卡运行qt5 opengles应用程序时表现不佳(FPS减半
- TMap::Emplace() 在应用现有密钥时会覆盖吗?
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 在轮廓和垫子上应用同件