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