主要函数:
findContours
drawContours
findContours(resultingCVMat, layerContours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE);
Mat imageContours=Mat::zeros(resultingCVMat.size(),CV_8UC1);
for (int n = 0;n < layerContours.size();n++)
{qDebug()<<"层面总轮廓数量 layerContours.size() "<<layerContours.size()<<" 当前轮廓 "<<n;drawContours(imageContours,layerContours,n,Scalar(255),5);Rect boundRect = boundingRect(layerContours[n]);rectangle(imageContours,boundRect,Scalar(255),5);
}
imwrite(QString("previewPic\\%1rect.bmp").arg(layerNum).toStdString(),imageContours);