halcon缺陷檢測
dev_close_window ()
dev_update_off ()
read_image (Image3, 'C:/Users/Administrator/Desktop/藥品檢測.png')
get_image_size (Image3, Width, Height)
dev_open_window_fit_image (Image3, 0, 0, -1, -1, WindowHandle)
dev_set_draw ('fill')
dev_set_line_width (3)
dev_display (Image3)
*處理圖片
threshold (Image3, Regions, 5, 62)
connection (Regions, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 227.96, 79863.2)
union1 (SelectedRegions, RegionUnion)
orientation_region (RegionUnion, Phi)
area_center (RegionUnion, Area, Row, Column)
vector_angle_to_rigid (Row, Column,Phi, Row, Column,rad(0), HomMat2D)
affine_trans_image (Image3, ImageAffineTrans, HomMat2D, 'constant', 'false')
affine_trans_region (RegionUnion, RegionAffineTrans, HomMat2D, 'nearest_neighbor')
dev_display (ImageAffineTrans)
gen_empty_obj (Chambers)
for I:=0 to 1 by 1
Rows :=191+I*102
for J:=0 to 5 by 1
columns :=166.3+J*80
gen_circle (circle, Rows, columns, 30.991)
concat_obj (Chambers, circle, Chambers)
dev_display (ImageAffineTrans)
endfor
endfor
difference (RegionAffineTrans, Chambers, RegionDifference)
union1 (Chambers, ChambersUnion)
orientation_region (ChambersUnion, PhiRef)
PhiRef1 := rad(180) + PhiRef
area_center (ChambersUnion, AreaRef, RowRef, ColumnRef)
read_image (Image3, 'C:/Users/Administrator/Desktop/藥品檢測.png')
dev_display(Image3)
*預處理
threshold (Image3, Regions1, 9, 90)
connection (Regions1, ConnectedRegions1)
select_shape (ConnectedRegions1, SelectedRegions1, 'area', 'and', 227.96, 91109.4)
union1 (SelectedRegions1, RegionUnion1)
fill_up (RegionUnion1, RegionFillUp)
orientation_region (RegionFillUp, Phi1)
area_center (RegionFillUp, Area1, Row1, Column1)
vector_angle_to_rigid (Row1, Column1, Phi1, RowRef, ColumnRef, PhiRef1, HomMat2D1)
affine_trans_image (Image3, ImageAffineTrans1, HomMat2D1, 'constant', 'false')
reduce_domain (ImageAffineTrans1, ChambersUnion, ImageReduced)
*4進行影像分割(blob)
threshold (ImageReduced, Regions2, 3, 109)
connection (Regions2, ConnectedRegions2)
select_shape (ConnectedRegions2, SelectedRegions2, ['area','circularity'], 'and', [727.96,0.7682], [2000,0.9962])
count_obj (Chambers, Number)
sort_region (SelectedRegions2, SortedRegions, 'character', 'true', 'row')
gen_empty_obj (WrongPill)
gen_empty_obj (MissingPill)
gen_empty_obj (CrackPill)
for Index :=1 to Number by 1
select_obj (Chambers, charms, Index)
intersection (charms,SortedRegions, pill)
area_center (pill, Area2, Row2, Column2)
area_holes (pill, AreaHoles)
if(AreaHoles>0)
concat_obj (CrackPill, pill, CrackPill)
else
if(Area2>0)
if(Area2<1400 or Area2>1600)
concat_obj (WrongPill, pill, WrongPill)
else
concat_obj (MissingPill, pill, MissingPill)
endif
endif
endif
endfor
*顯示
count_obj (SortedRegions, Number1)
count_obj (MissingPill, NumberMP)
count_obj (CrackPill, NumberCP)
count_obj (WrongPill, NumberWP)
*顯示
if (NumberWP > 0)
disp_message (WindowHandle, '錯誤藥片'+NumberWP, 'image', 0, 0, 'red', 'true')
endif
if(NumberMP >0)
disp_message (WindowHandle, '好藥片'+NumberMP, 'image', 20, 0, 'red', 'true')
endif
if(NumberCP>0)
disp_message (WindowHandle, '破碎藥片'+NumberCP, 'image', 40, 0, 'red', 'true')
endif
相關文章
- Halcon表面缺陷檢測-劃痕檢測
- Halcon缺陷檢測例項轉OpenCV實現(二) PCB印刷缺陷檢測OpenCV
- Halcon表面缺陷檢測-光度立體法
- 影像分析,使用Halcon進行缺陷檢測
- Halcon缺陷檢測例項轉OpenCV實現(三) 物體凸缺陷檢測OpenCV
- Halcon表面缺陷檢測-光度立體法檢測藥片包裝背面的缺陷
- halcon——缺陷檢測常用方法總結(測量擬合)
- halcon——缺陷檢測常用方法總結(特徵訓練)特徵
- halcon——缺陷檢測常用方法總結(光度立體)
- halcon視覺缺陷檢測系列(1)常用的6種方法視覺
- halcon——缺陷檢測常用方法總結(模板匹配(定位)+差分)
- halcon——缺陷檢測常用方法總結(頻域空間域結合)
- halcon三維檢測啟蒙1
- 道路缺陷智慧檢測系統
- 檢測-紋理表面凸起、凹痕、劃痕缺陷的檢測
- 布匹缺陷檢測baseline提升過程
- 深度學習之瑕疵缺陷檢測深度學習
- Halcon · 曲線寬度檢測演算法總結演算法
- [機器視覺]halcon應用例項 邊緣檢測視覺
- 在C#中使用Halcon開發視覺檢測程式C#視覺
- 突破傳統缺陷檢測的界限,"Defect Spectrum"首次實現超高精度豐富語義的工業缺陷檢測
- 網格缺陷檢測(二值化閾值分析)
- 結合模板匹配與測量的剃鬚刀缺陷檢測
- Halcon-表面檢測-----確定光度立體法系統的光源的方向
- 機器視覺產品尺寸測量與外觀缺陷檢測應用視覺
- VS2005中檢測和更正 C/C++ 程式碼缺陷C++
- 【軟體測試】缺陷
- 大模型在程式碼缺陷檢測領域的應用實踐大模型
- 遇到程式碼缺陷不要慌,馬上教你快速檢測和修復
- Halcon一維測量官方案例解析
- 軟體測試--缺陷報告
- Halcon一維測量1D Measuring解析
- 軟體測試:軟體缺陷管理
- 雲邊協同架構助力智慧工廠視覺 AI 缺陷檢測應用構建架構視覺AI
- 缺陷和缺陷報告
- halcon 修改影像格式
- Halcon快速入門
- 『測試基礎』| 如何理解測試用例管理和缺陷管理?