public class BarCodeReader
extends java.lang.Object
BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform Read operation to detect barcodes
Detect an code39 barcode with supplement.BarCodeReader reader; reader = new BarCodeReader("test.jpg",BarCodeReadType.Code39Standard); while(reader.read()) { System.out.println("BarCode Type: "+reader.getReadType()); System.out.println("BarCode CodeText: " + reader.getCodeText()); } reader.close();
Constructor and Description |
---|
BarCodeReader()
Initializes a new instance of the
BarCodeReader class with default values. |
BarCodeReader(java.awt.image.BufferedImage image)
Initializes a new instance of the
BarCodeReader class from an image. |
BarCodeReader(java.awt.image.BufferedImage image,
BaseDecodeType... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.awt.image.BufferedImage image,
java.awt.Rectangle[] areas,
BaseDecodeType type)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.awt.image.BufferedImage image,
java.awt.Rectangle area,
BaseDecodeType... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.io.InputStream stream)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.io.InputStream stream,
BaseDecodeType... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.io.InputStream stream,
BaseDecodeType type)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.lang.String filename)
Initializes a new instance of the
BarCodeReader class from file. |
BarCodeReader(java.lang.String filename,
BaseDecodeType... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(java.lang.String filename,
BaseDecodeType type)
Initializes a new instance of the
BarCodeReader class. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes barcode reader.
|
void |
dispose() |
boolean |
exportToXml(java.lang.String xmlFile)
Exports BarCode properties to the xml-file specified |
float |
getAngle()
Gets the angle of the barcode (0-360).
|
BaseDecodeType |
getBarCodeDecodeType() |
java.lang.String |
getCheckSum()
Gets the checksum for 1D barcodes.
|
ChecksumValidation |
getChecksumValidation() |
Code128DataPortion[] |
getCode128DataPortions()
Gets Code128DataPortion instance for recognized Code128 barcode
|
byte[] |
getCodeBytes()
Gets the encoded code bytes.
|
java.lang.String |
getCodeText()
Gets the code text.
|
java.lang.String |
getCodeText(boolean includeCheckSum)
Gets the code text.
|
java.lang.String |
getCodeText(java.nio.charset.Charset encoding)
Gets the code text with encoding.
|
SingleDecodeType |
getCodeType()
Gets the barcode type.
|
java.lang.String |
getCodeTypeName()
Gets the name of the barcode type.
|
CustomerInformationInterpretingType |
getCustomerInformationInterpretingType()
Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
|
boolean |
getDetectEncoding()
Gets flag to detect codetext encoding for unicode codesets.
|
java.lang.String |
getFileName()
Gets file name which was assigned by user
|
boolean |
getIsDeniable()
Checks the deniable recognition.
|
java.lang.String |
getMacroPdf417FileID()
Gets the file ID of the barcode, only available with MacroPdf417.
|
int |
getMacroPdf417SegmentID()
Gets the segment ID of the barcode,only available with MacroPdf417.
|
int |
getMacroPdf417SegmentsCount()
Gets macro pdf417 barcode segments count.
|
int |
getManualHints()
Deprecated.
Use QualitySettings instead.
|
java.lang.String |
getManualHintsName()
Gets name of ManualHints property
|
int |
getMedianSmoothingWindowSize()
Deprecated.
Use QualitySettings.getMedianSmoothingWindowSize() instead.
|
static ProcessorSettings |
getProcessorSettings()
Gets a settings of using processor cores.
|
int |
getQRStructuredAppendModeBarCodeIndex()
Gets the index of the QR structured append mode barcode.
|
int |
getQRStructuredAppendModeBarCodesQuantity()
Gets the QR structured append mode barcodes quantity.
|
int |
getQRStructuredAppendModeParityData()
Gets the QR structured append mode parity data.
|
com.aspose.barcode.barcoderecognition.QualitySettings |
getQualitySettings()
QualitySettings allows to configure recognition quality and speed manually.
|
int |
getRecognitionMode()
Deprecated.
Use QualitySettings instead.
|
java.lang.String |
getRecognitionModeName()
Gets the RecognitionMode's name
|
float |
getRecognitionQuality()
Gets the recognition quality.
|
BarCodeRegion |
getRegion()
Gets the barcode region.
|
boolean |
getStripFNC()
Strip FNC1, FNC2, FNC3 characters from codetext.
|
int |
getTimeout()
Gets the timeout of recognition process.
|
static BarCodeReader |
importFromXml(java.lang.String xmlFile)
Imports BarCode properties from the xml-file specified and applies them to the current BarCodeBuilder instance.
|
boolean |
isLicensed()
Gets a value indicating whether recognition module is licensed.
|
boolean |
read()
Reads barcode from the image.
|
void |
setBarCodeImage(java.awt.image.BufferedImage value)
Sets bitmap image for recognition.
|
void |
setBarCodeImage(java.awt.image.BufferedImage value,
java.awt.Rectangle area)
Sets bitmap image and area for recognition.
|
void |
setBarCodeImage(java.awt.image.BufferedImage value,
java.awt.Rectangle[] areas)
Sets bitmap image and areas for recognition.
|
void |
setBarCodeImage(java.io.InputStream stream)
Sets image stream for recognition.
|
void |
setBarCodeImage(java.lang.String filename)
Sets image file for recogniton.
|
void |
setBarCodeReadType(BaseDecodeType type)
Sets BarCodeReadType for recognition.
|
void |
setChecksumValidation(ChecksumValidation value)
Enable checksum validation during recognition for 1D barcodes.
|
void |
setChecksumValidation(int value)
Deprecated.
|
void |
setCustomerInformationInterpretingType(CustomerInformationInterpretingType value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
|
void |
setCustomerInformationInterpretingType(int value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
|
void |
setDetectEncoding(boolean value)
Sets flag to detect codetext encoding for unicode codesets.
|
void |
setManualHints(int value)
Deprecated.
Use QualitySettings instead.
|
void |
setMedianSmoothingWindowSize(int value)
Deprecated.
Use QualitySettings.setMedianSmoothingWindowSize(int) instead.
|
void |
setQualitySettings(com.aspose.barcode.barcoderecognition.QualitySettings value)
QualitySettings allows to configure recognition quality and speed manually.
|
void |
setRecognitionMode(int value)
Deprecated.
Use QualitySettings instead.
|
void |
setStripFNC(boolean value)
Strip FNC1, FNC2, FNC3 characters from codetext.
|
void |
setTimeout(int value)
Sets the timeout of recognition process.
|
public BarCodeReader()
Initializes a new instance of the BarCodeReader
class with default values.
Requires to set image setBitmapImage() before to call read() method.
public BarCodeReader(java.awt.image.BufferedImage image)
Initializes a new instance of the BarCodeReader
class from an image.
image
- A Bitmap instance containing the imagepublic BarCodeReader(java.awt.image.BufferedImage image, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
image
- The image.decodeTypes
- Decode types.public BarCodeReader(java.awt.image.BufferedImage image, java.awt.Rectangle area, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
image
- The image.area
- The area for recognition.decodeTypes
- Decode types.public BarCodeReader(java.awt.image.BufferedImage image, java.awt.Rectangle[] areas, BaseDecodeType type)
BarCodeReader
class.image
- The image to read.areas
- The array of recognition areas.type
- The decode type applicable for all the areas specified.public BarCodeReader(java.lang.String filename)
Initializes a new instance of the BarCodeReader
class from file.
filename
- The filename.public BarCodeReader(java.lang.String filename, BaseDecodeType type)
Initializes a new instance of the BarCodeReader
class.
filename
- The filename.type
- The BarCodeReadType.public BarCodeReader(java.lang.String filename, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
filename
- The filename.decodeTypes
- Decode types.public BarCodeReader(java.io.InputStream stream)
Initializes a new instance of the BarCodeReader
class.
stream
- The stream.public BarCodeReader(java.io.InputStream stream, BaseDecodeType type)
Initializes a new instance of the BarCodeReader
class.
stream
- The stream.type
- The decode type.public BarCodeReader(java.io.InputStream stream, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
stream
- The stream.decodeTypes
- Decode types.public boolean isLicensed()
Gets a value indicating whether recognition module is licensed.
public static ProcessorSettings getProcessorSettings()
public java.lang.String getFileName()
public int getTimeout()
Gets the timeout of recognition process.
public void setTimeout(int value)
Sets the timeout of recognition process.
value
- The timeout.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
public void setChecksumValidation(ChecksumValidation value)
value
- The checksum validation flag.@Deprecated public void setChecksumValidation(int value)
value
- The checksum validation flag.@Deprecated public int getMedianSmoothingWindowSize()
Gets the median smoothing window size. Typical values are 3 or 4. Default value is 3. Recognition hint MedianSmoothing must be set. At this version a value is directly mirrored to QualitySettings.
@Deprecated public void setMedianSmoothingWindowSize(int value)
Sets the median smoothing window size. Typical values are 3 or 4. Default value is 3. Recognition hint MedianSmoothing must be set. At this version a value is directly mirrored to QualitySettings.
value
- The median smoothing window size. Typical values are 3 or 4. Default value is 3.public boolean getStripFNC()
Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.
public void setStripFNC(boolean value)
Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.
public CustomerInformationInterpretingType getCustomerInformationInterpretingType()
Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
public void setCustomerInformationInterpretingType(CustomerInformationInterpretingType value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
public void setCustomerInformationInterpretingType(int value)
Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.Other.
public void close()
Closes barcode reader.
public boolean read()
Reads barcode from the image.
Detect AllSupportedTypesBarCodeReader reader; reader = new BarCodeReader("c:\\test.jpg"); while(reader.read()) { System.out.println("BarCode Type: "+reader.getReadType()); System.out.println("BarCode CodeText: " + reader.getCodeText()); } reader.close();
public final com.aspose.barcode.barcoderecognition.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.
Value: QualitySettings to configure recognition quality and speed.This sample shows how to use QualitySettings with BarCodeReaderBarCodeReader reader = new BarCodeReader("test.png"); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); } BarCodeReader reader = new BarCodeReader("test.png"); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); } BarCodeReader reader = new BarCodeReader("test.png"); //default mode is NormalQuality //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); }
public final void setQualitySettings(com.aspose.barcode.barcoderecognition.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.
Value: QualitySettings to configure recognition quality and speed.This sample shows how to use QualitySettings with BarCodeReaderBarCodeReader reader = new BarCodeReader("test.png"); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); } BarCodeReader reader = new BarCodeReader("test.png"); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); } BarCodeReader reader = new BarCodeReader("test.png"); //default mode is NormalQuality //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); while (reader.read()) { System.out.println("BarCode CodeText: " + reader.getCodeText()); }
@Deprecated public int getRecognitionMode()
Gets or sets the recognition mode. This property allows to quickly set up and tune the processing speed and quality in a way which is the most appropriate for you needs. Default value is MaxPerformance. At this version a value is directly mirrored to QualitySettings.
public java.lang.String getRecognitionModeName()
Gets the RecognitionMode's name
@Deprecated public void setRecognitionMode(int value)
Gets or sets the recognition mode. This property allows to quickly set up and tune the processing speed and quality in a way which is the most appropriate for you needs.
value
- The recognition mode. Default value is MaxPerformance.@Deprecated public int getManualHints()
Allows you to configure options of recognition accuracy and speed manually. You need to change the property "RecognitionMode" to "RecognitionMode.ManualHints". Default value is None.
reader.setRecognitionMode(RecognitionMode.ManualHints); reader.setManualHints(ManualHint.InvertImage| ManualHint.IncorrectBarcodes);
public java.lang.String getManualHintsName()
Gets name of ManualHints property
@Deprecated public void setManualHints(int value)
Allows you to configure options of recognition accuracy and speed manually. You need to change the property "RecognitionMode" to "RecognitionMode.ManualHints". Default value is None.
reader.setRecognitionMode(RecognitionMode.ManualHints); reader.setManualHints(ManualHint.InvertImage| ManualHint.IncorrectBarcodes);
value
- The manual hints. Default value is None.public java.lang.String getCodeText()
Gets the code text. Text will not contain the checksum for 1D barcode types, which support the checksum. Please use GetCodeText(true) method to get result with checksum.
public java.lang.String getCodeText(java.nio.charset.Charset encoding)
Gets the code text with encoding.
encoding
- The encoding for codetext.public java.lang.String getCodeText(boolean includeCheckSum)
includeCheckSum
- true to include CheckSum into result; false to return only CodeText.public java.lang.String getCheckSum()
Gets the checksum for 1D barcodes.
public float getAngle()
Gets the angle of the barcode (0-360).
public byte[] getCodeBytes()
Gets the encoded code bytes.
public java.lang.String getMacroPdf417FileID()
Gets the file ID of the barcode, only available with MacroPdf417.
public int getMacroPdf417SegmentID()
Gets the segment ID of the barcode,only available with MacroPdf417.
public int getMacroPdf417SegmentsCount()
Gets macro pdf417 barcode segments count. Default value is -1.
public Code128DataPortion[] getCode128DataPortions()
Code128DataPortion
objects.public int getQRStructuredAppendModeBarCodesQuantity()
Gets the QR structured append mode barcodes quantity. Default value is -1.
public int getQRStructuredAppendModeBarCodeIndex()
Gets the index of the QR structured append mode barcode. Index starts from 0. Default value is -1.
public int getQRStructuredAppendModeParityData()
Gets the QR structured append mode parity data. Default value is -1.
public boolean getIsDeniable()
Checks the deniable recognition. Such recognition might occur in max count mode decoding or use ManualHint.IncorrectBarcodes
public BarCodeRegion getRegion()
Gets the barcode region.
public SingleDecodeType getCodeType()
Gets the barcode type.
public java.lang.String getCodeTypeName()
Gets the name of the barcode type.
public float getRecognitionQuality()
Gets the recognition quality. Works for 1D and postal barcodes.
public boolean getDetectEncoding()
Gets flag to detect codetext encoding for unicode codesets.
public void setDetectEncoding(boolean value)
Sets flag to detect codetext encoding for unicode codesets.
Detection text encoding on the fly if DetectEncoding is enabledInputStream is = new ByteArrayInputStream(new byte[...]); BarCodeBuilder bb = new BarCodeBuilder(); bb.setCodeText(""); bb.setEncodeType(EncdeTypes.QR); bb.setCodeTextEncoding(Encoding.UTF8); bb.save(is, BarCodeImageFormat.Png); BarCodeReader reader = new BarCodeReader(is, BarCodeReadType.QR); reader.setDetectEncoding(true); while(reader.read()) System.out.println("BarCode CodeText: " + reader.GetCodeText()); is.setPosition(0); BarCodeReader reader1 = new BarCodeReader(is, BarCodeReadType.QR); reader1.setDetectEncoding(false); while(reader1.read()) System.out.println("BarCode CodeText: " + reader1.GetCodeText(Encoding.UTF8));
value
- The flag to detect codetext encoding.public final void setBarCodeImage(java.awt.image.BufferedImage value, java.awt.Rectangle[] areas)
Sets bitmap image and areas for recognition. Must be called before Read() method.
value
- The bitmap image for recognition.areas
- areas list for recognitionpublic final void setBarCodeImage(java.awt.image.BufferedImage value, java.awt.Rectangle area)
Sets bitmap image and area for recognition. Must be called before Read() method.
value
- The bitmap image for recognition.area
- area for recognitionpublic final void setBarCodeImage(java.io.InputStream stream)
Sets image stream for recognition. Must be called before Read() method.
stream
- The image stream for recogniton.public void setBarCodeImage(java.awt.image.BufferedImage value)
Sets bitmap image for recognition. Must be called before Read() method.
value
- The bitmap image for recognition.public void setBarCodeImage(java.lang.String filename)
Sets image file for recogniton. Must be called before Read() method.
filename
- The image file for recogniton.public void setBarCodeReadType(BaseDecodeType type)
Sets BarCodeReadType for recognition. Must be called before Read() method.
type
- The type of barcode to read.public void dispose()
public BaseDecodeType getBarCodeDecodeType()
public boolean exportToXml(java.lang.String xmlFile)
Exports BarCode properties to the xml-file specified
xmlFile
- The name for the fileReturns <b>True</b>
in case of success; <b>False</b>
Otherwise
public static BarCodeReader importFromXml(java.lang.String xmlFile)
Imports BarCode properties from the xml-file specified and applies them to the current BarCodeBuilder instance.
xmlFile
- The name for the file<b>True</b>
in case of success; <b>False</b>
Otherwise