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);
}
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());
}
}
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();
}
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());
}
}
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();
}
Aggregations