QQ登录

只需一步,快速开始

工业视觉HALCON手眼标定之9点标定

[ 复制链接 ]
相机标定之后,其结果可以进行保存供正交直接使用。
标定相关算子分类于Calibration下,参数相关在子分类栏目下。
我们这演示标定后,其结果如何使用

手眼标定 其实就是对机械手和相机的位置关系进行计算,依据计算所得的结果,
就可以将图像处理后的像素位置转换为机械手的坐标,进而让机械手执行动作。
举个例子 例如人眼睛看到一个东西的时候要让手去抓取,就需要大脑知道眼睛和手的坐标关系。
如果把大脑比作B,把眼睛比作A,把手比作C, 如果A和B的关系知道,B和C的关系知道,
那么C和A的关系就间接也知道了,也就是手和眼的坐标关系也就知道了。
这种关系在halcon中用矩阵形式表示,可以保存与加载。
在halcon可以用9点标定方法,也可以用标定板标定方法。
机械手常见的有龙门架式三轴机构,串联机械手,并联机械手。
机械手和相机可相对固定或移动。

这小节讲解三轴的9点标定,下节介绍串联机械手的固定相机的标定。
9点标定的使用是很简单
涉及两个函数
vector_to_hom_mat2d(Pixel9X, Pixel9Y, AxisX, AxisY, HomMat2D)
affine_trans_point_2d(HomMat2D, Column,Row, Qx, Qy)
对应矩阵的操作也有两个
write_tuple(HomMat2D, 'cali.tup')
read_tuple('cali.tup', HomMat2D)

下面为标定代码,可以在自己HALCON上运行查看效果。
可以将代码事先保存到桌面,
再下载下边的图片放到桌面,运行代码。
测试图片
1.bmp
代码运行效果如下。
2019-11-08_105838.jpg
read_image (Image, '1.bmp')
dev_close_window()
dev_open_window_fit_image(Image, 0, 0, -1, -1, WindowHandle)
threshold(Image,Region, 150, 255)
connection(Region, ConnectedRegions)
select_shape_std(ConnectedRegions, SelectedRegions, 'max_area', 70)
fill_up(SelectedRegions, RegionFillUp)
rectangularity(RegionFillUp, Rectangularity)
reduce_domain(Image, RegionFillUp, ImageReduced)
threshold(ImageReduced, Region, 0, 100)
smallest_rectangle1(Region, Row1, Column1, Row2, Column2)
Yd := (Row2-Row1)/4
Pixel9X := []
Pixel9Y := []
gen_rectangle1(Rect, Row1-Yd, Column1, Row1+Yd, Column2)
dilation_rectangle1(Rect, RegionDilation, 11, 11)
reduce_domain(ImageReduced, RegionDilation, ImageReduced1)
threshold(ImageReduced1, Region1, 0, 100)
connection(Region1, ConnectedRegions1)
sort_region(ConnectedRegions1, SortedRegions, 'first_point', 'true', 'column')
area_center(SortedRegions, Area, PixelY, PixelX)
tuple_concat (Pixel9X, PixelX, Pixel9X)
tuple_concat (Pixel9Y, PixelY, Pixel9Y)

gen_rectangle1(Rect, Row1+Yd, Column1, Row1+3*Yd, Column2)
dilation_rectangle1(Rect, RegionDilation, 11, 11)
reduce_domain(ImageReduced,RegionDilation,ImageReduced1)
threshold(ImageReduced1, Region1, 0, 100)
connection(Region1, ConnectedRegions1)
sort_region(ConnectedRegions1, SortedRegions, 'first_point', 'true', 'column')
area_center(SortedRegions, Area, PixelY, PixelX)
tuple_concat (Pixel9X, PixelX, Pixel9X)
tuple_concat (Pixel9Y, PixelY, Pixel9Y)
gen_rectangle1(Rect, Row1+3*Yd, Column1, Row1+5*Yd, Column2)
dilation_rectangle1(Rect, RegionDilation, 11, 11)
reduce_domain(ImageReduced,RegionDilation,ImageReduced1)
threshold(ImageReduced1, Region1, 0, 100)
connection(Region1, ConnectedRegions1)
sort_region(ConnectedRegions1, SortedRegions, 'first_point', 'true', 'column')
area_center(SortedRegions, Area, PixelY, PixelX)
tuple_concat (Pixel9X, PixelX, Pixel9X)
tuple_concat (Pixel9Y, PixelY, Pixel9Y)

gen_cross_contour_xld(Cross, Pixel9Y, Pixel9X, 12, 0.785398)
dev_set_line_width (3)
dev_display(Image)
dev_set_draw('margin')
dev_display(RegionFillUp)
dev_display(Cross)
stop()
AxisX := [70,305,540,70,305,540,70,305,540]
AxisY := [-70,-70,-70,-185,-185,-185,-300,-300,-300]

vector_to_hom_mat2d(Pixel9X, Pixel9Y, AxisX, AxisY, HomMat2D)
write_tuple(HomMat2D, 'cali.tup')

*Caculate
HomMat2D:=[]
read_tuple('cali.tup', HomMat2D)
dev_display(Image)
dev_display(Region1)
area_center(Region, Area, Row, Column)
gen_cross_contour_xld(Cross, Row, Column, 6, 0.785398)

affine_trans_point_2d(HomMat2D, Column,Row, Qx, Qy)
文章也下面的HALCON视频教程部分内容,
可以下载教程观看与学习。
  

halcon从自学到接项目视频教程,另外再赠送全网最全资源  

  

欢迎围观我录制的一套halcon自学视频教程(进入)


  

上位机VC MFC程序开发精典实例大全源码与视频讲解配套下载408例

  

经历1年的编程与录制点击进入查看


  

如果您认可,可联系功能定制!

  

如果您着急,充值会员可直接联系发您资料!

  

QQ联系我

微信扫扫联系我

  



回复

使用道具 举报

点击查看
快速回复 返回列表 客服中心 搜索