name: add_metrology_object_circle_measure — Add a circle or a circular arc to a metrology model.
add_metrology_object_line_measure — Add a line to a metrology model.
read_image (Img, 'D:/00项目代码/000视觉软件/02Halocn算法20190501/04测量20190424/04_池-孔径/IMG11.jpg')
get_image_size (Img, Width, Height)
gen_rectangle1 (ROI_0, 215.769, 773.814, 323.904, 1012.06)
reduce_domain (Img, ROI_0, ImageReduced)
binary_threshold (ImageReduced, Region, 'max_separability', 'dark', UsedThreshold)
connection (Region, ConnectedRegions)
area_center (ConnectedRegions, Area, Row, Column)
distance_pp (Row[0], Column[0], Row[1], Column[1], Distance)
abss := 5/Distance
stop ()
*******************************Circle_measure**************************************************
*add_metrology_object_circle_measure
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandlecircle)
dev_clear_window ()
read_image (Imagecircle, 'D:/00项目代码/000视觉软件/02Halocn算法20190501/04测量20190424/04_池-孔径/IMG13.jpg')
* read_image (Imagecircle, '测量拟合.bmp')
rgb1_to_gray (Imagecircle, GrayImagecircle)
get_image_size (GrayImagecircle, Widthcircle, Heightcircle)
* Prepare the metrology model data structure
create_metrology_model (MetrologyHandlecircle)
* Setting the image width in advance is not
* necessary, but improves the runtime of the
* first measurement.
* It is possible to measure more than one circle/rectangle/line/ellipse
set_metrology_model_image_size (MetrologyHandlecircle, Widthcircle, Heightcircle)
draw_circle (WindowHandlecircle, DrCenCirRow, DrCenCirColumn, DrCenCirRadius)
dev_set_draw ('margin')
CircleInitRadius := DrCenCirRadius
CircleInitRow := DrCenCirRow
CircleInitColumn := DrCenCirColumn
CircleRadiusTolerance := 10
* Add the metrology circle objects to the model
* as defined above
add_metrology_object_circle_measure (MetrologyHandlecircle, CircleInitRow, CircleInitColumn, CircleInitRadius, CircleRadiusTolerance, 5, 1.5, 2, [], [], MetrologyCircleIndices)
* It is possible to measure more than one circle/rectangle/line/ellipse
* instance per metrology object in one call.
* Since we like to measure two circles per object,
* we set 'num_instances' to 2.
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'num_instances', 10)
* Setting 'measure_transition' to 'uniform' assures
* that only consistent circles are returned, that have
* either only edges from bright to dark or vice versa.
* Since the consistency check increases runtime, it is
* switched of by default.
* In this example however, it is safer to switch it on,
* because both negative and positive edges are present.
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'measure_transition', 'uniform')
* Setting the minimum score can make the results more robust
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'min_score', .9)
* Perform the measurement circle
apply_metrology_model (GrayImagecircle, MetrologyHandlecircle)
* Access the results of the circle measurement
get_metrology_object_result (MetrologyHandlecircle, MetrologyCircleIndices, 'all', 'result_type', 'all_param', CircleParameter)
* Extract the parameters for better readability
Sequence := [0:3:|CircleParameter| - 1]
CircleRow := CircleParameter[Sequence]
CircleColumn := CircleParameter[Sequence + 1]
CircleRadius := CircleParameter[Sequence + 2]
* Display the results
* Get measured contours
get_metrology_object_result_contour (Contoursfittingscircle, MetrologyHandlecircle, 'all', 'all', 1.5)
* Get the contours of the measure regions
* and the coordinates of the edge points
* that were the basis for fitting the circles and rectangles
get_metrology_object_measures (Contourscircle, MetrologyHandlecircle, 'all', 'all', Rowcircle, Columncircle)
gen_cross_contour_xld (Contourscircle, Rowcircle, Columncircle, 6, 0.785398)
dev_clear_window ()
dev_display (Imagecircle)
fit_circle_contour_xld (Contoursfittingscircle, 'algebraic', -1, 0, 0, 3, 2, Row51, Column51, Radius1, StartPhi, EndPhi, PointOrder)
dev_set_color ('green')
gen_circle_contour_xld (ContCircle1, Row51, Column51, Radius1, 0, 6.28318, 'positive', 1)
gen_cross_contour_xld (Cross1, Row51, Column51, 6, 0.785398)
* gen_contour_region_xld (ConnectedRegions, Contours2, 'border')
* dev_set_draw ('fill')
* gen_region_contour_xld (Contoursfittingscircle, Region1, 'filled')
* dev_display (GrayImagecircle)
* dev_display (Contourscircle)
* dev_display (Contoursfittingscircle)
* dev_display (Contourscircle)
clear_metrology_model (MetrologyHandlecircle)
*******************************Circle_measure**************************************************
stop ()
stop ()
*******************************Circle_measure**************************************************
*add_metrology_object_circle_measure
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandlecircle)
dev_clear_window ()
* read_image (Imagecircle, 'E:/000MyWorkFiles/00Projects/01Halocn算法/04测量/池-孔径/IMG13.jpg')
* read_image (Imagecircle, '测量拟合.bmp')
rgb1_to_gray (Imagecircle, GrayImagecircle)
get_image_size (GrayImagecircle, Widthcircle, Heightcircle)
* Prepare the metrology model data structure
create_metrology_model (MetrologyHandlecircle)
* Setting the image width in advance is not
* necessary, but improves the runtime of the
* first measurement.
* It is possible to measure more than one circle/rectangle/line/ellipse
set_metrology_model_image_size (MetrologyHandlecircle, Widthcircle, Heightcircle)
draw_circle (WindowHandlecircle, DrCenCirRow, DrCenCirColumn, DrCenCirRadius)
dev_set_draw ('margin')
CircleInitRadius := DrCenCirRadius
CircleInitRow := DrCenCirRow
CircleInitColumn := DrCenCirColumn
CircleRadiusTolerance := 10
* Add the metrology circle objects to the model
* as defined above
add_metrology_object_circle_measure (MetrologyHandlecircle, CircleInitRow, CircleInitColumn, CircleInitRadius, CircleRadiusTolerance, 5, 1.5, 2, [], [], MetrologyCircleIndices)
* It is possible to measure more than one circle/rectangle/line/ellipse
* instance per metrology object in one call.
* Since we like to measure two circles per object,
* we set 'num_instances' to 2.
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'num_instances', 10)
* Setting 'measure_transition' to 'uniform' assures
* that only consistent circles are returned, that have
* either only edges from bright to dark or vice versa.
* Since the consistency check increases runtime, it is
* switched of by default.
* In this example however, it is safer to switch it on,
* because both negative and positive edges are present.
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'measure_transition', 'uniform')
* Setting the minimum score can make the results more robust
set_metrology_object_param (MetrologyHandlecircle, MetrologyCircleIndices, 'min_score', .9)
* Perform the measurement circle
apply_metrology_model (GrayImagecircle, MetrologyHandlecircle)
* Access the results of the circle measurement
get_metrology_object_result (MetrologyHandlecircle, MetrologyCircleIndices, 'all', 'result_type', 'all_param', CircleParameter)
* Extract the parameters for better readability
Sequence := [0:3:|CircleParameter| - 1]
CircleRow := CircleParameter[Sequence]
CircleColumn := CircleParameter[Sequence + 1]
CircleRadius := CircleParameter[Sequence + 2]
* Display the results
* Get measured contours
get_metrology_object_result_contour (Contoursfittingscircle1, MetrologyHandlecircle, 'all', 'all', 1.5)
* Get the contours of the measure regions
* and the coordinates of the edge points
* that were the basis for fitting the circles and rectangles
get_metrology_object_measures (Contourscircle, MetrologyHandlecircle, 'all', 'all', Rowcircle, Columncircle)
gen_cross_contour_xld (Contourscircle, Rowcircle, Columncircle, 6, 0.785398)
dev_display (Imagecircle)
fit_circle_contour_xld (Contoursfittingscircle1, 'algebraic', -1, 0, 0, 3, 2, Row52, Column52, Radius2, StartPhi, EndPhi, PointOrder)
dev_set_color ('green')
gen_circle_contour_xld (ContCircle2, Row52, Column52, Radius2, 0, 6.28318, 'positive', 1)
gen_cross_contour_xld (Cross2, Row52, Column52, 6, 0.785398)
* dev_display (GrayImagecircle)
* dev_display (Contourscircle)
* dev_display (Contoursfittingscircle1)
* dev_display (Contourscircle)
clear_metrology_model (MetrologyHandlecircle)
*******************************Circle_measure**************************************************
stop ()
dev_display (Imagecircle)
dev_display (Cross1)
dev_display (ContCircle1)
dev_display (Cross2)
dev_display (ContCircle2)
* real_rad1 := Radius1*abss
* real_rad2 := Radius2*abss
****************开始***********Line01**************************************************
*add_metrology_object_line_measure ----> line01
stop ()
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandleline01)
dev_clear_window ()
read_image (Imageline01, 'D:/00项目代码/000视觉软件/02Halocn算法20190501/04测量20190424/04_池-孔径/IMG13.jpg')
get_image_size (Imageline01, Width, Height)
rgb1_to_gray (Imageline01, GrayImageline01)
get_image_size (GrayImageline01, Widthline01, Heightline01)
dev_set_draw ('margin')
lineTolerance01 := 30
draw_line (WindowHandleline01, DrLineStartRow01, DrLineStartColumn01, DrLineEndRow01, DrLineEndColumn01)
* Prepare the metrology model data structure
create_metrology_model (MetrologyHandleLine01)
* Setting the image width in advance is not
* necessary, but improves the runtime of the
* first measurement.
* It is possible to measure more than one circle/rectangle/line/ellipse
set_metrology_model_image_size (MetrologyHandleLine01, Widthline01, Heightline01)
* Add the metrology line objects to the model with dir
* as defined above
add_metrology_object_line_measure (MetrologyHandleLine01, DrLineStartRow01, DrLineStartColumn01, DrLineEndRow01,DrLineEndColumn01,lineTolerance01, 5, 1, 30, [], [], MetrologyLineIndices01)
* Perform the measurement rectangle
apply_metrology_model (GrayImageline01, MetrologyHandleLine01)
* get_metrology_object_result
get_metrology_object_result (MetrologyHandleLine01, MetrologyLineIndices01, 'all', 'result_type', 'all_param', LineParameter)
* Display the results
* Get measured contours
get_metrology_object_result_contour (ContoursfittingLine01, MetrologyHandleLine01, 'all', 'all', 1.5)
* Get the contours of the measure regions
* and the coordinates of the edge points
* that were the basis for fitting the Line
get_metrology_object_measures (ContoursLine01, MetrologyHandleLine01, 'all', 'all', RowLine, ColumnLine)
gen_cross_contour_xld (CrossLine01, RowLine, ColumnLine, 6, 0.785398)
get_contour_xld (ContoursfittingLine01, Row1, Col1)
dev_display (GrayImageline01)
dev_display (ContoursLine01)
dev_display (ContoursfittingLine01)
dev_display (CrossLine01)
* Clean up memory
clear_metrology_model (MetrologyHandleLine01)
********************结束***********Line01**************************************************
stop ()
****************开始***********Line01**************************************************
*add_metrology_object_line_measure ----> line01
stop ()
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandleline01)
dev_clear_window ()
read_image (Imageline01, 'D:/00项目代码/000视觉软件/02Halocn算法20190501/04测量20190424/04_池-孔径/IMG13.jpg')
get_image_size (Imageline01, Width, Height)
rgb1_to_gray (Imageline01, GrayImageline01)
get_image_size (GrayImageline01, Widthline01, Heightline01)
dev_set_draw ('margin')
lineTolerance01 := 30
draw_line (WindowHandleline01, DrLineStartRow01, DrLineStartColumn01, DrLineEndRow01, DrLineEndColumn01)
* Prepare the metrology model data structure
create_metrology_model (MetrologyHandleLine01)
* Setting the image width in advance is not
* necessary, but improves the runtime of the
* first measurement.
* It is possible to measure more than one circle/rectangle/line/ellipse
set_metrology_model_image_size (MetrologyHandleLine01, Widthline01, Heightline01)
* Add the metrology line objects to the model with dir
* as defined above
add_metrology_object_line_measure (MetrologyHandleLine01, DrLineStartRow01, DrLineStartColumn01, DrLineEndRow01,DrLineEndColumn01,lineTolerance01, 5, 1, 30, [], [], MetrologyLineIndices01)
* Perform the measurement rectangle
apply_metrology_model (GrayImageline01, MetrologyHandleLine01)
* get_metrology_object_result
get_metrology_object_result (MetrologyHandleLine01, MetrologyLineIndices01, 'all', 'result_type', 'all_param', LineParameter)
* Display the results
* Get measured contours
get_metrology_object_result_contour (ContoursfittingLine02, MetrologyHandleLine01, 'all', 'all', 1.5)
* Get the contours of the measure regions
* and the coordinates of the edge points
* that were the basis for fitting the Line
get_metrology_object_measures (ContoursLine01, MetrologyHandleLine01, 'all', 'all', RowLine, ColumnLine)
gen_cross_contour_xld (CrossLine01, RowLine, ColumnLine, 6, 0.785398)
dev_display (GrayImageline01)
dev_display (ContoursLine01)
dev_display (ContoursfittingLine01)
dev_display (CrossLine01)
* Clean up memory
clear_metrology_model (MetrologyHandleLine01)
********************结束***********Line01**************************************************
stop ()
distance_pl (Row1, Col1, RowLine[0], ColumnLine[0], RowLine[33], ColumnLine[33], Distance2)
distance_pp ( Row52, Column52, Row51, Column51, Distance3)
dev_clear_window ()
dev_display (Imagecircle)
dev_set_color ('green')
gen_arrow_contour_xld (Arrow, 309, 467, 976, 453, 30, 30)
gen_arrow_contour_xld (Arrow, 976, 453,309, 467, 30, 30)
real_disl := abss*Distance2
real_discc := abss*Distance3
disp_message (3600,'宽度(mm):'+real_disl[10], 'image', 641,200,'green', 'false')
gen_arrow_contour_xld (Arrow, Row52, Column52, Row51, Column51,10, 10)
gen_arrow_contour_xld (Arrow, Row51, Column51, Row52, Column52,10, 10)
disp_message (3600,'中心距(mm):'+real_disl[10], 'image', 453,636,'green', 'false')
dev_display (GrayImageline01)
dev_set_color ('red')
dev_display (ContoursfittingLine02)
dev_display (ContoursfittingLine01)
dev_display (Cross1)
dev_display (ContCircle1)
dev_display (Cross2)
dev_display (ContCircle2)
real_rad1 := Radius1*abss*2
real_rad2 := Radius2*abss*2
gen_arrow_contour_xld (Arrow, 507, 637, 484, 615, 10, 10)
gen_arrow_contour_xld (Arrow, 400, 636, 428, 611, 10, 10)
disp_message (3600,'直径1(mm):'+real_rad1, 'image', 388,653,'green', 'false')
disp_message (3600,'直径2(mm):'+real_rad2, 'image', 518,651,'green', 'false')