DetectBarCodePositions

Description         The DetectBarCodePositions method searches for barcodes within the region of the image and returns the number of found barcodes.  The position, orientation and the number of detected bars are stored in an internal array, which can be retrieved by calling the GetBarCodePositionStructValues method. Barcode position is the “smallest” rectangle containing the whole barcode. Returned Orientation is the orientation of the barcode, but this method only searches and does not decode the barcodes, so orientation is not periodical with 360 degrees, but 180 degrees. Because the DetectBarCodePosition method doesn’t decode the barcode therefore it can't decide whether or not it's left to right or right to left coded at the detected angle. Exact orientation can be determined by the decoding methods. The DetectBarCodePositions method finds a given barcode on an image only if the barcode is completely contained within the input parameters, and each bar is a different region. The bars cannot be connected. BarCodeNum is a value that shows the number of detected bars. The BarCodeNum value can be retrieved by the method GetBarCodeNum. ErrorCode is a value that shows the code of occurred error. For possible values see Barcode Error codes. The ErrorCode value can be retrieved by the method GetErrCode.

For more information see Barcode Searching.

Syntax                 RetVal = [BiBrw1Dh]DetectBarCodePositions hDIB nDilationSize iMinimalBarNumber dMinimalSideLenghtRatio dMaxDistanceRatio iEnlargePercent dMaxAngleDifference

 

Returns             RetVal                           LONGLONG Returns the handle to the internal array which stores the details for each detected barcode.

Remarks             hDib                               LONGLONG  Device independent bitmap.

                            nDilationSize                 Byte         If the barcode is very noisy, contains holes, inlet bumps, etc., a binary dilation can be used. This parameter specifies the size of the dilation matrix.

iMinimalBarNumber   Short        Minimal bar number of barcodes to detect. The bar number is the number of Bars that the detected Barcode is consisting of. This value might be interesting in case of not being able to decode a detected barcode. Based on this value, you should be able to filter out invalid barcodes assuming that he is aware of how large barcode he is expecting on the image to scan. This might be even more useful in case of detecting barcode types which are always consisting of a specified number of Bars such as EAN types.

                             dMinimalSideLenghtRatio    Double        Barcode bars are usually long and thin rectangles. This parameter specifies the minimal ratio of longer and shorter side of the smallest outscribed rectangle of a region that is determined as a bar.

                             dMaxDistanceRatio     Double     This parameter specifies the maximal distance between two neighbouring bars. A given bar can be determined as a part of a barcode if the neighbouring bars are not farer than the width of the given bar multiplied by dMaxDistanceRatio..

                             iEnlargePercent            Short        The returned position rectangle of a given barcode is computed by the bars of it. The smallest outscribed rectangle’s left coordinate is the smallest x value of the bar pixels, right coordinate is the smallest right value, etc. If after position detection the barcode has to be decoded, the rectangle must be greater than the smallest rectangle due to the criterias of the barcodes to decode, so during rectangle computation each bar are enlarged by iEnlargePercent.

                             dMaxAngleDifference Double     This parameter specifies the maximal angle difference between two neighbouring bars. For a given bar and it’s neighbour bar angle difference is defined as the angle difference between the bar’s normal vector and the line connecting the centroids of the two bars. Normal vector of a bar is a vector that starts from the centroid of a bar, and it’s direction is perpendicular to the bar direction. Centroid is the centerpoint of a bar..

See Also              GetBarCodeNum, GetErrCode