Blob分析之board _components.hdev
*用立体方法分割板子组件的示例程序
*Application program to illustrate the segmentation
* of board _components.hdev with stereo methods
* 用有两个相机的立体装备
* We have a stereo setup of two cameras.
*两个相机都是经过30mm的标定板标定过的
* Both cameras will be calibrated by a couple of images
* of a 30mm calibration plate.
*以此来矫正和分割不同板子的图像
*The images of different boards will be rectified and the components segmented.
*这种方法只对有一定纹理的物体有效
* Note that this approach only works for sufficiently textured objects.
*如果只有很少的或者重复的纹理图像,对应的两个图像中点会匹配失败,测量结果也是错的
* If little or repetitive texture is present, the matching
* of corresponding points in both images will fail and
* therefore the measurement will be false.
*只有很少的或者重复的纹理图像的时候,可以加一个动态照明,给现场加一个随机的照明,生成一种纹理
* In such cases, it is a good practice to use active
* illumination, e.g., projecting a random light pattern
* onto the scene, to add texture information.
* 在有些应用场合中,有限的场景深度会成为一个问题,特别是场景特别小或者用远心镜头的时候
* In some applications, a limited depth of field can be
* a problem, especially when using a small field of view
* or telecentric lenses.
*在这种情况下,可以用倾斜镜头,充分利用Scheimpflug原理
* In such cases, please consider using tilt lenses
* to take advantage of the Scheimpflug principle.
*
* -------------------------------------------------------
* (1) STEREO CALIBRATION
* 关闭更新
dev_update_off ()
*设置图像路径
* Set the image path (make sure, that you have set HALCONIMAGES to the HALCON image directory)
ImgPath := 'stereo/board/'
*标定板描述文件
CalDescrFile := 'caltab_30mm.descr'
* Read the first images to get their size
*获取图像
read_image (ImageL, ImgPath + 'calib_l_01')
read_image (ImageR, ImgPath + 'calib_r_01')
* Reopen the windows with an appropriate size
*官拜窗口
dev_close_window ()
*获取图像大小
get_image_size (ImageL, WidthL, HeightL)
*打开固定尺寸的新窗体
dev_open_window (0, 0, WidthL, HeightL, 'black', WindowHandle1)
*设置显示填充形式,两种,margin表示边界,fill表示全部填充
dev_set_draw ('margin')
*设置显示颜色为绿色
dev_set_color ('green')
*设置显示字体
set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
*获取图像大小
get_image_size (ImageR, WidthR, HeightR)
*打开新窗体
dev_open_window (0, WidthL + 12, WidthL, HeightL, 'black', WindowHandle2)
*设置显示填充形式,两种,margin表示边界,fill表示全部填充
dev_set_draw ('margin')
*设置显示颜色为绿色
dev_set_color ('green')
*设置显示字体
set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
* Calibrate the stereo setup
* (determine the internal and external camera parameters).
*
* Set the initial values for the internal camera parameters
*生成面扫描相机初始参数
gen_cam_par_area_scan_division (0.0125, 0, 1.48e-5, 1.48e-5, WidthL / 2.0, HeightL / 2.0, WidthL, HeightL, StartCamPar)
*创建标定数据句柄
create_calib_data ('calibration_object', 2, 1, CalibDataID)
*设置标定相机出事参数
set_calib_data_cam_param (CalibDataID, 'all', [], StartCamPar)
*设置标定板文件
set_calib_data_calib_object (CalibDataID, 0, CalDescrFile)
*
* Read all used calibration images
*读取左右两幅图像
read_image (ImagesL, ImgPath + 'calib_l_' + [1:15]$'02d')
read_image (ImagesR, ImgPath + 'calib_r_' + [1:15]$'02d')
* Calibrate the setup
*矫正立体双目视觉
calibrate_stereo_setup (ImagesL, ImagesR, WindowHandle1, WindowHandle2, CalibDataID, StartCamPar, CalDescrFile, CamParamL, CamParamR, cLPcR, Errors)
* Generate the rectification maps
*生成双目矫正分布图
gen_binocular_rectification_map (MapL, MapR, CamParamL, CamParamR, cLPcR, 1, 'geometric', 'bilinear', RectCamParL, RectCamParR, CamPoseRectL, CamPoseRectR, RectLPosRectR)
*
* Check the calibration result
* by checking the epipolar constraint on the rectified images:
* The differences in row coordinates of all
* calibration point correspondences should be minimal
*检视矫正结果
map_image (ImagesL, MapL, ImagesRectL)
map_image (ImagesR, MapR, ImagesRectR)
*检测极线约束差异
check_epipolar_constraint (ImagesRectL, ImagesRectR, RectCamParL, RectCamParR, WindowHandle1, WindowHandle2, CalDescrFile, EpipolarError)
if (EpipolarError[1] > 0.3)
* The calibration of the stereo rig was not performed thoroughly
*右下角显示 'Press Run (F5) to continue' 这个信息
disp_continue_message (WindowHandle2, 'black', 'true')
stop ()
endif
*右下角显示 'Press Run (F5) to continue' 这个信息
disp_continue_message (WindowHandle2, 'black', 'true')
stop ()
*清除矫正数据
clear_calib_data (CalibDataID)
* --------------------------------------------------------
* (2) STEREO PROCESSING
*
* Parameters from above if calibration was not performed:
* gen_cam_par_area_scan_division (0.0131205, -665.85466, 1.4803422e-005, 1.48e-005, 155.90117, 126.703971, 320, 240, CamParamL)
* gen_cam_par_area_scan_division (0.0131712, -728.9579, 1.4799849e-005, 1.48e-005, 163.265701, 119.310684, 320, 240, CamParamR)
* cLPcR := [0.15350044,-0.003732778,0.04481715,0.1736607,319.8612,359.8945,0]
*定义双目视觉相对的差异参数和双目距离
* Define parameter values for binocular_disparity and binocular_distance, respectively.
*掩码宽
MaskWidth := 17
*掩码高
MaskHeight := 17
*纹理阈值
TextureThresh := 5
*最小差异
MinDisparity := 10
*最大差异
MaxDisparity := 40
*Level
NumLevels := 1
ScoreThresh := 0.1
* Get stereo image pair
**聚焦到窗体1
dev_set_window (WindowHandle1)
*读取图像
read_image (ImageL, ImgPath + 'board_l_01')
*增强对比度
emphasize (ImageL, ImageL, 7, 7, 1)
*映射图像
map_image (ImageL, MapL, ImageRectifiedL)
*显示图像
dev_display (ImageRectifiedL)
**聚焦到窗体2
dev_set_window (WindowHandle2)
*读取图像
read_image (ImageR, ImgPath + 'board_r_01')
*增强图像
emphasize (ImageR, ImageR, 7, 7, 1)
*映射图像
map_image (ImageR, MapR, ImageRectifiedR)
*显示图像
dev_display (ImageRectifiedR)
*显示信息
disp_message (WindowHandle1, 'Rectified left image', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle2, 'Rectified right image', 'window', 12, 12, 'black', 'true')
*右下角显示 'Press Run (F5) to continue' 这个信息
disp_continue_message (WindowHandle2, 'black', 'true')
stop ()
*当以图像距离
* Determine the distance image.
binocular_distance (ImageRectifiedL, ImageRectifiedR, DistanceImage, ScoreImageDistance, RectCamParL, RectCamParR, RectLPosRectR, 'ncc', MaskWidth, MaskHeight, TextureThresh, MinDisparity, MaxDisparity, NumLevels, ScoreThresh, 'left_right_check', 'interpolation')
* Display the distance image
dev_set_window (WindowHandle1)
dev_clear_window ()
dev_display (DistanceImage)
* Correct the distance image for the tilt of the stereo camera system.
* (Attention: the distance values are not measured
* in the rectified coordinate system anymore!)
* Define a region, which indicates three areas on the reference plane
*生成一组圆
gen_circle (Circle, [15,208,95], [58,32,211], [8,8,8])
*联合区域
union1 (Circle, RegionDefiningReferencePlane)
*倾斜修正
tilt_correction (DistanceImage, RegionDefiningReferencePlane, DistanceImageCorrected)
**聚焦到窗体2
dev_set_window (WindowHandle2)
*清除窗体
dev_clear_window ()
*显示纠正图像
dev_display (DistanceImageCorrected)
*显示信息
disp_message (WindowHandle1, 'Distance image', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle2, 'After tilt correction', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle2, 'black', 'true')
stop ()
MinHeight := -0.0005
MaxHeight := 0.05
* Transform the distances into heights above the reference plane.
*计算离参考平面的距离范围
height_range_above_reference_plane (DistanceImageCorrected, HeightAboveReferencePlaneReduced, MinHeight, MaxHeight)
*显示高度范围(本地函数)
visualize_height_ranges (ImageRectifiedL, HeightAboveReferencePlaneReduced, WindowHandle2, 0.0004, 0.0015, 0.0015, 0.0025, 0.0025, 0.004)
**聚焦到窗体1
dev_set_window (WindowHandle1)
*清除窗体
dev_clear_window ()
*显示数据
dev_display (HeightAboveReferencePlaneReduced)
*显示信息
disp_message (WindowHandle2, 'Segmented components', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle1, 'Height above reference plane', 'window', 12, 12, 'black', 'true')
Blob分析之board _components.hdev的更多相关文章
- Blob分析之board.hdev
* board.hdev: Detection of missing solder* 获取当前系统参数get_system ('clip_region', Information)*设置当前系统参数s ...
- 常用机器视觉工具----图像分析工具(blob分析)
http://blog.sina.com.cn/s/blog_67cc4eb70100ivnt.html Blob分析:Blob分析目的在于对图像中的2-D形状进行检测和分析,得到诸如目标位置.形状. ...
- opencv 在工业中的应用:blob分析
在工业中经常要检测一副图像中物体的数量,位置,大小,面积等信息,这就要用到BLOB分析,我用OPENCV做了个BLOB分析的DEMO. (1)打开一幅图像 (2)进行参数设置,设定二值化阙值,并选择是 ...
- Blob分析--粘连颗粒检测 基于距离变换的分水岭区域分割 盆地与原连通域求交集
文章转自微信公众号:机器视觉那些事 *******************************************************************公众号:机器视觉那些事儿*** ...
- Halcon 笔记2 Blob分析
1. 数组操作 2. 可视化-更新窗口 (1)单步模式-总是:则可以自动显示图像: (2)单步模式-从不:需要调用显示函数才能显示图像. (3)单步模式-清空显示:将原图清除,再显示新图 3. 图像处 ...
- Halcon blob分析基本处理步骤
Halcon,blob分析 应用场景,二值化后的灰度图像对比度清晰 基本处理流程 1 读取图片 read_image(变量名,'路径') //halcon字符串使用单引号'' 2 预处理 2.1 RO ...
- Blob分析之bottle.hdev
* 分割读取啤酒瓶子上的数字* bottle.hdev: Segment and read numbers on a beer bottle* 第0步* Step 0: Preparations*定义 ...
- Blob分析之ball_seq.hdev
* ball_seq.hdev: Inspection of Ball Bonding * 关闭更新dev_update_off ()*图像集合ImageNames := 'die/' + ['die ...
- Blob分析之 ball.hdev
* ball.hdev: Inspection of Ball Bonding * 关闭窗体更新 dev_update_window ('off')*关闭窗体dev_close_window ()*打 ...
随机推荐
- css中雪碧图(sprite)的使用及制作方法
雪碧图(sprite)是减少请求次数的有效手段,其原理是把多张图片进行合成,使用时通过css进行定位. 1.先看一下雪碧图 没有使用雪碧图时图标是这样一个个的单独文件: 合成雪碧图后是这样拼在一起的一 ...
- 底层剖析 Window 、Activity、 View 三者关系
不管工作几年的 Android 工程师,或多或少都听说过 Window 的概念,并且隐隐约约感觉它在 Activity 与 View 之间应该发挥着某种连接的作用.但是如果需要说出这 3 者之间的关系 ...
- JQ滚动加载
$(window).scroll(function () { if ($(document).scrollTop() + $(window).height() >= $(document).he ...
- 武汉中科通达软件Java工程师初试总结复盘
预约的视频面试时间是中午12点,不过面试官并没有准时到,拖了大概5.6分钟吧.Zoom会议上写着xxxJava工程师初试. 面试官戴着口罩,并没有露脸,看起来与我年龄相仿,感觉很年轻. 在我按着 ...
- Spring Bean的生命周期 ---附详细流程图及测试代码
一.生命周期流程图: Spring Bean的完整生命周期从创建Spring容器开始,直到最终Spring容器销毁Bean,这其中包含了一系列关键点 假设一个Bean实现了所有的接口,大的概况一下Be ...
- static关键字有何魔法?竟让Spring Boot搞出那么多静态内部类
生命太短暂,不要去做一些根本没有人想要的东西.本文已被 https://www.yourbatman.cn 收录,里面一并有Spring技术栈.MyBatis.JVM.中间件等小而美的专栏供以免费学习 ...
- 耐心看,1个Dubbo漏洞,35道必问面试题,Dubbo没什么可神秘的
Dubbo漏洞 无意中在网上看到了这样的一条新闻,说是我们360监测发现了Dubbo官方发布的危险漏洞通告,而且尴尬的是,世界上受影响最大的居然是中国,有图有真相 我感觉这也从侧面证明了一件事情,就是 ...
- 因为mac不支持移动硬盘的NTFS格式,mac电脑无法写入移动硬盘的终极解决办法
相信很多实用mac的同学,都有磁盘容量问题,所以才使用移动硬盘 当移动硬盘在windows电脑上使用过之后,会被格式化为NTFS格式 而mac电脑不支持NTFS格式 这里有两种方法 第一种是把移动硬盘 ...
- 树形dp 之 小胖守皇宫
题目描述 huyichen世子事件后,xuzhenyi成了皇上特聘的御前一品侍卫. 皇宫以午门为起点,直到后宫嫔妃们的寝宫,呈一棵树的形状:有边相连的宫殿间可以互相望见.大内保卫森严,三步一岗,五步一 ...
- Vue全家桶之一Vue(基础知识篇)
全家桶:Vue本身.状态管理.路由. 异步组件: