BarCodeReader
Inheritance: java.lang.Object
public class BarCodeReader
BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform ReadBarCodes operation to detect barcodes.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Constructors
Constructor | Description |
---|---|
BarCodeReader() | Initializes a new instance of the BarCodeReader class with default values. |
BarCodeReader(BufferedImage image) | Initializes a new instance of the BarCodeReader class from an image. |
BarCodeReader(BufferedImage image, BaseDecodeType decodeType) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(BufferedImage image, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(BufferedImage image, Rectangle area, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(BufferedImage image, Rectangle[] areas, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(String filename) | Initializes a new instance of the BarCodeReader class from file. |
BarCodeReader(String filename, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(String filename, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(InputStream stream) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(InputStream stream, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(InputStream stream, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
Methods
Method | Description |
---|---|
abort() | Function requests termination of current recognition session from other thread. |
dispose() | |
equals(Object arg0) | |
exportToXml(OutputStream xmlStream) | Exports BarCode properties to the xml-stream specified |
exportToXml(String xmlFile) | Exports BarCode properties to the xml-file specified |
getBarCodeDecodeType() | |
getBarcodeSettings() | The main BarCode decoding parameters. |
getChecksumValidation() | |
getClass() | |
getCustomerInformationInterpretingType() | Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER. |
getDetectEncoding() | A flag which force engine to detect codetext encoding for Unicode codesets. |
getFoundBarCodes() | Gets recognized BarCodeResult s array |
getFoundCount() | Gets recognized barcodes count |
getProcessorSettings() | Gets a settings of using processor cores. |
getQualitySettings() | QualitySettings allows to configure recognition quality and speed manually. |
getStripFNC() | Strip FNC1, FNC2, FNC3 characters from codetext. |
getTimeout() | Gets the timeout of recognition process in milliseconds. |
hashCode() | |
importFromXml(InputStream xmlStream) | Imports BarCode properties from the xml-stream specified and applies them to the current BarCodeReader instance. |
importFromXml(String xmlFile) | Imports BarCode properties from the xml-file specified and applies them to the current BarCodeReader instance. |
notify() | |
notifyAll() | |
readBarCodes() | Reads BarCodeResult s from the image. |
setBarCodeImage(BufferedImage value) | Sets bitmap image for recognition. |
setBarCodeImage(BufferedImage value, Rectangle area) | Sets bitmap image and area for recognition. |
setBarCodeImage(BufferedImage value, Rectangle[] areas) | Sets bitmap image and areas for recognition. |
setBarCodeImage(InputStream stream) | Sets image stream for recognition. |
setBarCodeImage(String filename) | Sets image file for recognition. |
setBarCodeReadType(BaseDecodeType type) | Sets decode type for recognition. |
setBarCodeReadType(SingleDecodeType[] barcodeTypes) | Sets SingleDecodeType type array for recognition. |
setChecksumValidation(ChecksumValidation value) | |
setChecksumValidation(int value) | Enable checksum validation during recognition for 1D barcodes. |
setCustomerInformationInterpretingType(CustomerInformationInterpretingType value) | Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER. |
setCustomerInformationInterpretingType(int value) | Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER. |
setDetectEncoding(boolean value) | A flag which force engine to detect codetext encoding for Unicode codesets. |
setQualitySettings(QualitySettings value) | QualitySettings allows to configure recognition quality and speed manually. |
setStripFNC(boolean value) | Strip FNC1, FNC2, FNC3 characters from codetext. |
setTimeout(int value) | Sets the timeout of recognition process in milliseconds. |
toString() | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
BarCodeReader()
public BarCodeReader()
Initializes a new instance of the BarCodeReader class with default values. Requires to set image (SetBitmapImage()) before to call ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader(); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage("c:\\test.png"); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
BarCodeReader(BufferedImage image)
public BarCodeReader(BufferedImage image)
Initializes a new instance of the BarCodeReader class from an image.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(bmp); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | A Bitmap instance containing the image |
BarCodeReader(BufferedImage image, BaseDecodeType decodeType)
public BarCodeReader(BufferedImage image, BaseDecodeType decodeType)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(bmp, new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The image. |
decodeType | BaseDecodeType | The decode type1. It can be single or multy |
BarCodeReader(BufferedImage image, BaseDecodeType[] decodeTypes)
public BarCodeReader(BufferedImage image, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(bmp, DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The image. |
decodeTypes | BaseDecodeType[] | Decode types. |
BarCodeReader(BufferedImage image, Rectangle area, BaseDecodeType[] decodeTypes)
public BarCodeReader(BufferedImage image, Rectangle area, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()), DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The image. |
area | java.awt.Rectangle | The area for recognition. |
decodeTypes | BaseDecodeType[] | Decode types. |
BarCodeReader(BufferedImage image, Rectangle[] areas, BaseDecodeType type)
public BarCodeReader(BufferedImage image, Rectangle[] areas, BaseDecodeType type)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()), new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
image | java.awt.image.BufferedImage | The image. |
areas | java.awt.Rectangle[] | The area for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(String filename)
public BarCodeReader(String filename)
Initializes a new instance of the BarCodeReader class from file.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader("c:\\test.png"); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The filename. |
BarCodeReader(String filename, BaseDecodeType type)
public BarCodeReader(String filename, BaseDecodeType type)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader("c:\\test.png", new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The filename. |
type | BaseDecodeType | The decode type. |
BarCodeReader(String filename, BaseDecodeType[] decodeTypes)
public BarCodeReader(String filename, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The filename. |
decodeTypes | BaseDecodeType[] | Decode types. |
BarCodeReader(InputStream stream)
public BarCodeReader(InputStream stream)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. InputStream fstr = new FileInputStream(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(fstr); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The stream. |
BarCodeReader(InputStream stream, BaseDecodeType type)
public BarCodeReader(InputStream stream, BaseDecodeType type)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. InputStream fstr = new FileInputStream("c:\\test.png"); BarCodeReader reader = new BarCodeReader(fstr, new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The stream. |
type | BaseDecodeType | The decode type. |
BarCodeReader(InputStream stream, BaseDecodeType[] decodeTypes)
public BarCodeReader(InputStream stream, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. InputStream fstr = new FileInputStream("c:\\test.png")); BarCodeReader reader = new BarCodeReader(fstr, DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The stream. |
decodeTypes | BaseDecodeType[] | Decode types. |
abort()
public void abort()
Function requests termination of current recognition session from other thread. Abort is unblockable method and returns control just after calling. The method should be used when recognition process is too long.
This sample shows how to call Abort function from other thread final BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); Thread thread1 = new Thread(new Runnable() { public void run() { for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeType()); System.out.println("BarCode CodeText: " + result.getCodeText()); } } }); thread1.start(); Thread.sleep(100); reader.abort();
dispose()
public void dispose()
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
exportToXml(OutputStream xmlStream)
public boolean exportToXml(OutputStream xmlStream)
Exports BarCode properties to the xml-stream specified
Parameters:
Parameter | Type | Description |
---|---|---|
xmlStream | java.io.OutputStream | The xml-stream for saving |
Returns: boolean - Whether or not export completed successfully.
Returns True in case of success; False Otherwise
exportToXml(String xmlFile)
public boolean exportToXml(String xmlFile)
Exports BarCode properties to the xml-file specified
Parameters:
Parameter | Type | Description |
---|---|---|
xmlFile | java.lang.String | The name of the file |
Returns: boolean - Whether or not export completed successfully.
Returns True in case of success; False Otherwise
getBarCodeDecodeType()
public BaseDecodeType getBarCodeDecodeType()
Returns: BaseDecodeType
getBarcodeSettings()
public BarcodeSettings getBarcodeSettings()
The main BarCode decoding parameters. Contains parameters which make influence on recognized data.
Returns: BarcodeSettings - The main BarCode decoding parameters
getChecksumValidation()
public ChecksumValidation getChecksumValidation()
Enable checksum validation during recognition for 1D barcodes.
Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible.
Checksum never used: Codabar
Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN
Checksum always used: Rest symbologies
This sample shows influence of ChecksumValidation on recognition quality and results BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128"); generator.save("c:\\test.png"); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13); //checksum disabled reader.setChecksumValidation(ChecksumValidation.OFF); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue()); System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); } BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13); //checksum enabled reader.setChecksumValidation(ChecksumValidation.ON); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue()); System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); }
Value: The checksum validation flag.
Returns: ChecksumValidation
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class>
getCustomerInformationInterpretingType()
public CustomerInformationInterpretingType getCustomerInformationInterpretingType()
Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.
Returns: CustomerInformationInterpretingType
getDetectEncoding()
public boolean getDetectEncoding()
A flag which force engine to detect codetext encoding for Unicode codesets.
This sample shows how to detect text encoding on the fly if DetectEncoding is enabled ByteArrayOutputStream ms = new ByteArrayOutputStream(); BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "\ufffd\ufffd\ufffd\ufffd\ufffd")) generator.getParameters().getBarcode().getQR().setCodeTextEncoding(Charset.forName("UTF-8"); generator.save(ms, BarCodeImageFormat.getPng()); //detects encoding for Unicode codesets is enabled BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR); reader.setDetectEncoding(true); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); //detect encoding is disabled BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR); reader.setDetectEncoding(false); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText());
Returns: boolean
getFoundBarCodes()
public BarCodeResult[] getFoundBarCodes()
Gets recognized BarCodeResult s array
This sample shows how to read barcodes with BarCodeReader BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); { reader.readBarCodes(); for(int i = 0; reader.getFoundCount() > i; ++i) System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText()); }
Value: The recognized BarCodeResult s array
Returns: com.aspose.barcode.barcoderecognition.BarCodeResult[]
getFoundCount()
public int getFoundCount()
Gets recognized barcodes count
This sample shows how to read barcodes with BarCodeReader BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.readBarCodes(); for(int i = 0; reader.getFoundCount() > i; ++i) System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
Value: The recognized barcodes count
Returns: int
getProcessorSettings()
public static ProcessorSettings getProcessorSettings()
Gets a settings of using processor cores.
This sample shows how to use ProcessorSettings to add maximum multi-threaded performnce //this allows to use all cores for single BarCodeReader call BarCodeReader.getProcessorSettings().setUseAllCores(true); //this allows to use current count of cores BarCodeReader.getProcessorSettings().setUseAllCores(false); BarCodeReader.getProcessorSettings().setUseOnlyThisCoresCount(Math.max(1, Environment.getProcessorCount() / 2));
Returns: ProcessorSettings
getQualitySettings()
public final QualitySettings getQualitySettings()
QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.
This sample shows how to use QualitySettings with BarCodeReader BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //normal quality mode is set by default for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText());
Value: QualitySettings to configure recognition quality and speed.
Returns: QualitySettings
getStripFNC()
public boolean getStripFNC()
Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.
This sample shows how to strip FNC characters BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754")) generator.save("c:\\test.png"); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128); //StripFNC disabled reader.setStripFNC(false); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); } BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128); //StripFNC enabled reader.setStripFNC(true); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); }
Returns: boolean
getTimeout()
public int getTimeout()
Gets the timeout of recognition process in milliseconds.
BarCodeReader reader = new BarCodeReader("c:\\test.png");
reader.setTimeout(5000);
for(BarCodeResult result : reader.readBarCodes())
System.out.println("BarCode CodeText: " + result.getCodeText());
Returns: int - The timeout.
hashCode()
public native int hashCode()
Returns: int
importFromXml(InputStream xmlStream)
public static BarCodeReader importFromXml(InputStream xmlStream)
Imports BarCode properties from the xml-stream specified and applies them to the current BarCodeReader instance.
Parameters:
Parameter | Type | Description |
---|---|---|
xmlStream | java.io.InputStream | The xml-stream for loading |
Returns: BarCodeReader - Returns True in case of success;
False Otherwise
importFromXml(String xmlFile)
public static BarCodeReader importFromXml(String xmlFile)
Imports BarCode properties from the xml-file specified and applies them to the current BarCodeReader instance.
Parameters:
Parameter | Type | Description |
---|---|---|
xmlFile | java.lang.String | The name of the file |
Returns: BarCodeReader - Returns True in case of success;
False Otherwise
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
readBarCodes()
public BarCodeResult[] readBarCodes()
Reads BarCodeResult s from the image.
This sample shows how to read barcodes with BarCodeReader BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.readBarCodes(); for(int i = 0; reader.getFoundCount() > i; ++i) System.out.println("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());
Returns: com.aspose.barcode.barcoderecognition.BarCodeResult[] - Returns array of recognized BarCodeResult s on the image. If nothing is recognized, zero array is returned.
setBarCodeImage(BufferedImage value)
public void setBarCodeImage(BufferedImage value)
Sets bitmap image for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader()) { reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage(bmp); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); } }
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.awt.image.BufferedImage | The bitmap image for recognition. |
setBarCodeImage(BufferedImage value, Rectangle area)
public final void setBarCodeImage(BufferedImage value, Rectangle area)
Sets bitmap image and area for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage(bmp, new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight())); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.awt.image.BufferedImage | The bitmap image for recognition. |
area | java.awt.Rectangle | area for recognition |
setBarCodeImage(BufferedImage value, Rectangle[] areas)
public final void setBarCodeImage(BufferedImage value, Rectangle[] areas)
Sets bitmap image and areas for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BufferedImage bmp = ImageIO.read(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage(bmp, new Rectangle[] { new Rectangle(0, 0, bmp.getWidth(), bmp.getHeight()) }); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.awt.image.BufferedImage | The bitmap image for recognition. |
areas | java.awt.Rectangle[] | areas list for recognition |
setBarCodeImage(InputStream stream)
public final void setBarCodeImage(InputStream stream)
Sets image stream for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. InputStream fstr = new FileInputStream(new File("c:\\test.png")); BarCodeReader reader = new BarCodeReader(); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage(fstr); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
stream | java.io.InputStream | The image stream for recogniton. |
setBarCodeImage(String filename)
public void setBarCodeImage(String filename)
Sets image file for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader()) { reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage("c:\\test.png"); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); } }
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | The image file for recogniton. |
setBarCodeReadType(BaseDecodeType type)
public void setBarCodeReadType(BaseDecodeType type)
Sets decode type for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader()) reader.setBarCodeReadType(new MultyDecodeType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage("c:\\test.png"); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
type | BaseDecodeType | The type of barcode to read. |
setBarCodeReadType(SingleDecodeType[] barcodeTypes)
public void setBarCodeReadType(SingleDecodeType[] barcodeTypes)
Sets SingleDecodeType type array for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. BarCodeReader reader = new BarCodeReader(); reader.setBarCodeReadType(DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); reader.setBarCodeImage("c:\\test.png"); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
barcodeTypes | SingleDecodeType[] | The SingleDecodeType type array to read. |
setChecksumValidation(ChecksumValidation value)
public void setChecksumValidation(ChecksumValidation value)
Enable checksum validation during recognition for 1D barcodes.
Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible.
Checksum never used: Codabar
Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN
Checksum always used: Rest symbologies
This sample shows influence of ChecksumValidation on recognition quality and results BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128"); generator.save("c:\\test.png"); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13); //checksum disabled reader.setChecksumValidation(ChecksumValidation.OFF); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue()); System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); } BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.EAN_13); { //checksum enabled reader.setChecksumValidation(ChecksumValidation.ON); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); System.out.println("BarCode Value: " + result.getExtended().getOneD().getValue()); System.out.println("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); } }
Value: The checksum validation flag.
Parameters:
Parameter | Type | Description |
---|---|---|
value | ChecksumValidation |
setChecksumValidation(int value)
public void setChecksumValidation(int value)
Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The checksum validation flag. |
setCustomerInformationInterpretingType(CustomerInformationInterpretingType value)
public void setCustomerInformationInterpretingType(CustomerInformationInterpretingType value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.
Parameters:
Parameter | Type | Description |
---|---|---|
value | CustomerInformationInterpretingType |
setCustomerInformationInterpretingType(int value)
public void setCustomerInformationInterpretingType(int value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
setDetectEncoding(boolean value)
public void setDetectEncoding(boolean value)
A flag which force engine to detect codetext encoding for Unicode codesets.
This sample shows how to detect text encoding on the fly if DetectEncoding is enabled ByteArrayOutputStream ms = new ByteArrayOutputStream(); BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "\ufffd\ufffd\ufffd\ufffd\ufffd"); generator.getParameters().getBarcode().getQR().setCodeTextEncoding(Charset.forName("UTF-8"); generator.save(ms, BarCodeImageFormat.getPng()); //detects encoding for Unicode codesets is enabled BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR); reader.setDetectEncoding(true); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); //detect encoding is disabled BarCodeReader reader = new BarCodeReader(new ByteArrayInputStream(ms.toByteArray()), DecodeType.QR); reader.setDetectEncoding(true); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText());
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setQualitySettings(QualitySettings value)
public final void setQualitySettings(QualitySettings value)
QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.
This sample shows how to use QualitySettings with BarCodeReader BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //normal quality mode is set by default for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText()); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); for(BarCodeResult result : reader.readBarCodes()) System.out.println("BarCode CodeText: " + result.getCodeText());
Value: QualitySettings to configure recognition quality and speed.
Parameters:
Parameter | Type | Description |
---|---|---|
value | QualitySettings |
setStripFNC(boolean value)
public void setStripFNC(boolean value)
Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.
This sample shows how to strip FNC characters BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754"); generator.save("c:\\test.png"); BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128); //StripFNC disabled reader.setStripFNC(false); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); } BarCodeReader reader = new BarCodeReader("c:\\test.png", DecodeType.CODE_128); //StripFNC enabled reader.setStripFNC(true); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode CodeText: " + result.getCodeText()); }
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setTimeout(int value)
public void setTimeout(int value)
Sets the timeout of recognition process in milliseconds.
BarCodeReader reader = new BarCodeReader("c:\\test.png");
reader.setTimeout(5000);
for(BarCodeResult result : reader.readBarCodes())
System.out.println("BarCode CodeText: " + result.getCodeText());
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The timeout. |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |