Search in sources :

Example 16 with BarCodeReader

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

the class SwitchBarcodeRecognitionModes method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(SwitchBarcodeRecognitionModes.class) + "BarcodeReader/advanced_features/";
    // Create an instance of BarCodeReader and set image and symbology type to recognize
    BarCodeReader reader = new BarCodeReader(dataDir + "code39Extended.jpg", com.aspose.barcode.barcoderecognition.DecodeType.DATA_MATRIX);
    // Set recognition mode
    reader.setRecognitionMode(RecognitionMode.ManualHints);
    // Set manual hints
    reader.setManualHints(ManualHint.InvertImage | ManualHint.IncorrectBarcodes);
    // 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 17 with BarCodeReader

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

the class Barcode_Recognition method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(Barcode_Recognition.class) + "BarcodeReader/basic_features/";
    // Initialize barcode reader
    BarCodeReader rd = new BarCodeReader(dataDir + "CodeText.jpg");
    // 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("Symbology type: " + rd.getCodeType());
    }
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 18 with BarCodeReader

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

the class ApplyingChecksumForCodaBar method main.

public static void main(String[] args) {
    // ExStart:ApplyingChecksumValidation
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(ApplyingChecksumValidation.class) + "Barcode/AdvancedFeatures/";
    // Generation
    // Instantiate BarCodeBuilder object
    com.aspose.barcode.BarCodeBuilder builder = new com.aspose.barcode.BarCodeBuilder();
    // Set the Code text for the barcode
    builder.setCodeText("1234567890");
    // Set the symbology type to CodaBar
    builder.setEncodeType(com.aspose.barcode.EncodeTypes.CODABAR);
    // Set the EnableChecksum property to yes
    builder.setEnableChecksum(com.aspose.barcode.EnableChecksum.Yes);
    // Set the CodabarChecksumMode
    builder.setCodabarChecksumMode(com.aspose.barcode.CodabarChecksumMode.Mod10);
    // Save the image on the system
    builder.save("Codabar_Mod10.png");
    // Recognition
    // Initialize reader object
    BarCodeReader reader = new BarCodeReader("Codabar_Mod10.png", com.aspose.barcode.barcoderecognition.DecodeType.CODABAR);
    // Set ChecksumValidation property of the reader to On
    reader.setChecksumValidation(com.aspose.barcode.barcoderecognition.ChecksumValidation.On);
    while (reader.read()) {
        // Get code text
        System.out.println(" codetext: " + reader.getCodeText());
        // Get type of barcode
        System.out.println(" type: " + reader.getCodeType());
        // Get checksum value
        System.out.println(" Checksum: " + reader.getCheckSum());
    }
// ExEnd:ApplyingChecksumValidation
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

Example 19 with BarCodeReader

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

the class BarcodeOrientation method main.

public static void main(String[] args) throws Exception {
    ApplyALicense.applyALicense();
    // The path to the resource directory.
    String dataDir = Utils.getDataDir(BarcodeOrientation.class) + "BarcodeReader/advanced_features/";
    // Read code39 barcode from image
    String image = dataDir + "code39Extended.jpg";
    BarCodeReader reader = new BarCodeReader(image, com.aspose.barcode.barcoderecognition.DecodeType.CODE_39_STANDARD);
    // Set orientation
    reader.setOrientationHints(Orientation.Rotate90);
    // Try to recognize all possible barcodes in the image
    while (reader.read()) {
        System.err.println("Codetext: " + reader.getCodeText());
    }
    // Close reader
    reader.close();
}
Also used : BarCodeReader(com.aspose.barcode.barcoderecognition.BarCodeReader)

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