public class BarCodeReader extends 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 supplementBarCodeReader reader; reader = new BarCodeReader("c:\\test.jpg",BarCodeReadType.Code39Standard); while(reader.read()) { System.out.println("BarCode Type: "+reader.getReadType()); System.out.println("BarCode CodeText: " + reader.getCodeText()); } reader.close();
Modifier and Type | Class and Description |
---|---|
static class |
BarCodeReader.PossibleBarCode
Describes possible barcode found.
|
Constructor and 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... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(BufferedImage image,
long type)
Initializes a new instance of the BarCodeReader class.
|
BarCodeReader(BufferedImage image,
Rectangle[] areas,
BaseDecodeType type) |
BarCodeReader(BufferedImage image,
Rectangle[] areas,
long type)
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 area,
long type)
Initializes a new instance of the BarCodeReader} class.
|
BarCodeReader(InputStream stream)
Initializes a new instance of the BarCodeReader} class.
|
BarCodeReader(InputStream stream,
BaseDecodeType... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(InputStream stream,
BaseDecodeType type)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(InputStream stream,
long type)
Initializes a new instance of the BarCodeReader} class.
|
BarCodeReader(InputStream stream,
Rectangle area,
long 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... decodeTypes)
Initializes a new instance of the
BarCodeReader class. |
BarCodeReader(String filename,
BaseDecodeType type)
Initializes a new instance of the BarCodeReader} class.
|
BarCodeReader(String filename,
long type)
Initializes a new instance of the BarCodeReader} class.
|
BarCodeReader(String filename,
Rectangle area,
long type)
Initializes a new instance of the BarCodeReader class.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes barcode reader.
|
boolean |
exportToXml(String xmlFile)
Exports BarCode properties to the xml-file specified
|
BarCodeReader.PossibleBarCode[] |
getAllPossibleBarCodes()
Gets all possible barcodes found.
|
float |
getAngle()
Gets the angle of the barcode (0-360).
|
long |
getBarCodeReadType() |
String |
getBarCodeReadTypeName()
Gets BarCodeReadType name which was assigned by user
|
String |
getCheckSum()
Gets the checksum for 1D barcodes.
|
int |
getChecksumValidation() |
byte[] |
getCodeBytes()
Gets the encoded code bytes.
|
String |
getCodeText()
Gets the code text.
|
String |
getCodeText(boolean includeCheckSum)
Gets the code text.
|
String |
getCodeText(Charset encoding)
Gets the code text with encoding.
|
SingleDecodeType |
getCodeType()
Gets the barcode type.
|
String |
getCodeTypeName()
Gets the name of the barcode type.
|
int |
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.
|
int |
getExpectedBarCodeCount()
Expected barcodes to be found.The reader will stop reading the image once it found barcodes more than this value.
|
String |
getFileName()
Gets file name which was assigned by user
|
int |
getImageBinarizationHints()
Deprecated.
|
boolean |
getIsDeniable()
Checks the deniable recognition.
|
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()
Allows you to configure options of recognition accuracy and speed manually.
|
String |
getManualHintsName()
Gets name of ManualHints property
|
int |
getMedianSmoothingWindowSize()
Gets the median smoothing window size.
|
int |
getOrientationHints()
Gets the orientation hints.
|
String |
getOrientationHintsName()
Gets name of OrientationHints property
|
static com.aspose.barcode.common.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.
|
long |
getReadType()
Deprecated.
|
String |
getReadTypeName() |
int |
getRecognitionMode()
Gets or sets the recognition mode.
|
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(String xmlFileName)
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(BufferedImage value)
Sets bitmap image for recognition.
|
void |
setBarCodeImage(String filename)
Sets image file for recogniton.
|
void |
setBarCodeReadType(BaseDecodeType type)
Sets BarCodeReadType for recognition.
|
void |
setBarCodeReadType(long type)
Deprecated.
|
void |
setChecksumValidation(int value)
Enable checksum validation during recognition for 1D barcodes.
|
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 |
setExpectedBarCodeCount(int value)
Expected barcodes to be found.The reader will stop reading the image once it found barcodes more than this value.
|
void |
setImageBinarizationHints(int value)
Deprecated.
|
void |
setManualHints(int value)
Allows you to configure options of recognition accuracy and speed manually.
|
void |
setMedianSmoothingWindowSize(int value)
Sets the median smoothing window size.
|
void |
setOrientationHints(int value)
Sets the orientation hints.
|
void |
setRecognitionMode(int value)
Gets or sets the recognition mode.
|
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(BufferedImage image)
Initializes a new instance of the BarCodeReader} class from an image.
image
- A Bitmap instance containing the imagepublic BarCodeReader(BufferedImage image, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
image
- The image.decodeTypes
- Decode types.public BarCodeReader(BufferedImage image, long type)
Initializes a new instance of the BarCodeReader class.
image
- The image.type
- The BarCodeReadType.public BarCodeReader(String filename, Rectangle area, long type)
filename
- The image.area
- The area for recognition.type
- The BarCodeReadType.public BarCodeReader(BufferedImage image, Rectangle area, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
<b>This constructor overload is not supported in compact framework.</b>
image
- The image.area
- The area for recognition.decodeTypes
- Decode types.public BarCodeReader(BufferedImage image, Rectangle[] areas, BaseDecodeType type)
public BarCodeReader(InputStream stream, Rectangle area, long type)
Initializes a new instance of the BarCodeReader} class. Not support compact framework.}
stream
- The image stream.area
- The area for recognition.type
- The BarCodeReadType.public BarCodeReader(BufferedImage image, Rectangle area, long type)
Initializes a new instance of the BarCodeReader} class. Not support compact framework.}
image
- The image.area
- The area for recognition.type
- The BarCodeReadType.public BarCodeReader(BufferedImage image, Rectangle[] areas, long type)
Initializes a new instance of the BarCodeReader} class. Not support compact framework.}
image
- The image.areas
- Areas for recognition.type
- The BarCodeReadType.public BarCodeReader(String filename)
Initializes a new instance of the BarCodeReader} class from file.
filename
- The filename.public BarCodeReader(String filename, long type)
Initializes a new instance of the BarCodeReader} class.
filename
- The filename.type
- The BarCodeReadType.public BarCodeReader(String filename, BaseDecodeType type)
Initializes a new instance of the BarCodeReader} class.
filename
- The filename.type
- The BarCodeReadType.public BarCodeReader(String filename, BaseDecodeType... decodeTypes)
Initializes a new instance of the BarCodeReader
class.
filename
- The filename.decodeTypes
- Decode types.public BarCodeReader(InputStream stream)
Initializes a new instance of the BarCodeReader} class.
stream
- The stream.public BarCodeReader(InputStream stream, long type)
Initializes a new instance of the BarCodeReader} class.
stream
- The stream.type
- The The BarCodeReadType.public BarCodeReader(InputStream stream, BaseDecodeType type)
Initializes a new instance of the BarCodeReader
class.
stream
- The stream.type
- The decode type.public BarCodeReader(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.
Value: true} if recognition module is licensed; otherwise, false.public static com.aspose.barcode.common.ProcessorSettings getProcessorSettings()
public String getFileName()
public int getTimeout()
Gets the timeout of recognition process.
Value: The timeout.public void setTimeout(int value)
Sets the timeout of recognition process.
Value: The timeout.public int 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
Value: The checksum validation flag.public void setChecksumValidation(int value)
value
- The checksum validation flag.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.
Value: The median smoothing window size. Typical values are 3 or 4. Default value is 3.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.
Value: The median smoothing window size. Typical values are 3 or 4. Default value is 3.public int getExpectedBarCodeCount()
Expected barcodes to be found.The reader will stop reading the image once it found barcodes more than this value. Default value is int.MaxValue.
public void setExpectedBarCodeCount(int value)
Expected barcodes to be found.The reader will stop reading the image once it found barcodes more than this value. Default value is int.MaxValue.
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 int getCustomerInformationInterpretingType()
Gets 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 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.
Value: The recognition mode. Default value is MaxPerformance.public String getRecognitionModeName()
Gets the RecognitionMode's name
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.public int getOrientationHints()
Gets the orientation hints.
Value: The orientation hints. Default value is NoRotate.public String getOrientationHintsName()
Gets name of OrientationHints property
public void setOrientationHints(int value)
Sets the orientation hints.
Value: The orientation hints. Default value is NoRotate.@Deprecated public int getImageBinarizationHints()
Gets the image binarization hints.
Value: The image binarization hints. Default value is None.@Deprecated public void setImageBinarizationHints(int value)
Sets the image binarization hints.
Value: The image binarization hints. Default value is None.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.
Value: The manual hints. Default value is None.reader.setRecognitionMode(RecognitionMode.ManualHints); reader.setManualHints(ManualHint.InvertImage| ManualHint.IncorrectBarcodes);
public String getManualHintsName()
Gets name of ManualHints property
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.
Value: The manual hints. Default value is None.reader.setRecognitionMode(RecognitionMode.ManualHints); reader.setManualHints(ManualHint.InvertImage| ManualHint.IncorrectBarcodes);
public 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 String getCodeText(Charset encoding)
Gets the code text with encoding.
encoding
- The encoding for codetext.public String getCodeText(boolean includeCheckSum)
includeCheckSum
- true to include CheckSum into result; false to return only CodeText.public String getCheckSum()
Gets the checksum for 1D barcodes.
public float getAngle()
Gets the angle of the barcode (0-360). RecognitionHints.Orientation enum does not included into the calculation.
public byte[] getCodeBytes()
Gets the encoded code bytes.
public 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 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 String getCodeTypeName()
Gets the name of the barcode type.
@Deprecated public long getReadType()
Gets the barcode type. Works correctly for first 62 symbologies only.
public String getReadTypeName()
public long getBarCodeReadType()
public String getBarCodeReadTypeName()
Gets BarCodeReadType name which was assigned by user
public float getRecognitionQuality()
Gets the recognition quality. Works for 1D and postal barcodes.
public BarCodeReader.PossibleBarCode[] getAllPossibleBarCodes()
Gets all possible barcodes found. Only for 1D barcodes. Includes correct answer if the barcode recognized fine.
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.setSymbologyType(Symbology.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 void setBarCodeImage(BufferedImage value)
Sets bitmap image for recognition. Must be called before Read() method.
value
- The bitmap image for recognition.public void setBarCodeImage(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.@Deprecated public void setBarCodeReadType(long type)
Sets BarCodeReadType for recognition. Must be called before Read() method.
type
- The type of barcode to read.public boolean exportToXml(String xmlFile)
Exports BarCode properties to the xml-file specified
xmlFile
- The name for the filepublic static BarCodeReader importFromXml(String xmlFileName)
Imports BarCode properties from the xml-file specified and applies them to the current BarCodeBuilder instance.
Copyright (c) 2002-2017 Aspose Pty Ltd. All Rights Reserved.