Search in sources :

Example 11 with BarCodeReader

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

the class UsingManualHintsToOptimizeScan method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(UsingManualHintsToOptimizeScan.class) + "BarcodeReader/advanced_features/";
    long s = System.currentTimeMillis();
    String filename = dataDir + "datamatrix.bmp";
    BarCodeReader reader = new BarCodeReader(filename, com.aspose.barcode.barcoderecognition.DecodeType.GS_1_DATA_MATRIX);
    System.out.println("Skip rotated barcodes");
    reader.setRecognitionMode(RecognitionMode.ManualHints);
    reader.setManualHints(ManualHint.SkipRotatedBarcodes);
    while (reader.read()) {
        System.out.println(reader.getCodeType() + ": " + reader.getCodeText() + " QA:" + reader.getRecognitionQuality());
    }
    long res1 = System.currentTimeMillis() - s;
    System.out.println(res1);
    System.out.println();
    s = System.currentTimeMillis();
    reader = new BarCodeReader(filename, com.aspose.barcode.barcoderecognition.DecodeType.GS_1_DATA_MATRIX);
    System.out.println("Not skip rotated barcodes");
    while (reader.read()) {
        System.out.println(reader.getCodeType() + ": " + reader.getCodeText() + " QA:" + reader.getRecognitionQuality());
    }
    long res2 = System.currentTimeMillis() - s;
    System.out.println(res2);
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 12 with BarCodeReader

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

the class RecognizingMultipleSymbologiesInSingleImage method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(RecognizingMultipleSymbologiesInSingleImage.class) + "BarcodeReader/basic_features/";
    BufferedImage img = ImageIO.read(new File(dataDir + "MultipleBarcodes.png"));
    // Initialize barcode reader
    BarCodeReader rd = new BarCodeReader(img, DecodeType.ALL_SUPPORTED_TYPES);
    // Read all types of barcode
    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 13 with BarCodeReader

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

the class GetBarCodeRecognitionQualityInPercent method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(GetBarCodeRecognitionQualityInPercent.class) + "BarcodeReader/advanced_features/";
    // Initialize the BarCodeReader object
    BarCodeReader reader = new BarCodeReader(dataDir + "code39Extended.jpg", com.aspose.barcode.barcoderecognition.DecodeType.ALL_SUPPORTED_TYPES);
    // Call read method
    while (reader.read()) {
        System.out.println(reader.getCodeText() + " Type: " + reader.getCodeType());
        float percent = reader.getRecognitionQuality();
        System.out.println("Percent: " + percent);
    }
    reader.close();
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 14 with BarCodeReader

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

the class IdentifyTypeOfCode128 method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(UsingManualHintsToOptimizeScan.class) + "BarcodeReader/advanced_features/";
    // Create an instance of BarCodeReader class
    // Set file path
    // Set the recognition type
    com.aspose.barcode.barcoderecognition.BarCodeReader reader = new com.aspose.barcode.barcoderecognition.BarCodeReader("1bc.png", com.aspose.barcode.barcoderecognition.DecodeType.CODE_128);
    // Perform read operation
    reader.read();
    // Create an array of Code128DataPortion class
    // Call the GetCode128DataPortions method
    com.aspose.barcode.barcoderecognition.Code128DataPortion[] code128DataPortions = reader.getCode128DataPortions();
    // Execute Loop for each Code128DataPortion instance
    for (com.aspose.barcode.barcoderecognition.Code128DataPortion code128DataPortion : code128DataPortions) {
        // Display the subtype and data
        System.out.println("Code128SubType: " + code128DataPortion.getCode128SubType());
        System.out.println("Data:" + code128DataPortion.getData());
    }
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 15 with BarCodeReader

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

the class ReadBarcodeFromSpecificRegionOfImage method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(ReadBarcodeFromSpecificRegionOfImage.class) + "BarcodeReader/advanced_features/";
    // Open the stream. Read only access is enough for Aspose.BarCode to load an image.
    InputStream stream = new FileInputStream(dataDir + "specificRegion.png");
    // Get BufferedImage with exact bar code only
    java.awt.image.BufferedImage img = javax.imageio.ImageIO.read(new java.io.File(dataDir));
    // Create an instance of BarCodeReader class
    // and specify an area to look for the barcode
    BarCodeReader reader = new BarCodeReader(img, new Rectangle(0, 0, 100, 50), com.aspose.barcode.barcoderecognition.DecodeType.PDF_417);
    // Read all barcodes in the provided area
    while (reader.read()) {
        // Display the codetext and symbology type of the barcode found
        System.out.println("Codetext: " + reader.getCodeText() + " Symbology: " + reader.getCodeType());
    }
    // Close the reader
    reader.close();
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Rectangle(java.awt.Rectangle) BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader) FileInputStream(java.io.FileInputStream)

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