Exemple #1
0
    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/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/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/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()