下面是HALCON中的一个标定的例子,在有的时候,镜头倾斜安装能够扩大我们的视野,满足一定的需求,但是怎么标定出来正确准确的图像呢,下面这个例子说明了,而且通过这里我们学习使用黑底白点的标定板。

使用的一些图片:

*
* This example demonstrates the benefit of a tilt lens
* and calibrates a camera with a telecentric tilt lens.
* Some peculiarities for telecentric tilt lenses are
* pointed out.
*
* Prepare windows
dev_update_off ()
dev_close_window ()
WindowWidth := 500
WindowHeight := 400
open_two_windows_setup (WindowWidth, WindowHeight, 1, WindowHandles)
*
* This section shows the benefit to be gained from using
* a tiltable lens. First explain the application.
Message := 'This example demonstrates the benefit of a'
Message[1] := 'tilt lens and calibrates a camera with a'
Message[2] := 'telecentric tilt lens.'
disp_message (WindowHandles[1], Message, 'window', 12, 12, 'black', 'true')
Message := 'With a standard camera and lens, best results'
Message[1] := 'are achieved if the optical axis of the camera'
Message[2] := 'is perpendicular to the measurement plane'
Message[3] := 'that contains the object. However, an obstacle'
Message[4] := 'above the measurement plane may prevent this'
Message[5] := 'camera setup and the camera must look at the'
Message[6] := 'object from the side.'
disp_message (WindowHandles[1], Message, 'window', 102, 22, 'black', 'false')
*
* When the optical axis is not perpendicular to the
* measurement plane, the volume of the depth of focus
* is not parallel to the measurement plane.
* As a consequence of this camera setup, a part of an object
* lying in the measurement plane appears blurred in the image.
dev_set_window (WindowHandles[0])
read_image (ImageBlurred, 'caliper/caliper_no_tilt')
get_image_size (ImageBlurred, Width, Height)
crop_rectangle1 (ImageBlurred, ImagePart, 134, 134, 1000, 1000)
* Generate image of the scene
show_setup (ImagePart, WindowHandles[0], 0)
disp_continue_message (WindowHandles[1], 'black', 'true')
stop ()
Message := 'If the optical axis is not perpendicular'
Message[1] := 'to the measurement plane...'
disp_message (WindowHandles[0], Message, 'window', 12, 12, 'black', 'true')
dev_set_window (WindowHandles[1])
gen_rectangle1 (ROIBlurredL, 231, 844, 897, 1276)
gen_rectangle1 (ROIBlurredR, 231, 7, 897, 170)
dev_display (ImageBlurred)
dev_set_color ('red')
dev_display (ROIBlurredR)
dev_display (ROIBlurredL)
Message := '... parts of the object in the measurement'
Message[1] := 'plane are blurred in the image.'
disp_message (WindowHandles[1], Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandles[1], 'black', 'true')
stop ()
*
* If the camera is equipped with a tilt lens,
* the lens can be tilted so that the whole measurement
* plane is in focus.
show_setup (ImagePart, WindowHandles[0], 1)
Message := 'If the camera is equipped with a tilt lens ...'
disp_message (WindowHandles[0], Message, 'window', 12, 12, 'black', 'true')
* Second window
read_image (ImageSharp, 'caliper/caliper_with_tilt')
dev_set_window (WindowHandles[1])
dev_display (ImageSharp)
Message := '... the lens can be tilted so that the entire'
Message[1] := 'measurement plane is in focus.'
disp_message (WindowHandles[1], Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandles[1], 'black', 'true')
stop ()
*
* Calibration of a camera with telecentric tilt lens
dev_set_window (WindowHandles[0])
dev_clear_window ()
Message := 'Calibrate camera with a telecentric tilt lens'
disp_message (WindowHandles[0], Message, 'window', 12, 12, 'black', 'true')
dev_set_window (WindowHandles[1])
dev_set_color ('green')
* Specify initial camera parameter.
* The tilt angle defines the angle by which the
* lens is tilted.
Tilt := 8.5
* The rotation angle defines the orientation of
* the axis around which the tilt is performed.
* It is the angle between the x-axis of
* the sensor and the tilt axis of the lens.
Rot := 270
* Define the magnification of the lens
Magnification := 0.35
* Define size of a pixel
Sx := 5.4e-6
Sy := Sx
gen_cam_par_area_scan_tilt_bilateral_telecentric_division (Magnification, 0.0, Tilt, Rot, Sx, Sy, Width / 2, Height / 2, Width, Height, StartCamParam)
DescrFile := 'calplate_40mm.cpd'
* While tilt lenses provide a region for in which the depth of field
* overlaps in a large area for both cameras, the depth of field is
* wedge-shaped, where the wedge of one camera has a small depth at
* the left or right borders of the images.  This means that some marks
* in the calibration sequence at the left or right borders may still
* be slightly out of focus in this setup.  Therefore, we use a higher
* Sigma to make sure that all marks are extracted.
Sigma := 2.5
*
* Create the calibration data model
create_calib_data ('calibration_object', 1, 1, CalibDataID)
set_calib_data_cam_param (CalibDataID, 0, [], StartCamParam)
set_calib_data_calib_object (CalibDataID, 0, DescrFile)
*
* Input calibration data into the calibration model
for Index := 1 to 8 by 1read_image (Image, 'stereo/telecentric_tilt/cam_0_calib_plate_' + Index$'02')find_calib_object (Image, CalibDataID, 0, 0, Index, 'sigma', Sigma)get_calib_data_observ_contours (Caltab, CalibDataID, 'caltab', 0, 0, Index)get_calib_data_observ_contours (Circles, CalibDataID, 'marks', 0, 0, Index)* Visualize calibration object found in the current imagedev_display (Image)dev_display (Caltab)dev_display (Circles)wait_seconds (0.1)
endfor
*
* Calibrate the cameras
calibrate_cameras (CalibDataID, Error)
dev_set_window (WindowHandles[1])
dev_clear_window ()
* Inspect the calibration results
get_calib_data (CalibDataID, 'camera', 0, 'params', CamParam)
* Get the names of the camera parameters for this model
get_calib_data (CalibDataID, 'camera', 0, 'params_labels', ParLabels)
*
* Display the initial and the optimized camera parameters
display_camera_parameters (StartCamParam, CamParam, Error, ParLabels$'-5', WindowHandles[1])
dev_set_window (WindowHandles[0])
dev_clear_window ()
Message := 'Discussion of the calibration results:'
disp_message (WindowHandles[0], Message, 'window', 12, 12, 'black', 'true')
Message[0] := 'The calibration error indicates that the'
Message[1] := 'calibrated camera parameters correctly describe'
Message[2] := 'the imaging geometry.'
Message[3] := 'Nevertheless, the error is slighlty higher than'
Message[4] := 'it would be in a setup with a larger'
Message[5] := 'depth of field.'
Message[6] := 'This tilt lens has nearly no distortion.'
Message[7] := 'In such a case, a robust calibration of the'
Message[8] := 'tilt parameters and the optical center (cx, cy)'
Message[9] := 'is difficult, e.g., the parameters'
Message[10] := 'may differ from the nominal parameters.'
Message[11] := ' '
Message[12] := 'However, as we will see in the next step, the'
Message[13] := 'determined camera parameters are consistent'
Message[14] := 'and can be used for accurate measurements.'
disp_message (WindowHandles[0], Message, 'window', 42, 22, 'black', 'false')
disp_continue_message (WindowHandles[1], 'black', 'true')
stop ()
*
* Determine mean distance of pitch lines
dev_set_window (WindowHandles[0])
dev_clear_window ()
Message := 'Use the calibration results:'
disp_message (WindowHandles[0], Message, 'window', 12, 12, 'black', 'true')
Message := 'Measure the mean distance of the pitch lines'
Message[1] := 'of a caliper with high accuracy.'
disp_message (WindowHandles[0], Message, 'window', 42, 22, 'black', 'false')
dev_set_window (WindowHandles[1])
dev_set_line_width (2)
dev_display (ImageSharp)
*
* Extract measurement plane using the optimized
* camera parameters
read_image (ImageMeasurementPlane, 'caliper/caliper_measurement_plane')
find_calib_object (ImageMeasurementPlane, CalibDataID, 0, 0, 0, 'sigma', 0.5)
get_calib_data_observ_points (CalibDataID, 0, 0, 0, RowCoor, ColumnCoord, Indices, Poses)
*
* Note that for telecentric cameras the distance z
* to the camera does not have an effect on the appearance of
* the calibration plate in the image. Therefore cannot be
* determined. Another consequence is that the pose of the
* measurement plane does not need to be compensated
* for the plate thickness.
*
* Measure the mean distance between the pitch lines
gen_measure_rectangle2 (670, 640, rad(0), 635, 31, Width, Height, 'bilinear', MeasureHandle)
gen_rectangle2 (Rectangle, 670, 640, rad(0), 635, 31)
*
* Determine the image positions of the pitch lines
measure_pairs (ImageSharp, MeasureHandle, 2, 50, 'all', 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
Row := (RowEdgeFirst + RowEdgeSecond) / 2.0
Col := (ColumnEdgeFirst + ColumnEdgeSecond) / 2.0
gen_cross_contour_xld (Cross, Row, Col, 20, 0.785398)
dev_display (ImageSharp)
dev_display (Cross)
*
* Determine the positions of the pitch lines in camera coordinates
image_points_to_world_plane (CamParam, Poses, Row, Col, 'mm', X1, Y1)
distance_pp (X1[0:2], Y1[0:2], X1[1:3], Y1[1:3], Distance)
*
* Compute the mean and the deviation of the distances.
MeanDistance := mean(Distance)
DeviationDistance := deviation(Distance)
disp_message (WindowHandles[1], ['Mean distance: ' + MeanDistance$'.3f' + ' mm','Deviation:'$'-15' + DeviationDistance$'.3f' + ' mm'], 'window', 12, 12, 'black', 'true')
close_measure (MeasureHandle)
*
* Delete calibration data model
clear_calib_data (CalibDataID)

HALCON标定倾斜安装镜头相关推荐

  1. Halcon学习笔记:Halcon标定步骤-3d_coordinates.hdev示例

    Halcon标定步骤 1.设置相机内部参数的初始值 StartCamPar := [0.016,0,0.0000074,0.0000074,326,247,652,494] set_calib_dat ...

  2. Halcon标定板标定

    halcon标定有自己的标定助手可以演示,不过拿到VS里面却不是很适用.尤其是关于畸变矫正和透视矫正算子的解释也没有,下面两个算子set_origin_pose,gen_image_to_world_ ...

  3. Halcon标定板标定流程

    一.相机内参标定 目的:标定内参的目的是消除镜头的畸变. 面阵相机的内参由一个8位的数组组成包括: startCamPar:=[Focus,Kappa,Sx,Sy,Cx,Cy,ImageWidth,I ...

  4. HALCON标定板简介

    HALCON标定板简介

  5. 华睿相机sdk 开发_岳阳楼区供应睿鉑倾斜五镜头相机D2PSDK是

    岳阳楼区供应睿鉑倾斜五镜头相机D2PSDK是 优势说明:睿鉑倾斜五镜头相机D2PSDK是S2PSDK的升级版相机,具备1:500地籍免相控的能力. 分享到: 当 前 价:1.00 起订数量: 1台 发 ...

  6. 机器视觉--使用halcon标定助手进行相机标定

    一.点击选项卡:---助手--创建新的calibration,可以设置自己的摄相机参数. 二.选择描述文件,cpd文件,就是选择你所需要的标定板的尺寸样式. 如果没有你想使用的标定板,可以通过生成标定 ...

  7. INS/GNSS组合导航(八)IMU倾斜安装求倾斜角

    1.倾斜安装示意图 将下图手机屏幕想象为车机屏幕,此时车机倾斜安装对应为IMU倾斜安装 2.求解倾斜安装角 定义垂直向下为正方向,与重力的方向一致,水平安装传感器IMU时,对应的三轴加速度测量值: R ...

  8. 双目立体视觉之Halcon标定

    标定结果 Halcon标定过程 获取左右相机图像中标定板的区域; find_caltab(Image : CalPlate : CalPlateDescr, SizeGauss, MarkThresh ...

  9. 【Linux配置五】 Ubuntu18.04+kalibr标定工具箱安装编译

    一.安装kalibr 1.安装依赖项 所有 Ubuntu 版本的通用要求如下: sudo apt-get install -y \git wget autoconf automake nano \li ...

最新文章

  1. python java web_Python 与 Java 使用 websocket 通信
  2. Lambda 表达式有何用处?如何使用?
  3. Python安装selenium启动浏览器
  4. window下的host路径
  5. 牛客网(剑指offer) 第九题 变态跳台阶
  6. ns-3文件编译出错总结
  7. SOJ 2800_三角形
  8. 【转】RNN、LSTM、Transformer、BERT简介与区别
  9. 配图做设计、找图找灵感交给素材路SUCAI63
  10. 三分钟快速理解javascript内存管理
  11. [转] 拆开表皮看心脏:主流网游引擎面面观
  12. rem布局下使用背景图片和sprite图
  13. win10计算机无动作后锁屏,怎么让win10不锁屏_让win10不锁屏的操作方法
  14. 独家深访:腾讯变革150天全记录
  15. 国产linux系统对打印机的支持,Linux系统下对打印机进行配置
  16. Python3正则匹配re.split,re.serach,re.sub,re.finditer及re.findall函数用法详解
  17. 使用kubeadm在CentOS上搭建Kubernetes1.14.3集群
  18. sudo rm-rf引发的惨案——Linux硬盘的分区和挂载
  19. python的dev包怎么安装_python-dev如何安装 sudo apt-get install python-dev ?
  20. Wind量化接口中ErrorCode各类错误码意义

热门文章

  1. window下启动nexus出错Unsupported major.minor version 51
  2. JavaScript —— 如何判断一个非数字输入
  3. linux系统负载检查方法
  4. Redis官方的高可用性解决方案
  5. 怎么保证缓存和数据库一致性
  6. Python 解决 :NameError: name 'reload' is not defined 问题
  7. opencv std::vectorcv:Mat
  8. JS字符串类型转日期然后进行日期比较
  9. 201521123111《Java程序设计》第2周学习总结
  10. TortoiseGit:记住用户名和密码