记录应用 ——已调通
int main( int argc, char** argv )
{
vector<Mat> test;
readImgs(".\\", 1, test);
unsigned char* imgtest=NULL,*outimg=NULL;
imgtest = test[0].data;
//Mat img/*(test[0].rows, test[0].cols, CV_8UC1)*/; //img = test[0];这样是使用同一段空间
//img = test[0].clone();//这样不使用同一段空间,拷贝一段相同数据
Mat img(2048, 2592, CV_8UC1, imgtest);
Mat imgTempforContour = img.clone();
Mat imgTempforCanny = img.clone();
vector<vector<Point>> contours;
vector<Vec4i> hierarchy;
threshold(imgTempforContour, imgTempforContour, 100, 255, CV_THRESH_BINARY);
findContours(imgTempforContour, contours, hierarchy, RETR_EXTERNAL, CHAIN_APPROX_NONE);//获得最小外接矩形,且需经过二值化,该矩形横平竖直
vector<Rect> boundRect(contours.size()); //定义外接矩形集合
Scalar a(100);//灰度图只有第一个值有效
for(int i=0; i<contours.size(); i++)
{
boundRect