measurement is one of the application scenarios of machine vision. Today I will introduce some methods of measuring items in halcon. There are many measurement demos of
in halcon. In actual project use, the most widely used method is to use calipers to solve measurement tasks. The overall idea is to find the boundary point first, then judge whether the boundary point meets the requirements, and finally pass the fitting Outlet or circle to perform measurement tasks. Of course, it can also be fitted after edge finding.
Understand the halcon measurement principle
In halcon, the method to determine the edge is to calculate the average value of pixels on each width on the width of an ROI, and calculate all the average values over the entire length of the ROI, and get a series of average gray Degree value, then this series of gray values constitute the contour line Profile Line
Projection contour line calculation mean
If the gray value is calculated at this width, the projection lines are not parallel, then interpolation will be used to calculate the average gray Value, nearest_neighbor nearest neighbor interpolation, biliner bilinear interpolation, bicubic interpolation. The effect of
width and filtering
At the same time, the wider the ROI width, the more realistic the calculated average value, and the more accurate the value obtained. At the same time, for the same ROI width, if filtering is used, the effect is the best. It is used in the measurement object The filter is a Gaussian filter.
measures the rectangular ROI
measured ROI, rectangle center R, C coordinates, rectangle width and height, phi
measurement process
establishes the measurement object
gen_measure_rectangle2(:: Row, Column, Phi, Length1, Length2, gen Width, Height, Intercpolation: Measure Handle_measure) (:: CenterRow, CenterCol, Radius, AngleStart, AngleExtent, AnnulusRadius, Width, Height, Interpolation: MeasureHandle)
Row: R coordinate of the center of the rectangular ROI
Column: C coordinate of the center of the rectangular ROI
Length1: Half-length of the rectangular ROI
Length2: Z2z
Width: the width of the image
Height: the height of the retreat
Interolation: interpolation
MeasureHandle: the bit arc of the output measurement handle object
gen_measure_arc is similar to the gen_measure_rectangle2
measurement z2 zz37: Row Measure, Transition: Measure pos, Transition: Select , ColumnEdge,Amplitude, Distance)
measure_pairs(Image:: MeasureHandle, Sigma, Threshold, Transition, Select: RowEdgeFirst,ColumnEdgeFirst, AmplitudeFirst, RowEdgeSecond, ColumnEdgeSecond, AmplitudeSecond, IntraDistance, InterDistance: filter input image
Image: input image handle
zImage: filter
ThresHold: edge amplitude
Transition: edge polarity, from white to black, from black to white, both
Select: point selection, first point, last point, all
RowEdge, ColumnEdge, Amplitude, Dinstance: output point information
also There is an advanced measurement method called fuzzy_measure. I personally have not used this method in practical applications, but I have also studied it. In the later stage, we will specifically talk about fuzzy_meausre.
. We still get a point separately, we can’t To truly express a boundary, our best way is to fit a straight line or a circle through a series of points found, express
in pseudo code, and finally fit the circle and straight line through fit_circle_contour_xld and fit_line_contour_xld.
calculates
distance_pp calculates the distance between two points
distance_pl calculates the distance from a point to a line
mean_tuple calculates the average value, which is used when distance_pl is used to find the circle of
caliper, and find the line
although there are only two simplest operators But the combination will have a powerful effect, which can meet the needs of more than 98% of the project. There are many measurement methods given by halcon, which I have seen, but I still useless in the actual project, and for beginners, it is not You need to know so much, otherwise your enthusiasm will be dissipated.
Feel like to pay attention to my public account VisionManMaster
from time to time to update various knowledge later, welcome to come and follow me