decode_structured_light_pattern — 对使用结构光系统采集的相机图像进行解码。
decode_structured_light_pattern(CameraImages : : StructuredLightModel : )
decode_structured_light_pattern 用于解码先前通过结构光系统采集的相机图像
CameraImages。解码过程中生成的对应图像及其他中间结果将存储在模型
StructuredLightModel 中,后续可通过算子 get_structured_light_object 进行访问。
下面将详细说明解码过程:
如 gen_structured_light_pattern 中所述,首要目标是判断像素所在区域反射的是亮条还是暗条。为简化这一判断过程,会使用归一化图像,并确定一个能够适应不同反射率和光照条件下的对象的局部可变阈值。在对采集的相机图像进行解码时,所有灰度编码图像都会与先前计算出的阈值进行比较。若图像中某像素的灰度值大于或等于该阈值,则将其归类为亮区。
此外,在解码过程中会对图案区域进行分割。该分割由参数
'min_gray_difference'
控制(参见 set_structured_light_model_param)。
假设已处理了 n 张格雷码(Gray Code)图像,我们就能为每个像素获得一个 n 位的二进制代码。通过该序列,可以推导出显示器上 范围内的行和列坐标。
如果 StructuredLightModel 是一个混合系统,不仅包含格雷码图像,还包含相位偏移图像(参见 gen_structured_light_pattern),那么下一步就是对后者进行解码。解码结果是一个具有亚像素精度的对应图像,该图像建立了显示器坐标与相机坐标之间的映射关系,其中包含关于哪个相机像素观测到哪个显示器像素的信息。
如果 StructuredLightModel 的 'pattern_type' 设置为
'single_stripe',解码过程的第一步是确定是哪条单条纹将光投射到相机像素上。随后利用格雷码序列和相位来精确定位该单条纹内的具体位置。
在实际应用中,可能会出现某个像素检测到的格雷码序列错误的情况。这会导致对应图像中代表显示器行或列的值超出显示器的宽度和高度。为避免此类问题,解码过程的最后一步是将这些值从对应图像中移除。
此算子修改后续输入参数的状态:
在执行此算子时,若该参数值需在多个线程间使用,则必须对其访问进行同步。
CameraImages (输入对象) (multichannel-)image(-array) → object (byte / uint2)
采集的相机图像。
StructuredLightModel (输入控制,状态被修改) structured_light_model → (handle)
结构光模型的句柄。
* Create the model
create_structured_light_model ('deflectometry', StructuredLightModel)
* Set the size of the monitor
set_structured_light_model_param (StructuredLightModel, \
'pattern_width', 1600)
set_structured_light_model_param (StructuredLightModel, \
'pattern_height', 1200)
* Set the smallest width of the stripes in the pattern
set_structured_light_model_param (StructuredLightModel, \
'min_stripe_width', 8)
* Generate the patterns to project
gen_structured_light_pattern (PatternImages, StructuredLightModel)
* Set the expected black/white contrast in the region of interest
set_structured_light_model_param (StructuredLightModel, \
'min_gray_difference', 70)
* Decode the camera images
decode_structured_light_pattern (CameraImages, StructuredLightModel)
* Get the computed correspondences and defects
get_structured_light_object (CorrespondenceImages, StructuredLightModel, \
'correspondence_image')
set_structured_light_model_param (StructuredLightModel, 'derivative_sigma', \
Sigma)
get_structured_light_object (DefectImage, StructuredLightModel, \
'defect_image')
算子 decode_structured_light_pattern 返回值 2 (H_MSG_TRUE),如果给定的参数有效。否则,将抛出异常。
create_structured_light_model,
set_structured_light_model_param
三维计量