编程语言
首页 > 编程语言> > 下相机定位算法原理及实现

下相机定位算法原理及实现

作者:互联网

1.什么是下相机定位算法?

2、定位算法的原理和难点在哪?

3、解决方案

4、部分核心源码

  public Position GetCorrectionPoi(Position firstMarkPoi, Position firstTackPhotoPoi, Position currentTackPhotoPoi, Position dstPoi, out Position offset)
        {
            //拍照点相对于相机在移动,所以第一次的拍照点与第二次的拍照点得到的mark点坐标不在同一坐标系下
            //1、故需要把第二个点先根据当前拍照点旋转,然后根据firstTackPhotoPoi,currentTackPhotoPoi平移得到与第一个点同一坐标系点位
            //2、然后把第一个点旋转到与放置位平行
            Position dstPoiCopy = dstPoi.Copy();
            //获取当前的拍照的mark点对应的机械手坐标
            Position currentIRobotPoi = this.getRunCameraPoi(1);
            //旋转
            double angle1 = firstTackPhotoPoi.U - currentTackPhotoPoi.U;
            Position currentIRobotPoi1 = this.getRotatePoi(currentIRobotPoi, angle1, currentTackPhotoPoi);
            //平移
            Position currentIRobotPoi2 = this.getTransPoi(currentIRobotPoi1, currentTackPhotoPoi, firstTackPhotoPoi);
            //同理模版中的第二个点也需要做同样动作
            //获取模板的两个点位
            List<Position> templateRobotPoiList1 = this.getTemplateRobotPoiList();
            Position tempMark1Poi = templateRobotPoiList1[0];
            Position tempMark2Poi = templateRobotPoiList1[1];
            Position tempMark2Poi1 = this.getRotatePoi(tempMark2Poi, angle1, currentTackPhotoPoi);
            Position tempMark2Poi2 = this.getTransPoi(tempMark2Poi1, currentTackPhotoPoi, firstTackPhotoPoi);
            //创建新的点组合
            List<Position> currentIRobotPoiList = new List<Position>() { firstMarkPoi, currentIRobotPoi2 };
            List<Position> templateRobotPoiList = new List<Position>() { tempMark1Poi, tempMark2Poi2 };
            //获取旋转角度 
            double offsetAngle = this.getOffsetAngle(currentIRobotPoiList, templateRobotPoiList);
            //全部使用第一个点做平移计算
            //模板点旋转到与放置为平行
            double tempOffsetAngle = dstPoi.U - firstTackPhotoPoi.U;
            Position rotatedTempPoi = this.getRotatePoi(tempMark1Poi, tempOffsetAngle, firstTackPhotoPoi);
            //第一次拍照点旋转到与放置为平行
            Position rotatedCurrentPoi = this.getRotatePoi(firstMarkPoi, tempOffsetAngle - offsetAngle, firstTackPhotoPoi);
            //第一次拍照点与模板的平移
            Position tmpDstPoi = this.getTransPoi(firstTackPhotoPoi, rotatedCurrentPoi, rotatedTempPoi);
            //模板与放置位的平移 
            Position newDstPoi = this.getTransPoi(tmpDstPoi, firstTackPhotoPoi, dstPoi);
            //角度补偿
            newDstPoi.Z = dstPoi.Z;
            //防止旋转过大
            newDstPoi.U = (dstPoi.U - offsetAngle) % 360;
            //********************偏移计算*********************
            offset = this.getTransOffset(rotatedCurrentPoi, firstMarkPoi);
            offset.U = tempOffsetAngle;
            //模板2个Mark点与运行2个Mark点的距离偏差
            double templateDistance = HsNcCommon.VisionHelper.distancePP(templateRobotPoiList[0].X, templateRobotPoiList[0].Y, templateRobotPoiList[1].X, templateRobotPoiList[1].Y);
            double runDistance = HsNcCommon.VisionHelper.distancePP(currentIRobotPoiList[0].X, currentIRobotPoiList[0].Y, currentIRobotPoiList[1].X, currentIRobotPoiList[1].Y);
            offset.Z = runDistance - templateDistance;
            return newDstPoi;
        }

5. 后续计划[敬请期待],如需完整代码请微信联系

标签:P2,定位,拍照,firstTackPhotoPoi,相机,算法,放置,Position
来源: https://www.cnblogs.com/Bonker/p/16546782.html