测量函数部分记录

测量函数版本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();

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值