[原创]移动相机九点标定工具原理及实现(包涵部分源码)

博客 动态
0 127
优雅殿下
优雅殿下 2022-07-22 17:02:07
悬赏:0 积分 收藏

[原创]移动相机九点标定工具原理及实现(包涵部分源码)

1. 移动相机标定与固定相机的标定有什么差异?

  • 书接上文 [原创]一种自动化九点标定工具原理(包涵部分源码)
  • 移动相机(眼在手上):相机安装在龙门架的Z轴上
  • 相机拍照得出来来的位置与当前龙门架实际点位有关系,有什么关系呢?答案:平移关系,只比固定相机多了一个平移关系
  • 怎么理解呢?假如以相机中心点作为坐标系T1原点,坐标系T1和龙门架坐标系G1只有平移关系。 而坐标系T1内的图像坐标系C1与龙门架坐标系G1存在一个固定的仿射变换矩阵

2. 解决办法?

  • 假如龙门架在G1点位,在此点位使用相机拍到一个mark点的图像坐标为P1;放射变换矩阵为M1,而此mark点对应的真实龙门架坐标为R1
  • 四者之间的关系为R1=P1*M1+G1
  • 通过上一篇文章描述方法,同样利用旋转方式获取P1,只是操作方式稍微不同。

3. 详细操作步骤?

  • 龙门架先吸取标定板到R1位置,放下标定板
  • 龙门架到达G1位置,拍照获取到mark点位置P1.1
  • 龙门架再次到R1位置,吸取标定板,旋转180度后放下标定板
  • 龙门架再次到达G1位置,拍照获取到mark点位置P1.2
  • P1的图像坐标为P1.1和P1.2的中心点
  • 到此,公式R1=P1*M1+G1的参数已经拿到R1,P1,G1。按照上述方式操作9次就可以计算出仿射变换矩阵M1了

4. 适用范围

  • 此标定方式只适合类似于龙门架的头部相机标定,不适合机械手设备的头部相机标定
  • 机械手头部相机的标定除了平移关系外,还有旋转关系。具体标定方式见下回分解

5. 源码

image.png

        private void updatePoiMatrix(Position pcbPoi,Position poi1, Position poi2,Position takePhotoPoi)        {            //更新对应的数组            imagePoiList.Add(new Position() { X = (poi1.X + poi2.X) / 2, Y = (poi1.Y + poi2.Y) / 2 });            System.Windows.Point p1=new System.Windows.Point();            p1.X = pcbPoi.X - takePhotoPoi.X;            p1.Y = pcbPoi.Y - takePhotoPoi.Y;            Position newDstPoi = new Position();            newDstPoi.X = p1.X;            newDstPoi.Y = p1.Y;            robotPoiList.Add(newDstPoi);        }        private void btnSaveCalibration_Click(object sender, EventArgs e)        {            try            {                NcHelper.GetInstance().SaveMat(imagePoiList, robotPoiList, this.matPath);            }            catch (Exception ex)            {                this.printException(ex);            }        }                public void SaveMat(List<Position> imageList, List<Position> robotPoiList, string path)        {            HTuple imageXList = new HTuple(), imageYList = new HTuple();            HTuple robotXList = new HTuple(), robotYList = new HTuple();            for (int i = 0; i < imageList.Count; i++)            {                imageXList[i] = imageList[i].X;                imageYList[i] = imageList[i].Y;                robotXList[i] = robotPoiList[i].X;                robotYList[i] = robotPoiList[i].Y;            }            HTuple hv_HomMat2D = new HTuple(), hv_SerializedItemHandle = new HTuple();            HTuple hv_FileHandle = new HTuple();            ////标定            hv_HomMat2D.Dispose();            HOperatorSet.VectorToHomMat2d(imageXList, imageYList, robotXList, robotYList, out hv_HomMat2D);            //保存变换矩阵            hv_SerializedItemHandle.Dispose();            HOperatorSet.SerializeHomMat2d(hv_HomMat2D, out hv_SerializedItemHandle);            hv_FileHandle.Dispose();            HOperatorSet.OpenFile(path, "output_binary", out hv_FileHandle);            HOperatorSet.FwriteSerializedItem(hv_FileHandle, hv_SerializedItemHandle);            HOperatorSet.CloseFile(hv_FileHandle);            imageXList.Dispose();            imageYList.Dispose();            robotXList.Dispose();            robotYList.Dispose();            hv_HomMat2D.Dispose();            hv_SerializedItemHandle.Dispose();            hv_FileHandle.Dispose();        }

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

  • 机械手头部相机标定工具
  • 下相机定位算法
  • 基于头部相机的载具定位算法
  • 基于顶部相机的塑盘取料算法
  • 基于头部相机的检测算法实现
  • 一种面向接口接口、依赖注入的运控框架的总体介绍及分层实现
posted @ 2022-07-22 16:24 Bonker 阅读(26) 评论(0) 编辑 收藏 举报
回帖
    优雅殿下

    优雅殿下 (王者 段位)

    2018 积分 (2)粉丝 (47)源码

    小小码农,大大世界

     

    温馨提示

    亦奇源码

    最新会员