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 ()*打 ...
随机推荐
- [译]高性能缓存库Caffeine介绍及实践
概览 本文我们将介绍Caffeine-一个Java高性能缓存库.缓存和Map之间的一个根本区别是缓存会将储存的元素逐出.逐出策略决定了在什么时间应该删除哪些对象,逐出策略直接影响缓存的命中率,这是缓存 ...
- CSS中link和@import的使用区别
我们都知道在html中引入外部的CSS 有2种方式,link标签和@import,他们又什么区别呢? 1.从属关系区别@import是 CSS 提供的语法规则,只有导入样式表的作用:link是HTML ...
- Jmeter系列(38)- 详解性能监控工具 nmon
如果你想从头学习Jmeter,可以看看这个系列的文章哦 https://www.cnblogs.com/poloyy/category/1746599.html 前言 做性能测试,服务器监控是至关重要 ...
- [JAVA]多线程之实现Callable接口
通过继承Callable方式实现的多线程可以获取线程执行后的返回值 示例代码如下: public class Counter implements Callable<Integer> { ...
- 外部应用复制 表格 到word中 设置表格自适应
word 批量设置表格宽度自适应 描述 : 我们经常从 外部 如 excel,html 等其他文件 中复制的表格到word 文档 经常会出现在 word 中显示不全的问题 主要是源格式的表格 宽度比 ...
- 李航统计学习方法(第二版)(六):k 近邻算法实现(kd树(kd tree)方法)
1. kd树简介 构造kd树的方法如下:构造根结点,使根结点对应于k维空间中包含所有实例点的超矩形区域;通过下面的递归方法,不断地对k维空间进行切分,生成子结点.在超矩形区域(结点)上选择一个坐标轴和 ...
- python 装饰器(七):装饰器实例(四)类装饰器装饰类以及类方法
类装饰器装饰类方法 不带参数 from functools import wraps import types class CatchException: def __init__(self,orig ...
- [USACO3.1]形成的区域(扫描线+离散化)
[USACO3.1]形成的区域(P6432) 日期:2020-05-31 目录 [USACO3.1]形成的区域(P6432) 一.题意分析 二.算法分析 1. 暴力 0). 初始状态(红点为原点) 1 ...
- 《你还在写sql语句吗?》人生苦短,进入MybatisPlus的丝滑体验
一.发展历程 依稀记得大学期间,类中写sql语句的日子,一个sql语句占据了大部分时间,到后来hibernate的出现算是解决了这一痛点.工作 后,我们又接触到了mybatis这样的框架,瞬间感觉这个 ...
- drf☞jwt自动签发与手动签发
目录 一.自动签发 二.手动签发 一.自动签发 urls from rest_framework_jwt.views import obtain_jwt_token # 使用jwt自带的登录视图 ur ...