Search in sources :

Example 6 with BarCodeReader

use of com.aspose.barcode.barcoderecognition.BarCodeReader in project Aspose.BarCode-for-Java by aspose-barcode.

the class FasterImageProcessingForBarcodeRecognition method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(FasterImageProcessingForBarcodeRecognition.class) + "BarcodeReader/advanced_features/";
    // Read code39 barcode from image
    String imageFilePath = dataDir + "datamatrix.bmp";
    // Create an instance of BarCodeReader and set image and symbology type to recognize
    BarCodeReader reader = new BarCodeReader(imageFilePath, com.aspose.barcode.barcoderecognition.DecodeType.DATA_MATRIX);
    // Set recognition hints
    // reader.setImageBinarizationHints(RecognitionHints.ImageBinarization.MedianSmoothing);
    reader.setMedianSmoothingWindowSize(4);
    // Try to recognize the barcode from the image
    while (reader.read()) {
        // Display the CodeText
        System.out.println("Codetext: " + reader.getCodeText());
    }
    // Close the reader
    reader.close();
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 7 with BarCodeReader

use of com.aspose.barcode.barcoderecognition.BarCodeReader in project Aspose.BarCode-for-Java by aspose-barcode.

the class GetAllPossible1DBarcodesFromAnImage method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(GetAllPossible1DBarcodesFromAnImage.class) + "BarcodeReader/advanced_features/";
    // Initialize the BarCodeReader object
    BarCodeReader reader = new BarCodeReader(dataDir + "MultipleBarcodes.png", com.aspose.barcode.barcoderecognition.DecodeType.CODE_128);
    // Call read method
    reader.read();
    // Now get all possible barcodes
    int iCount = 0;
    while (reader.read()) {
        // Display code text, symbology, detected angle, recognition percentage of the barcode
        System.out.println("Code Text: " + reader.getCodeText() + " Symbology: " + reader.getCodeType() + " Recognition percentage: " + reader.getAngle());
        // Display x and y coordinates of barcode detected
        Point[] point = reader.getRegion().getPoints();
        System.out.println("Top left coordinates: X = " + point[0].getX() + ", Y = " + point[0].getY());
        System.out.println("Bottom left coordinates: X = " + point[1].getX() + ", Y = " + point[1].getY());
        System.out.println("Bottom right coordinates: X = " + point[2].getX() + ", Y = " + point[2].getY());
        System.out.println("Top right coordinates: X = " + point[3].getX() + ", Y = " + point[3].getY());
        iCount = iCount + 1;
    }
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) Point(java.awt.Point) Point(java.awt.Point)

Example 8 with BarCodeReader

use of com.aspose.barcode.barcoderecognition.BarCodeReader in project Aspose.BarCode-for-Java by aspose-barcode.

the class SpecificBarcodeSymbology method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(SpecificBarcodeSymbology.class) + "BarcodeReader/basic_features/";
    BufferedImage img = ImageIO.read(new File(dataDir + "CodeText.jpg"));
    // Initialize barcode reader
    BarCodeReader rd = new BarCodeReader(img, com.aspose.barcode.barcoderecognition.DecodeType.CODE_128);
    // Read barcode of type Code39Extended
    while (rd.read()) {
        // Print the code text, if barcode found
        System.out.println("CodeText: " + rd.getCodeText().toString());
        // Print the symbology type
        System.out.println("CodeText: " + rd.getCodeType());
    }
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) File(java.io.File) BufferedImage(java.awt.image.BufferedImage)

Example 9 with BarCodeReader

use of com.aspose.barcode.barcoderecognition.BarCodeReader in project Aspose.BarCode-for-Java by aspose-barcode.

the class LoadingFromAStream method main.

public static void main(String[] args) throws IOException {
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(LoadingFromAStream.class) + "BarcodeReader/loading_images/";
    // Open the stream. Read only access is enough for Aspose.BarCode to load an image.
    InputStream stream = new FileInputStream(dataDir + "CodeText.jpg");
    // Create an instance of BarCodeReader class
    // and pass InputStream object as a parameter
    BarCodeReader reader = new BarCodeReader(stream);
    // OR
    // Open the stream. Read only access is enough for Aspose.BarCode to load an image.
    InputStream stream1 = new FileInputStream(dataDir + "CodeText.jpg");
    // Create an instance of BarCodeReader class
    // and pass InputStream object and bar code symbology type as parameters
    BarCodeReader reader1 = new BarCodeReader(stream, com.aspose.barcode.barcoderecognition.DecodeType.CODE_39_EXTENDED);
    // OR
    // Open the stream. Read only access is enough for Aspose.BarCode to load an image.
    InputStream stream2 = new FileInputStream(dataDir + "CodeText.jpg");
    // Load the image. Read only access is enough for Aspose.BarCode to load an image.
    BufferedImage img3 = ImageIO.read(new File(dataDir + "CodeText.jpg"));
    // Create an instance of BarCodeReader class
    // and pass BufferedImage object as parameter
    BarCodeReader reader3 = new BarCodeReader(img3);
    // OR
    // Create an instance of BarCodeReader class
    // and pass image object, Rectangle object and bar code symbology type as parameters
    BarCodeReader reader2 = new BarCodeReader(img3, new Rectangle(0, 0, 100, 50), com.aspose.barcode.barcoderecognition.DecodeType.CODE_39_EXTENDED);
    // OR
    // Load the image. Read only access is enough for Aspose.BarCode to load an image.
    BufferedImage img4 = ImageIO.read(new File(dataDir + "CodeText.jpg"));
    // Create an instance of BarCodeReader class
    // and pass BufferedImage object and bar code symbology type as parameters
    BarCodeReader reader4 = new BarCodeReader(img4, com.aspose.barcode.barcoderecognition.DecodeType.PDF_417);
    // OR
    // Load the image. Read only access is enough for Aspose.BarCode to load an image.
    BufferedImage img5 = ImageIO.read(new File(dataDir + "CodeText.jpg"));
    // Create an instance of BarCodeReader class
    // and pass BufferedImage object, Rectangle object and bar code symbology type as parameters
    BarCodeReader reader5 = new BarCodeReader(img5, new Rectangle(0, 0, 100, 50), com.aspose.barcode.barcoderecognition.DecodeType.CODE_39_EXTENDED);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Rectangle(java.awt.Rectangle) BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) File(java.io.File) FileInputStream(java.io.FileInputStream) BufferedImage(java.awt.image.BufferedImage)

Example 10 with BarCodeReader

use of com.aspose.barcode.barcoderecognition.BarCodeReader in project Aspose.BarCode-for-Java by aspose-barcode.

the class Filter method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(ReadMultipleMacropdf417BarcodeImages.class) + "BarcodeReader/advanced_features/";
    String strFileID = "1";
    File dir = new File(dataDir);
    File[] files = dir.listFiles(new Filter(strFileID));
    for (int nCount = 1; nCount <= files.length; nCount++) {
        // We got list of all the files, now read barcodes
        BarCodeReader reader = new BarCodeReader(files[nCount - 1].getAbsolutePath(), com.aspose.barcode.barcoderecognition.DecodeType.MACRO_PDF_417);
        if (reader.read() == true) {
            System.out.println("File: " + files[nCount - 1].getAbsolutePath() + " == FileID: " + reader.getMacroPdf417FileID() + " == SegmentID: " + reader.getMacroPdf417SegmentID() + " == CodeText: " + reader.getCodeText());
        }
        reader.close();
    }
}
Also used : FileFilter(java.io.FileFilter) BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) File(java.io.File)

Aggregations

BarCodeReader (com.aspose.barcode.barcoderecognition.BarCodeReader)19 File (java.io.File)5 BufferedImage (java.awt.image.BufferedImage)4 BarCodeRegion (com.aspose.barcode.barcoderecognition.BarCodeRegion)2 Point (java.awt.Point)2 Rectangle (java.awt.Rectangle)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 BarCodeBuilder (com.aspose.barcode.BarCodeBuilder)1 GradientPaint (java.awt.GradientPaint)1 Graphics (java.awt.Graphics)1 Paint (java.awt.Paint)1 FileFilter (java.io.FileFilter)1