Halcon card ruler measurement

read_image (Image, ‘E:/Kell/vision/gg.png’)

* Measure 01: Prepare measurement

draw_line (200000, Row1, Column1, Row2, Column2)

gen_region_line (RegionLines, Row1, Column1, Row2, Column2)

gen_arrow_contour_xld (Arrow, Row1, Column1, Row2, Column2, 15, 25)

AmplitudeThreshold := 25

RoiWidthLen2 := 50

set_system (‘int_zooming’, ‘true’)

* Measure 01: Coordinates for line Measure 01 [0]

LineRowStart_Measure_01_0 := Row1

LineColumnStart_Measure_01_0 := Column1

LineRowEnd_Measure_01_0 := Row2

LineColumnEnd_Measure_01_0 := Column2

* Measure 01: Convert coordinates to rectangle2 type

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 := RoiWidthLen2

gen_measure_rectangle2 (TmpCtrl_Row, TmpCtrl_Column, TmpCtrl_Phi, TmpCtrl_Len1, TmpCtrl_Len2, 3840, 2748, ‘nearest_neighbor’, MsrHandle_Measure_01_0)

measure_pos (Image, MsrHandle_Measure_01_0, 1, AmplitudeThreshold, ‘negative’, ‘all’, Row_Measure_01_0, Column_Measure_01_0, Amplitude_Measure_01_0, Distance_Measure_01_0)

dev_set_color (‘green’)

gen_cross_contour_xld (Cross, Row_Measure_01_0, Column_Measure_01_0, 36, 0.785398)

close_measure (MsrHandle_Measure_01_0)

**for Index := 0 to |Row_Measure_01_0|-1 by 1 RowStar:=Row_Measure_01_0[Index]-sin(rad(90)-TmpCtrl_Phi)*TmpCtrl_Len2 RowEnd:=Row_Measure_01_0[Index]+sin(rad(90)-TmpCtrl_Phi)*TmpCtrl_Len2 ColStar:=Column_Measure_01_0[Index]-cos(rad(90)-TmpCtrl_Phi)*TmpCtrl_Len2 ColEnd:=Column_Measure_01_0[Index]+cos(rad(90)-TmpCtrl_Phi)*TmpCtrl_Len2 gen_contour_polygon_xld (Contour, [RowStar,RowEnd], [ColStar,ColEnd]) endfor**