Halcon之畸变标定Grid-Rectification

简介: Halcon之畸变标定Grid-Rectification

1、官方例程


C:\Users\Public\Documents\MVTec\HALCON-18.11-Progress\examples\hdevelop\Tools\Grid-Rectification\


gen_arbitrary_distortion_map.hdev

grid_rectification.hdev


2、算子说明


connect_grid_points


功能:建立矫正网格的矫正点间的连接。


create_rectification_grid


功能:建立一个附文件,描述矫正网格。


find_rectification_grid


功能:分割图像中矫正网格区域。


gen_arbitrary_distortion_map


功能:产生一个投射图,其描述随意扭曲图像与正确图像间的映射。


gen_grid_rectification_map


功能:计算扭曲图像与基于规律的网格的正确的图像的映射。


3、源码grid_rectification.hdev


* This example illustrates how to use the operators for the grid-rectification.
* 
* The following command creates a postscript file
* that contains the rectification grid. This grid must be
* printed. Then it must be mounted on the object surface.
WidthOfGrid := 0.17
NumSquares := 17
create_rectification_grid (WidthOfGrid, NumSquares, 'rectification_grid.ps')
* 
* Read the image of the object wrapped by the rectification grid
* and reopen the window with an appropriate size.
read_image (Image, 'can_with_grid')
get_image_size (Image, ImageWidth, ImageHeight)
dev_close_window ()
dev_open_window (0, 0, ImageWidth * 0.75, ImageHeight * 0.75, 'black', WindowID1)
dev_display (Image)
dev_update_off ()
set_display_font (WindowID1, 14, 'mono', 'true', 'false')
* 
* 
* Part 1: Determination of the image map
* The surface to be rectified is wrapped by a checkered pattern, which
* is used to determine the mapping between the distorted image and
* the rectified image. Note the orientation of the two circular marks. When
* in gen_grid_rectification_map() the parameter Rotation is 'auto', the rectified
* image is rotated such that the black mark is left of the white mark.
* 
* Determine region of interest
MinContrast := 25
Radius := 10
find_rectification_grid (Image, GridRegion, MinContrast, Radius)
* 
dev_display (GridRegion)
disp_message (WindowID1, 'Grid region', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID1, 'black', 'true')
stop ()
reduce_domain (Image, GridRegion, ImageReduced)
* 
* Determine grid points
SigmaSaddlePoints := 1.5
Threshold := 5
saddle_points_sub_pix (ImageReduced, 'facet', SigmaSaddlePoints, Threshold, Row, Col)
* 
dev_set_color ('blue')
gen_cross_contour_xld (SaddlePoints, Row, Col, 6, 0.785398)
dev_display (Image)
dev_display (SaddlePoints)
disp_message (WindowID1, 'Grid points', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID1, 'black', 'true')
stop ()
* 
* Connect points to grid
SigmaConnectGridPoints := 0.9
MaxDist := 5.0
GridSpacing := 20
dev_set_color ('red')
connect_grid_points (ImageReduced, ConnectingLines, Row, Col, SigmaConnectGridPoints, MaxDist)
* 
dev_display (ConnectingLines)
disp_message (WindowID1, 'Connected grid points', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowID1, 'black', 'true')
stop ()
* 
* Determine image map
gen_grid_rectification_map (ImageReduced, ConnectingLines, Map, Meshes, GridSpacing, 0, Row, Col, 'bilinear')
map_image (ImageReduced, Map, ImageMapped)
* 
get_image_size (Map, MapWidth, MapHeight)
dev_open_window (0, (ImageWidth * 0.75) + 12, MapWidth, MapHeight, 'black', WindowID2)
set_display_font (WindowID2, 14, 'mono', 'true', 'false')
dev_display (ImageMapped)
disp_message (WindowID2, 'Rectified grid', 'window', 12, 12, 'black', 'true')
stop ()
* 
* 
* Part 2: Application of the image map
* The original surface (without the checkered pattern) is rectified
* using the previously calculated image map.
* 
* Read in the image to be rectified
read_image (Image, 'can')
* 
* Rectify image using the previously calculated image map
dev_set_window (WindowID2)
map_image (Image, Map, ImageMapped)
* 
dev_set_window (WindowID1)
dev_display (Image)
disp_message (WindowID1, 'Original image', 'window', 12, 12, 'black', 'true')
dev_set_window (WindowID2)
dev_display (ImageMapped)
disp_message (WindowID2, 'Rectified image', 'window', 12, 12, 'black', 'true')


相关文章
Halcon找圆系列(1)如何检测圆形
Halcon找圆系列(1)如何检测圆形
1863 0
Halcon找圆系列(1)如何检测圆形
|
3月前
|
算法 定位技术 vr&ar
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
506 0
一文了解PnP算法,python opencv中的cv2.solvePnP()的使用,以及使用cv2.sovlePnP()方法标定相机和2D激光雷达
|
5月前
|
存储 编解码 算法
【Qt&OpenCV 检测图像中的线/圆/轮廓 HoughLinesP/HoughCircles/findContours&drawContours】
【Qt&OpenCV 检测图像中的线/圆/轮廓 HoughLinesP/HoughCircles/findContours&drawContours】
89 0
|
6月前
|
算法
[Halcon&标定] 相机自标定
[Halcon&标定] 相机自标定
158 1
|
6月前
|
编解码 对象存储 UED
[Halcon&标定] 单相机标定
[Halcon&标定] 单相机标定
225 1
|
6月前
|
文字识别 Python
Halcon 学习笔记五:几何定位+仿射变换+测量
Halcon 学习笔记五:几何定位+仿射变换+测量
610 0
|
6月前
[Qt5] 鼠标中心为基准缩放图像(halcon实现)
[Qt5] 鼠标中心为基准缩放图像(halcon实现)
236 0
|
文字识别 监控 算法
Baumer工业相机堡盟相机使用BGAPISDK联合Halcon直接进行彩色图像显示(Color)(C#)(将图像数据Buffer转为HObject)
Baumer工业相机堡盟相机使用BGAPISDK联合Halcon直接进行彩色图像显示(Color)(C#)(将图像数据Buffer转为HObject)
155 0
|
C++ 计算机视觉
相机与激光雷达标定:gazebo仿真livox_camera_lidar_calibration---相机内参标定
ROS功能包:**livox_camera_lidar_calibration**提供了一个手动校准Livox雷达和相机之间外参的方法,已经在Mid-40,Horizon和Tele-15上进行了验证。其中包含了计算相机内参,获得标定数据,优化计算外参和雷达相机融合应用相关的代码。本方案中使用了标定板角点作为标定目标物,由于Livox雷达非重复性扫描的特点,点云的密度较大,比较易于找到雷达点云中角点的准确位置。相机雷达的标定和融合也可以得到不错的结果。
相机与激光雷达标定:gazebo仿真livox_camera_lidar_calibration---相机内参标定
|
数据采集 传感器
相机与激光雷达标定:gazebo仿真livox_camera_lidar_calibration---标定数据采集与处理
ROS功能包:**livox_camera_lidar_calibration**提供了一个手动校准Livox雷达和相机之间外参的方法,已经在Mid-40,Horizon和Tele-15上进行了验证。其中包含了计算相机内参,获得标定数据,优化计算外参和雷达相机融合应用相关的代码。本方案中使用了标定板角点作为标定目标物,由于Livox雷达非重复性扫描的特点,点云的密度较大,比较易于找到雷达点云中角点的准确位置。相机雷达的标定和融合也可以得到不错的结果。
相机与激光雷达标定:gazebo仿真livox_camera_lidar_calibration---标定数据采集与处理