Reference Guide
GdPicture14 Namespace / GdPictureImaging Class / BarcodeDataMatrixReaderGetBarcodeCount Method
Example





In This Topic
    BarcodeDataMatrixReaderGetBarcodeCount Method (GdPictureImaging)
    In This Topic
    Returns the number of barcode detected by the BarcodeDataMatrixReaderDoScan method.
    Syntax
    'Declaration
     
    
    Public Function BarcodeDataMatrixReaderGetBarcodeCount() As Integer
    public int BarcodeDataMatrixReaderGetBarcodeCount()
    public function BarcodeDataMatrixReaderGetBarcodeCount(): Integer; 
    public function BarcodeDataMatrixReaderGetBarcodeCount() : int;
    public: int BarcodeDataMatrixReaderGetBarcodeCount(); 
    public:
    int BarcodeDataMatrixReaderGetBarcodeCount(); 

    Return Value

    The number of barcode detected.
    Remarks

    This method is used in the "Barcode Recognition" Demo.

    Example
    Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
    using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
    {
        int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
     
        // Set to 0, so all the DataMatrix barcodes in the image should be found.
        int expectedBarcodes = 0;
     
        // Perform scanning at best speed, ignoring very damaged barcodes.
        BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
     
        // Start the DataMatrix scanning process and write info into a text file.
        gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
     
        using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
        {
            int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
     
            for (int i = 1; i <= barcodesFound; i++)
            {
                // Decoded information.
                file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
     
                // The skew angle of the barcode, in degrees.
                file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
     
                // The number of rows of the barcode.
                file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
     
                // The number of columns of the barcode.
                file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
     
                // The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
                file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
     
                // The barcode position, given by the coordinates of the corners.
                file.WriteLine("Position =  Top-Left=["
                    + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
                    + "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
                    + "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
                    + "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
            }
        }
     
        // Release used resources.
        gdpictureImaging.BarcodeDataMatrixReaderClear();
        gdpictureImaging.ReleaseGdPictureImage(imageID);
    }
    See Also