赞
踩
小白学视觉,笔记,扩展
//最大外接矩形
Rect rect = boundingRect(contours[n]);
// 最小外接矩形
RotatedRect rrect = minAreaRect(contours[n]);
#include <opencv2/opencv.hpp> #include <iostream> #include <vector> using namespace cv; using namespace std; int main() { Mat img = imread("stuff.jpg"); if (img.empty()) { cout << "请确认图像文件名称是否正确" << endl; return -1; } Mat img1, img2; img.copyTo(img1); //深拷贝用来绘制最大外接矩形 img.copyTo(img2); //深拷贝用来绘制最小外接
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。