测量函数版本1
没有加入基准测量的版本
//输出测量结果
void MainWindow::on_ButtonOutPutRes_clicked()
{
//采用读取照片的处理方式
CurImgMat=imread("test.bmp",IMREAD_GRAYSCALE);//读取照片
//如果不采用照片读取的话这里直接对CurImgMat进行处理即可
medianBlur(CurImgMat, CurImgMat, 7);
vector<Point2f> CenterPts=StegerLineFloat(CurImgMat);//提取中心点
int TotalPoints=CenterPts.size();
vector<double>CenterX(TotalPoints);//保存X坐标
vector<double>CenterY(TotalPoints);//保存Y坐标
vector<double>MeasureResult(TotalPoints);//深度信息
QVector<double> FigX(TotalPoints),FigY(TotalPoints);
//赋值并求测量结果
for(int i=0;i<TotalPoints;i++){
CenterX[i]=CenterPts[i].x;
CenterY[i]=CenterPts[i].y;//赋值
MeasureResult[i]=CalculateRes(pmat,CenterY[i],CenterX[i]);//将X,Y坐标带入pmat得到测量结果
FigX[i]=CenterX[i];
FigY[i]=MeasureResult[i];
}
vector<int> Boundary=SlopeIntersect(CenterX,CenterY,50);//提取焊缝边界
ui->QplotRes->addGraph();
ui->QplotRes->graph(0)->setPen(QPen(Qt::blue));
ui->QplotRes->graph(0)->setData(FigX,FigY);
ui->QplotRes->xAxis->setLabel("水平坐标(pixel)");
ui->QplotRes->yAxis->setLabel("测量结果(mm)");
ui->QplotRes->rescaleAxes(true);//如果不用这个语句,可能无法看到画图的结果
//区域分割
//绘制第二个散点图
QVector<double> BoundX,BoundY;
BoundX<<CenterX[Boundary[0]]<<CenterX[Boundary[1]];
BoundY<<1<<1;
ui->QplotRes->addGraph();
ui->QplotRes->graph(1)->setPen(QPen(Qt::red));
//ui->QplotRes->graph(1)->setLineStyle(QCPGraph::lsNone);
ui->QplotRes->graph(1)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2));
ui->QplotRes->graph(1)->setData(BoundX,BoundY);
ui->QplotRes->replot();
}