Halcon-表面檢測-----確定光度立體法系統的光源的方向
對應程式:
determine_tilt_slant_photometric_stereo.hdev
目標:通過使用具有朗伯反射的球體的影像來確定光度立體法系統的光源的方向。
思路為:
圖片:
程式碼:
* Initializations
dev_update_off ()
dev_close_window ()
dev_open_window_fit_size (0, 0, 640, 494, 500, 500, WindowHandle1)
Color := 'green'
dev_set_color (Color)
dev_set_draw ('margin')
dev_set_line_width (3)
set_display_font (WindowHandle1, 14, 'mono', 'true', 'false')
ApproxSphereRadius := 200
*
* Read the shaded images of the sphere
ImageFiles := 'photometric_stereo/shaded_sphere_' + [1:6]$'02'
read_image (Images, ImageFiles)
channels_to_image (Images, MultichannelImage)
count_channels (MultichannelImage, NumImages)
dev_display (Images)
*
* Determine the position and the radius of the sphere
* from the multichannel image
disp_message (WindowHandle1, 'Detect the position of the sphere ...', 'window', 12, 12, 'black', 'true')
gen_circle_contour_xld (ContourCircle, 200, 200, ApproxSphereRadius, 0, 6.28318, 'positive', 1)
create_scaled_shape_model_xld (ContourCircle, 'auto', 0.0, 0.0, 'auto', 0.9, 1.5, 'auto', 'auto', 'ignore_color_polarity', 1, ModelID)
find_scaled_shape_model (MultichannelImage, ModelID, 0.0, 0.0, .9, 1.1, .95, 1, .5, 'least_squares_high', 0, .9, RowCenter, ColumnCenter, Angle, Scale, MatchScore)
SphereRadius := ApproxSphereRadius * Scale
gen_cross_contour_xld (CenterCross, RowCenter, ColumnCenter, 15, 0.0)
dev_display (CenterCross)
dev_display_shape_matching_results (ModelID, Color, RowCenter, ColumnCenter, Angle, Scale, Scale, 0)
disp_continue_message (WindowHandle1, 'black', 'true')
clear_shape_model (ModelID)
stop ()
Color := 'blue'
dev_set_color (Color)
*
* Compute the tilt and slant angles of the light source:
* The parameters MinGray and MaxGray are used to select
* the gray values used for processing. Those values must
* be selected in a way that:
* 1. The background of the scene is excluded from processing
* 2. Overexposed and underexposed parts of the sphere are
* excluded from processing
* 3. The selected region is as large as possible in order
* to ensure a robust estimation of the orientation of
* the light source
MinGray := 170
MaxGray := 255
measure_light_source_orientation_from_sphere (MultichannelImage, SphereRadius, RowCenter, ColumnCenter, MinGray, MaxGray, Tilt, Slant)
*
* Display the results
get_window_extents (WindowHandle1, Row, Column, Width, Height)
dev_open_window (0, Width + 12, Width, Height, 'white', WindowHandle2)
dev_set_part (0, 0, 493, 639)
set_display_font (WindowHandle2, 14, 'mono', 'true', 'false')
PointO := [RowCenter,ColumnCenter]
PointE := PointO + [0,SphereRadius + 10]
gen_contour_polygon_xld (LineContour, [PointO[0],PointE[0]], [PointO[1],PointE[1]])
gen_arrow_contour_xld (ArrowContour, PointE[0], PointE[1], PointO[0], PointO[1] + 50, 20, 20)
hom_mat2d_identity (HomMat2DIdentity)
gen_circle_contour_xld (ContSphere, RowCenter, ColumnCenter, SphereRadius, 0, 6.28318, 'positive', 1)
gen_contour_polygon_xld (LineContourBottom, [RowCenter + SphereRadius,RowCenter + SphereRadius], [0,639])
for Index := 1 to NumImages by 1
access_channel (MultichannelImage, Image, Index)
hom_mat2d_rotate (HomMat2DIdentity, rad(Tilt[Index - 1]), RowCenter, ColumnCenter, HomMat2DRotateTilt)
affine_trans_contour_xld (ArrowContour, ArrowTilt, HomMat2DRotateTilt)
affine_trans_point_2d (HomMat2DRotateTilt, PointE[0], PointE[1], QxTilt, QyTilt)
if (Tilt[Index - 1] >= 0)
PointOrder := 'positive'
else
PointOrder := 'negative'
endif
gen_circle_contour_xld (ContCircleTilt, RowCenter, ColumnCenter, 100, 0, rad(Tilt[Index - 1]), PointOrder, 1)
*
hom_mat2d_rotate (HomMat2DIdentity, rad(Slant[Index - 1]), RowCenter, ColumnCenter, HomMat2DRotateSlant)
affine_trans_contour_xld (ArrowContour, ArrowSlant, HomMat2DRotateSlant)
affine_trans_point_2d (HomMat2DRotateSlant, PointE[0], PointE[1], QxSlant, QySlant)
gen_circle_contour_xld (ContCircleSlant, RowCenter, ColumnCenter, 100, 0, rad(Slant[Index - 1]), 'positive', 1)
*
dev_set_window (WindowHandle1)
dev_display (Image)
dev_display (LineContour)
dev_display (ContCircleTilt)
dev_display (ArrowTilt)
disp_message (WindowHandle1, 'Top view (' + Index + '/' + NumImages + ')', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle1, '0°', 'image', PointE[0], PointE[1], 'black', 'true')
disp_message (WindowHandle1, 'Tilt = ' + Tilt[Index - 1]$'+4.1f' + '°', 'image', QxTilt, QyTilt - 80, 'black', 'true')
dev_set_window (WindowHandle2)
dev_clear_window ()
dev_set_color ('black')
dev_display (LineContourBottom)
dev_display (ContSphere)
dev_set_color (Color)
dev_display (LineContour)
dev_display (ArrowSlant)
dev_display (ContCircleSlant)
disp_message (WindowHandle2, 'Cross section (' + Index + '/' + NumImages + ')', 'window', 12, 12, 'black', 'true')
disp_message (WindowHandle2, '0°', 'image', PointE[0], PointE[1], 'black', 'true')
disp_message (WindowHandle2, 'Slant = ' + Slant[Index - 1]$'+4.1f' + '°', 'image', QxSlant, QySlant - 80, 'black', 'true')
dev_set_window (WindowHandle1)
if (Index < NumImages)
disp_continue_message (WindowHandle2, 'black', 'true')
stop ()
endif
endfor
用到的幾個運算元:
參考資料:
[1]: https://blog.csdn.net/weixin_34391445/article/details/94513702
相關文章
- Halcon表面缺陷檢測-光度立體法
- 光度立體法重構表面
- Halcon表面缺陷檢測-光度立體法檢測藥片包裝背面的缺陷
- halcon——缺陷檢測常用方法總結(光度立體)
- 光度立體法總結
- 檢測-紋理表面凸起、凹痕、劃痕缺陷的檢測
- Halcon表面缺陷檢測-劃痕檢測
- 表面劃痕檢測方法
- Halcon 光度立體法 例程學習總結
- 檢測金屬圓環表面的凹痕
- Halcon6:三維重建和光度立體視覺視覺
- 直播系統定製開發要先確定整體的計劃
- 目標檢測發展方向
- 目標檢測實用中可以改進的方向
- windows10系統使用自帶記憶體檢測工具檢測記憶體好壞的方法Windows記憶體
- SAP ATP可用性檢查中的可用性檢查規則的確定
- 如何確定計算節點能不能檢測到儲存節點上的磁碟
- 軟體確認測試報告有什麼作用?國內權威的軟體檢測機構推薦測試報告
- 光源
- 帶貨直播原始碼,確定ViewPager滑塊滑動方向原始碼Viewpager
- 定積分在幾何上的應用——2. 立體的體積
- 軟體測試的驗證和確認
- 軟體測試報告可作哪些用途?如何正確選擇軟體檢測機構?測試報告
- 十三、確定測試資源
- 自媒體文章檢測工具,檢測你的文章,提高你的質量
- AI是基因檢測發展的加速器?細聊“AI+基因檢測”的正確開啟方式AI
- 光源光功率計(光損耗測試儀OLTS)的損耗測試原理
- 軟體測試培訓分享:軟體測試的職業發展方向有哪些
- STM32埠IO方向設定問題的IO方向設定問題
- 定性檢測的樣本量估算之精確概率法
- 你瞭解過軟體確認測試嗎?可進行確認測試的軟體測評中心推薦
- JavaScript 陀螺儀檢測裝置方向(重力感應)JavaScript
- 實時的空號檢測API,穩定可靠API
- Leetcode 892. 三維形體的表面積 python 版本LeetCodePython
- 自動化測試的方向
- win10正式版系統下檢測不到獨立顯示卡的解決方法Win10
- 美疾控中心混淆病毒檢測和抗體檢測 使人無法準確把握新冠疫情在美國的傳播情況
- 軟體確認測試