- gen_empty_obj (ShowAll)
- get_image_size (Image, Width, Height)
- RowAll:=[]
- ColAll:=[]
- for IndexNum := 0 to |RowStart|-1 by 1
- gen_contour_polygon_xld (Contour, [RowStart[IndexNum],RowEnd[IndexNum]], [ColStart[IndexNum],ColEnd[IndexNum]])
- concat_obj (ShowAll, Contour, ShowAll)
- Row:=[]
- Col:=[]
- if (CountOrStep>0)
- for Index := 0 to CountOrStep by 1
- Rowtemp := (RowEnd[IndexNum]-RowStart[IndexNum])*(1.0/CountOrStep*Index)+RowStart[IndexNum]
- Coltemp := (ColEnd[IndexNum]-ColStart[IndexNum])*(1.0/CountOrStep*Index)+ColStart[IndexNum]
- Row:=[Row,Rowtemp]
- Col:=[Col,Coltemp]
- endfor
- else
- angle_lx (RowStart[IndexNum], ColStart[IndexNum], RowEnd[IndexNum], ColEnd[IndexNum], Phi)
- Rowt:=RowStart[IndexNum]
- Colt:=ColStart[IndexNum]
- gen_region_contour_xld (Contour, Region, 'margin')
- IsInside:=1
- while (IsInside)
- Row:=[Row,Rowt]
- Col:=[Col,Colt]
- Rowt := Rowt+(-CountOrStep)*sin(-Phi)
- Colt := Colt+(-CountOrStep)*cos(-Phi)
- test_region_point (Region, Rowt, Colt, IsInside)
- endwhile
- endif
- if (IsAngleAuto=1)
- angle_lx (RowStart[IndexNum], ColStart[IndexNum], RowEnd[IndexNum], ColEnd[IndexNum], Phi)
- RowOff:=(1.0*Heiget/2*sin(Phi+rad(90)))
- ColOff:=(1.0*Heiget/2*cos(Phi+rad(90)))
- else
- RowOff:=(1.0*Heiget/2*sin(rad(-Angle)))
- ColOff:=(1.0*Heiget/2*cos(rad(-Angle)))
- endif
- RowS:=Row-RowOff
- ColS:=Col-ColOff
- RowE:=Row+RowOff
- ColE:=Col+ColOff
- for Index := 0 to |RowS|-1 by 1
- if(Index=0 or Index=|RowS|-1)
- gen_arrow_contour_xld (Arrow, RowS[Index], ColS[Index], RowE[Index], ColE[Index], ROIWidth, ROIWidth)
- concat_obj (ShowAll, Arrow, ShowAll)
- endif
- test_region_point (Image, RowS[Index], ColS[Index], IsInside1)
- test_region_point (Image, RowE[Index], ColE[Index], IsInside2)
- if (0=IsInside1 or 0=IsInside2)
- continue
- endif
- set_system ('int_zooming', 'true')
- LineRowStart_Measure_01_0 := RowS[Index]
- LineColumnStart_Measure_01_0 := ColS[Index]
- LineRowEnd_Measure_01_0 := RowE[Index]
- LineColumnEnd_Measure_01_0 := ColE[Index]
- TmpCtrl_Row := 0.5*(LineRowStart_Measure_01_0+LineRowEnd_Measure_01_0)
- TmpCtrl_Column := 0.5*(LineColumnStart_Measure_01_0+LineColumnEnd_Measure_01_0)
- TmpCtrl_Dr := LineRowStart_Measure_01_0-LineRowEnd_Measure_01_0
- TmpCtrl_Dc := LineColumnEnd_Measure_01_0-LineColumnStart_Measure_01_0
- TmpCtrl_Phi := atan2(TmpCtrl_Dr, TmpCtrl_Dc)
- TmpCtrl_Len1 := 0.5*sqrt(TmpCtrl_Dr*TmpCtrl_Dr + TmpCtrl_Dc*TmpCtrl_Dc)
- TmpCtrl_Len2 := ROIWidth
- if (isDbLine=1)
- gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2,Width, Height, 'nearest_neighbor', MsrHandle_Measure_01_0)
- measure_pos (Image, MsrHandle_Measure_01_0, Sigma, Threshold, Transition,Select, Row_Measure_01_1, Column_Measure_01_1, Amplitude_Measure_01_0, Distance_Measure_01_0)
- gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi+rad(180), TmpCtrl_Len1, TmpCtrl_Len2,Width, Height, 'nearest_neighbor', MsrHandle_Measure_01_0)
- measure_pos (Image, MsrHandle_Measure_01_0, Sigma, Threshold, Transition,Select, Row_Measure_01_2, Column_Measure_01_2, Amplitude_Measure_01_0, Distance_Measure_01_0)
- Row_Measure_01_0:=(Row_Measure_01_1+Row_Measure_01_2)/2.0
- Column_Measure_01_0:=(Column_Measure_01_1+Column_Measure_01_2)/2.0
- else
- gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2,Width, Height, 'nearest_neighbor', MsrHandle_Measure_01_0)
- measure_pos (Image, MsrHandle_Measure_01_0, Sigma, Threshold, Transition,Select, Row_Measure_01_0, Column_Measure_01_0, Amplitude_Measure_01_0, Distance_Measure_01_0)
- endif
- close_measure (MsrHandle_Measure_01_0)
- RowAll:=[RowAll,Row_Measure_01_0]
- ColAll:=[ColAll,Column_Measure_01_0]
- endfor
- endfor
- gen_cross_contour_xld (Cross, RowAll, ColAll, ROIWidth, rad(45))
- concat_obj (ShowAll, Cross, ShowAll)
- gen_contour_polygon_xld (ContourLine, RowAll, ColAll)
- if (MaxNumRatio<0 and MaxNumRatio>1)
- fit_line_contour_xld (ContourLine, 'tukey', -1, 0, 5, 2, RowB, ColB, RowE, ColE, Nr, Nc, Dist)
- else
- fit_line_contour_xld (ContourLine, 'tukey', |RowAll|*MaxNumRatio, 0, 5, 2, RowB, ColB, RowE, ColE, Nr, Nc, Dist)
- endif
- gen_contour_polygon_xld (Contour, [RowB,RowE], [ColB,ColE])
- concat_obj (ShowAll, Contour, ShowAll)
- return ()
复制代码
LineInspection_AaronLin.zip
(2.25 KB, 下载次数: 20)
|