HALCON从入门到入门-单目对焦测距-三维重建

测试效果

不同高度上拍摄几十张图像

三维重建出的样子

重建的代表深度的图

全景深图

废话

对焦测距是一种采用不同光学参数进行拍摄,在一系列物体图像中找出最清晰的像,并根据几何光学成像原理来计算物体深度的方法。其基本原理是,当镜头对焦于某一物体时,该物体在图像传感器上形成的像最为清晰。通过比较不同焦点位置下的图像清晰度,可以确定物体与相机之间的距离。

实现代码

* This program reconstructs the height of a single solder
* ball on a BGA using depth from focus.
* 
dev_update_off ()
dev_close_window ()
read_image (Image, 'dff/focus_bga_37')
dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_paint ('default')
dev_display (Image)
* 
* Read the sequence of images
disp_message (WindowHandle, 'Read a sequence of focus images ...', 'image', 20, 20, 'white', 'false')
Sequence := [37:-1:1]
Names := 'dff/focus_bga_' + Sequence$'02'
read_image (ImageArray, Names)
channels_to_image (ImageArray, Image)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
for Index := 1 to 37 by 1
    access_channel (Image, ImageDisp, Index)
    dev_display (ImageDisp)
    disp_message (WindowHandle, 'DFF sequence of solder ball: image ' + Index$'02', 'image', 20, 20, 'white', 'false')
    wait_seconds (0.05)
endfor
* 
* Compute the depth map and display results
dev_display (ImageDisp)
disp_message (WindowHandle, 'Compute the depth map', 'image', 20, 20, 'white', 'false')
depth_from_focus (Image, Depth, Confidence, ['bandpass',3,3], 'next_maximum')
scale_image_max (Depth, DepthScaleMax)
select_grayvalues_from_channels (Image, Depth, Sharp)
scale_image (Sharp, ImageScaled, 8, 0)
compose2 (DepthScaleMax, ImageScaled, MultiChannelImage)
dev_clear_window ()
dev_set_paint (['3d_plot','texture'])
dev_display (MultiChannelImage)
disp_message (WindowHandle, '3D reconstruction of a solder ball on a bga', 'image', 20, 280, 'white', 'false')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄晓魚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值