DetectBarCodePositions method searches for barcodes on the specified part of the image fitting to a mathematical model of barcodes. First the algorithm performs a binary dilation in order to reduce the number of inlet bumps and incontinuities of the barcodes (it’s especially important for skewed barcodes with thin bars). Use higher dilation values for thin bar, skewed barcodes, and lower values for higher quality, horizontal/vertical barcodes. After the dilation the algorithm searches for possible bars on the image fitting to the bar criterions, and tries to make different groups of the coherent bars. At the end of the algorithm each group of bars is determined as a barcode if the barcode group fits to the group criterions.
The model of barcodes has the following criterions :
1. Bar criterions :
1.1. A bar must be similar to a rectangle.
1.2. The ratio of the longer and shorter sides of the rectangle must be equal or larger than the minimal side-length ratio (dMinimalSideLenghtRatio).
2. Group criterions :
2.1. Two coherent bars have to have the same direction.
2.2. A bar can be coherent to a given bar, if the distance between the two bars is not larger than the shorter side of the given bar multiplied by the maximal distance ratio (dMaxDistanceRatio).
2.3. Let’s define the angle difference between two bars as the angle difference between the bar’s normal vector and the line connecting the centroids of the two bars. A bar can be coherent to a given bar if the angle difference between the two bars is not larger than the maximal angle differenc (dMaxAngleDifference).
2.4. At the end of the searching algorythm a finished group of bars can be determined as a barcode, if the number of bars of the given group is equal or larger than the minimal bar number (iMinimalBarNumber).