- * Code generated by Image Acquisition 01
- list_files ('I:/测量图片及程序/拉链/', ['files','follow_links'], ImageFiles)
- tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima)图片下载:
- [hide]链接:[url]http://pan.baidu.com/s/1c9TzOi[/url] 密码:17a1[/hide]
- ,'ignore_case'], ImageFiles)
- for Index := 0 to |ImageFiles| - 1 by 1
-
- read_image (image, ImageFiles[Index])
- * Do something
- count_seconds(Seconds)
- * read_image (image, 'C:/Documents and Settings/zazaniao/桌面/拉链/拉链ng2.png')
- rgb1_to_gray(image, GrayImage)
- threshold (GrayImage, Regions, 200, 255)
- connection(Regions, ConnectedRegions2)
- select_shape(ConnectedRegions2, SelectedRegions2, 'area', 'and', 150, 99999)
- closing_circle(SelectedRegions2, RegionClosing, 3.5)
-
- select_shape(RegionClosing, SelectedRegions, ['width','height'], 'and', [8,25], [40,80])
- union1(SelectedRegions, RegionUnion)
- gen_rectangle2(Rectangle, 0, 0, 0, 800, 10)
- dilation1(RegionUnion, Rectangle, RegionClosing1,1)
- connection(RegionClosing1, ConnectedRegions1)
- select_shape(ConnectedRegions1, SelectedRegions1, 'width', 'and', 400, 99999)
- dilation_rectangle1(SelectedRegions1, SelectedRegions1, 21, 1)
- smallest_rectangle2(SelectedRegions1, Row, Column, Phi, Length1, Length2)
- get_image_size(GrayImage, Width, Height)
- gen_empty_obj(LLine)
- gen_empty_obj(RLine)
- ResultFlag:=0
- for i:=0 to |Row|-1 by 1
- gen_measure_rectangle2(Row[i], Column[i], 0,Width, Length2[i], Width, Height, 'nearest_neighbor', MeasureHandle)
- gen_rectangle2(Rectangle1, Row[i], Column[i], 0,Width, Length2[i])
- measure_pairs (GrayImage, MeasureHandle, 1, 25, 'positive_strongest', \
- 'all', RowEdgeFirst, ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond,\
- ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance)
- close_measure(MeasureHandle)
- dev_display(GrayImage)
- for j:=0 to |RowEdgeFirst|-1 by 1
- gen_rectangle2(Rectangle1, RowEdgeFirst[j], ColumnEdgeFirst[j], Phi[i], 1, Length2[i])
- concat_obj(LLine,Rectangle1,LLine)
- gen_rectangle2(Rectangle1, RowEdgeSecond[j], ColumnEdgeSecond[j], Phi[i], 1, Length2[i])
- concat_obj(LLine,Rectangle1,LLine)
- * if(j<|IntraDistance|and j>0)
- * disp_message(3600, IntraDistance[j], 'image', RowEdgeFirst[j]-40, ColumnEdgeFirst[j], 'red', 'false')
- * endif
- * if(j<|InterDistance| and j>0)
- * disp_message(3600, InterDistance[j], 'image', RowEdgeSecond[j]+40, ColumnEdgeSecond[j], 'red', 'false')
- * endif
- endfor
- tuple_median(InterDistance, Median)
- tuple_max(InterDistance, Max)
- if(Max>1.5*Median)
- ResultFlag:=ResultFlag+1
- endif
-
- dev_display(LLine)
- if(ResultFlag>0)
- disp_message(3600, 'chain NG', 'window', 12, 12, 'red', 'true')
- else
- disp_message(3600, 'chain OK', 'window', 12, 12, 'green', 'true')
- endif
- endfor
- count_seconds(Seconds1)
- time:=1000*(Seconds1-Seconds)
- stop()
- endfor
-
复制代码 图片下载:
|