基于光度立体视觉的三维重建方法
基于光度立体视觉的三维重建方法
- 一、三维重建概述
- 二、光度立体原理简介
- 三、Halcon:光度立体实验
- 1.四张测试原图
- 2.结果图
- 3.Halcon实验代码
- 四、相关参考
光度立体视觉通过多角度的光源激励,获取多个不同光照方向下的表面图像,从中重建表面法向,进而重构表面三维形貌,具有像素级的法向重建精度,适用于高反射表面的信息获取,目前已在人体建模、文物保护、医疗辅助、缺陷检测 等方面得到了一定的应用。
一、三维重建概述
在计算机视觉中,三维重建方法主要分为两大类:基于主动视觉理论的三维重建方法和基于被动视觉的三维重建方法。如图所示:
结构光法:利用已知的结构化光源(如条纹图案或激光散斑)照射物体,通过分析反射图案的变形来重建物体的三维形状。
时间飞行(Time of Flight, ToF)法:通过测量光波从发射到反射再到接收所花费的时间来估测物体距离,从而直接获取整个场景的深度信息。
激光扫描法:使用激光束对物体进行扫描,通过测量激光束的反射时间和方向来计算物体的三维坐标。
立体视觉法:利用两个或多个从不同角度拍摄的图像来重建三维场景的结构。通过找到多个图像间相同特征点的方法,来估计这些点在三维空间中的位置。
单目视觉法:仅使用单一摄像机作为采集设备,通过图像的纹理、形状等信息以及经验知识来恢复三维信息。
基于深度学习的方法:利用深度学习算法对图像进行特征提取和匹配,进而实现三维重建。这种方法可以模仿动物视觉系统的工作原理,直接利用图像信息来恢复三维结构。
二、光度立体原理简介
光度立体通过在同一视角下获取多张在不同光照方向下的观测图像,从中逆向求解表面法向,进而重构表面形貌,基本原理如图3所示。光度立体通常假设光照为远场光源,相机成像符合正交投影模型,通过标定获取光照信息(方向和强度),从不同光照信息下的图像之间的亮度变化中逆向求解表面法向量,且光照数量越多,法向求解更加具有鲁棒性。
光度立体采用时分复用的方式,依次点亮每个光源,获取每个光照方向下的观测图像。给定表面上法向为n的一点,则其成像公式可以被描述为:
式中,I 为观测的强度值(经过强度归一化),l 为光照方向,v为视角方向, ρ (n,l ,v)为双向反射分布函数(Bidirectional reflectance distribution function,BRDF),用来描述表面反射特性,max(nT,l,o)解释为附着阴影,n 为单位向量,即
三、Halcon:光度立体实验
1.四张测试原图
![]() | ![]() |
---|---|
![]() | ![]() |
2.结果图
a. 四张原始图片都是光源在不同的角度下拍摄的从主视图看,光源角度几乎都在45°左右
Slants := [41.4,42.6,41.7,40.9]
b. 从俯视图看,均匀分布在每个上下左右四个位置
Tilts := [6.1,95.0,-176.1,-86.8]
下面是对于参数Slants和Titls的示意图和解释,Slants示意图如下:
Titls示意图如下:
3.Halcon实验代码
* This program demonstrates the use of the photometric stereo technique
* for the inspection of the backside of a pharmaceutical blister.
* Input are 4 images taken from the backside of a pharmaceutical blister
* with light coming from different orientations.
*
* Initialization
dev_close_window ()
dev_update_off ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
set_display_font (WindowHandle, 14, 'mono', 'true', 'false')
Message := 'Inspect the backside of a blister'
Message[1] := 'using photometric stereo. In this case four'
Message[2] := 'different light orientations were used.'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Show input images with different illumination
read_image (Images, 'photometric_stereo/blister_back_0' + [1:4])
for I := 1 to 4 by 1
Message := 'Acquire image ' + I + ' of 4'
select_obj (Images, ObjectSelected, I)
dev_display (ObjectSelected)
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
wait_seconds (0.5)
endfor
*
* Apply photometric stereo to determine the albedo
* and the surface gradient.
Tilts := [6.1,95.0,-176.1,-86.8]
Slants := [41.4,42.6,41.7,40.9]
ResultType := ['gradient','albedo']
photometric_stereo (Images, HeightField, Gradient, Albedo, Slants, Tilts, ResultType, 'poisson', [], [])
*
* Display the albedo image
dev_display (Albedo)
disp_message (WindowHandle, 'Albedo image', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*
* Calculate the gaussian curvature of the surface
* using the gradient field as input for the operator
* derivate_vector_field.
* Defects are usually easy to detect in the curvature image.
derivate_vector_field (Gradient, GaussCurvature, 1, 'gauss_curvature')
*
* Detect defects
*
* Segment the tablet areas in the curvature image
regiongrowing (GaussCurvature, Regions, 1, 1, 0.001, 250)
select_shape (Regions, TabletRegions, ['width','height'], 'and', [150,150], [200,200])
shape_trans (TabletRegions, TabletRegions, 'convex')
union1 (TabletRegions, TabletRegions)
erosion_circle (TabletRegions, TabletRegions, 3.5)
* Search for defects inside the tablet areas
reduce_domain (GaussCurvature, TabletRegions, ImageReduced)
abs_image (ImageReduced, ImageAbs)
threshold (ImageAbs, Region, 0.03, 255)
closing_circle (Region, RegionClosing, 10.5)
connection (RegionClosing, ConnectedRegions)
select_shape (ConnectedRegions, Defects, 'area', 'and', 10, 99999)
area_center (Defects, Area, Row, Column)
gen_circle (Circle, Row, Column, gen_tuple_const(|Row|,20.5))
* Display the defects in curvature image
dev_set_draw ('margin')
dev_set_color ('red')
dev_set_line_width (2)
dev_display (GaussCurvature)
dev_display (Circle)
Message := 'The defect can easily be detected'
Message[1] := 'in the surface curvature image'
disp_message (WindowHandle, Message, 'window', 12, 12, 'black', 'true')
stop ()
* Display the defects in the albedo image
dev_set_draw ('margin')
dev_set_color ('red')
dev_display (Albedo)
dev_display (Circle)
disp_message (WindowHandle, 'Defect in albedo image', 'window', 12, 12, 'black', 'true')
该Halcon实例地址:inspect_blister_photometric_stereo.hdev
四、相关参考
[1]韦逍遥,刘文渊,王龄裕,等.基于光度立体视觉的钢轨焊缝打磨表面缺陷检测[J].机械工程学报,2024,60(24):11-24.
[2]郑天航.基于光度立体的三维重建方法研究[D].浙江科技大学,2024.2024.000031.
基于图像的多视角立体视觉三维重建(四)——基于MVS算法的稠密点云重建
Photometric Stereo 光度立体三维重建(一)——介绍