C++ 提取图像ROI保存到Mat
来源:互联网 发布:zeppelin软件下载 编辑:程序博客网 时间:2024/04/28 08:04
只要给定待提取ROI的四个角点坐标,利用OpenCV的透视变换计算出变换矩阵,就可以实现提取并保存到Mat;
void ls::getROI(cv::Mat &src, float vertices[8],cv::Mat &dst) { float w2 = sqrt(pow(vertices[0] - vertices[2], 2) + pow(vertices[1] - vertices[3] ,2 )); float h2 = sqrt(pow(vertices[0] - vertices[4], 2) + pow(vertices[1] - vertices[5] ,2)); dst = cv::Mat::zeros(h2, w2, CV_8UC3); //__android_log_print(ANDROID_LOG_INFO, "SRC", "error%d", src.rows); // corners of destination image with the sequence [tl, tr, bl, br] vector<Point2f> dst_pts, img_pts; dst_pts.push_back(cv::Point(0, 0)); dst_pts.push_back(cv::Point(w2 - 1, 0)); dst_pts.push_back(cv::Point(0, h2 - 1)); dst_pts.push_back(cv::Point(w2 - 1, h2 - 1)); // corners of source image with the sequence [tl, tr, bl, br] img_pts.push_back(cv::Point(vertices[0], vertices[1])); img_pts.push_back(cv::Point(vertices[2],vertices[3])); img_pts.push_back(cv::Point(vertices[4],vertices[5])); img_pts.push_back(cv::Point(vertices[6], vertices[7])); // convert to original image scale // for (size_t i = 0; i < img_pts.size(); i++) { // img_pts[i].x *= scale; // img_pts[i].y *= scale; // } // get transformation matrix cv::Mat M_trans = getPerspectiveTransform(img_pts, dst_pts); // apply perspective transformation warpPerspective(src, dst, M_trans, dst.size()); }
1 0
- C++ 提取图像ROI保存到Mat
- opencv中对Mat类型图像感兴趣(ROI)轮廓外接矩形并截取保存结果
- ROI提取图像中部分区域
- Mat 版opencv保存图像
- OpenCV中Mat类的图像如何设置ROI
- openCV中Mat类的图像如何设置ROI
- OpenCV中Mat类的图像如何设置ROI
- OpenCV中Mat类的图像如何设置ROI
- OpenCV中Mat类的图像如何设置ROI
- 【Opencv学习(三)】获取Mat图像的ROI区域
- matlab cell保存mat 以及提取
- opencv2读取视频提取ROI区域并把ROI区域保存为图片
- 图像 ROI
- OpenCV截取图像ROI并保存于指定路径
- OpenCV截取图像ROI并保存于指定路径
- 保存图像到相册
- OpenCV 中Mat对象的获取ROI区域自图像的问题
- opencv提取ROI区域
- java读取sql脚本文件并写入数据库
- ThinkPHP导入excel表获取数据
- SQLite在多线程环境下的应用
- iOS开发网络篇—数据缓存
- hdu 4533(树状数组区间更新+单点查询)
- C++ 提取图像ROI保存到Mat
- 深度理解原型链
- 打印documents 本地文件
- android保留两位小数的方法
- C++ 智能指针详解
- android网络框架
- 如何查看linux系统CPU利用率
- 使用mybatis-spring,必须使用spring3.0 以上
- Maven