def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/MakingBarcodeRegions/' # initialize barcode reader img = dataDir + "barcode.jpg" barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Try to recognize all possible barcodes in the image while (reader.read()): # Display the symbology type print "BarCode Type: " print reader.getReadType() # Display the codetext print "BarCode CodeText: " print reader.getCodeText() # Get the barcode region region = reader.getRegion() if (region != ""): # Initialize an object of type BufferedImage to get the Graphics object imageIO = ImageIO bufferedImage = imageIO.read(File(img)) # Initialize graphics object from the image g = bufferedImage.getGraphics() color = Color # Initialize paint object p = GradientPaint(0, 0, color.red, 100, 100, color.pink, True) region.drawBarCodeEdges(g, color.RED) # Save the image imageIO.write(bufferedImage, "png", File(dataDir + "Code39StdOut.png")) # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/GetAllOneDBarcodes/' img = dataDir + "barcode+jpg" # initialize barcode reader barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Call read method reader.read() # Now get all possible barcodes barcodes = reader.getAllPossibleBarCodes() i = 0 while(java_values(i < strlen(barcodes))): # Display code text, symbology, detected angle, recognition percentage of the barcode print "Code Text: " + barcodes[i].getCodetext() + " Symbology: " + barcodes[i].getBarCodeReadType() + " Recognition percentage: " + barcodes[i].getAngle() # Display x and y coordinates of barcode detected point = barcodes[i].getRegion().getPoints() print "Top left coordinates: X = " + point[0].getX() + ", Y = " + point[0].getY() print "Bottom left coordinates: X = " + point[1].getX() + ", Y = " + point[1].getY() print "Bottom right coordinates: X = " + point[2].getX() + ", Y = " + point[2].getY() print "Top right coordinates: X = " + point[3].getX()+ ", Y = " + point[3].getY() break # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/GetBarcodeRegionInfo/' # initialize barcode reader img = dataDir + "barcode.jpg" barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Try to recognize all possible barcodes in the image while (reader . read()): # Get the region information region = reader.getRegion() if (region != ""): # Display x and y coordinates of barcode detected point = region.getPoints() print "Top left coordinates: X = " print point[0].x print ", Y = " print point[0].y print "Bottom left coordinates: X = " print point[1].x print ", Y = " print point[1].y print "Bottom right coordinates: X = " print point[2].x print ", Y = " print point[2].y print "Top right coordinates: X = " print point[3].x print ", Y = " print point[3].y print "Codetext: " + reader.getCodeText() # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/GetBarcodeRecognitionQuality/' img = dataDir + "barcode.jpg" # initialize barcode reader barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Call read method while (reader.read()): print "Barcode CodeText: " + reader.getCodeText() print " Barcode Type: " print reader.getReadType() percent = reader.getRecognitionQuality() print "Barcode Quality Percentage: " print percent # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/MakingBarcodeRegions/' # initialize barcode reader img = dataDir + "barcode.jpg" barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Try to recognize all possible barcodes in the image while (reader.read()): # Display the symbology type print "BarCode Type: " print reader.getReadType() # Display the codetext print "BarCode CodeText: " print reader.getCodeText() # Get the barcode region region = reader.getRegion() if (region != ""): # Initialize an object of type BufferedImage to get the Graphics object imageIO=ImageIO bufferedImage = imageIO . read(File(img)) # Initialize graphics object from the image g = bufferedImage . getGraphics() color = Color # Initialize paint object p = GradientPaint(0, 0, color.red, 100, 100, color.pink, True) region.drawBarCodeEdges(g, color.RED) # Save the image imageIO.write(bufferedImage, "png", File(dataDir + "Code39StdOut.png")) # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/ReadBarcodeFromSpecificRegion/' # Open the stream. Read only access is enough for Aspose.BarCode to load an image. stream = FileInputStream(dataDir + "test.png") # Create an instance of BarCodeReader class # and specify an area to look for the barcode barcode_reader_type = BarCodeReadType reader = BarCodeReader(stream, Rectangle(0, 0, 10, 50), barcode_reader_type.Code39Standard) # TRead all barcodes in the provided area while (reader.read()): # Display the codetext and symbology type of the barcode found print "Codetext: " print reader.getCodeText() print " Symbology: " print reader.getReadType() # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/RecognizeSpecificSymbology/' # initialize barcode reader img = dataDir + "barcode.jpg" barcode_reader_type = BarCodeReadType rd = BarCodeReader(img, barcode_reader_type.Code39Standard) # read barcode while (rd.read()): # print the code text, if barcode found print "CodeText: " print rd.getCodeText() # print the symbology type print "Type: " print rd.getReadType()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/GetAllOneDBarcodes/' img = dataDir + "barcode+jpg" # initialize barcode reader barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Call read method reader.read() # Now get all possible barcodes barcodes = reader.getAllPossibleBarCodes() i = 0 while (java_values(i < strlen(barcodes))): # Display code text, symbology, detected angle, recognition percentage of the barcode print "Code Text: " + barcodes[i].getCodetext( ) + " Symbology: " + barcodes[i].getBarCodeReadType( ) + " Recognition percentage: " + barcodes[i].getAngle() # Display x and y coordinates of barcode detected point = barcodes[i].getRegion().getPoints() print "Top left coordinates: X = " + point[0].getX( ) + ", Y = " + point[0].getY() print "Bottom left coordinates: X = " + point[1].getX( ) + ", Y = " + point[1].getY() print "Bottom right coordinates: X = " + point[2].getX( ) + ", Y = " + point[2].getY() print "Top right coordinates: X = " + point[3].getX( ) + ", Y = " + point[3].getY() break # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/GetBarcodeRegionInfo/' # initialize barcode reader img = dataDir + "barcode.jpg" barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Try to recognize all possible barcodes in the image while (reader.read()): # Get the region information region = reader.getRegion() if (region != ""): # Display x and y coordinates of barcode detected point = region.getPoints() print "Top left coordinates: X = " print point[0].x print ", Y = " print point[0].y print "Bottom left coordinates: X = " print point[1].x print ", Y = " print point[1].y print "Bottom right coordinates: X = " print point[2].x print ", Y = " print point[2].y print "Top right coordinates: X = " print point[3].x print ", Y = " print point[3].y print "Codetext: " + reader.getCodeText() # Close reader reader.close()
def __init__(self): dataDir = Settings.dataDir + 'WorkingWithBarcodeRecognition/AdvancedBarcodeRecognitionFeatures/SwitchBarcodeRecognitionModes/' img = dataDir + "barcode.jpg" # initialize barcode reader barcode_reader_type = BarCodeReadType reader = BarCodeReader(img, barcode_reader_type.Code39Standard) # Set recognition mode recognitionMode = RecognitionMode reader.setRecognitionMode(recognitionMode.ManualHints) # Set manual hints manualHint = ManualHint reader.setManualHints(manualHint.InvertImage) reader.setManualHints(manualHint.IncorrectBarcodes) # Call read method while (reader.read()): print "Barcode CodeText: " + reader.getCodeText() # Close reader reader.close()