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,
long type)
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,
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,
long type)
Initializes a new instance of the BarCodeReader} class.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes barcode reader.
|
BarCodeReader.PossibleBarCode[] |
getAllPossibleBarCodes()
Gets all possible barcodes found.
|
float |
getAngle()
Gets the angle of the barcode (0-360).
|
long |
getBarCodeReadType() |
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(Charset encoding)
Gets the code text with encoding.
|
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.
|
int |
getImageBinarizationHints()
Gets the image binarization hints.
|
int |
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.
|
int |
getMedianSmoothingWindowSize()
Gets the median smoothing window size.
|
int |
getOrientationHints()
Gets the orientation hints.
|
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()
Gets the barcode type.
|
int |
getRecognitionMode()
Gets or sets the recognition mode.
|
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 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(long type)
Sets BarCodeReadType for recognition.
|
void |
setChecksumValidation(int value) |
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)
Sets the image binarization hints.
|
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, long type)
Initializes a new instance of the BarCodeReader} class.
image
- The image.type
- The BarCodeReadType.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(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(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 static boolean isLicensed()
Gets a value indicating whether recognition module is licensed.
Value: true} if recognition module is licensed; otherwise, false.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)
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 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.
Value: The recognition mode. Default value is MaxPerformance.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 void setOrientationHints(int value)
Sets the orientation hints.
Value: The orientation hints. Default value is NoRotate.public int getImageBinarizationHints()
Gets the image binarization hints.
Value: The image binarization hints. Default value is None.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. It needs change the property "RecognitionMode" to "RecognitionMode.ManualHints".
Value: The manual hints. Default value is None.[C#] reader.RecognitionMode = RecognitionMode.ManualHints; reader.ManualHints = ManualHint.InvertImage| ManualHint.IncorrectBarcodes; [VB.NET] reader.RecognitionMode = RecognitionMode.ManualHints reader.ManualHints = ManualHint.InvertImage Or ManualHint.IncorrectBarcodes
public void setManualHints(int value)
Allows you to configure options of recognition accuracy and speed manually. It needs change the property "RecognitionMode" to "RecognitionMode.ManualHints".
Value: The manual hints. Default value is None.[C#] reader.RecognitionMode = RecognitionMode.ManualHints; reader.ManualHints = ManualHint.InvertImage| ManualHint.IncorrectBarcodes; [VB.NET] reader.RecognitionMode = RecognitionMode.ManualHints reader.ManualHints = ManualHint.InvertImage Or ManualHint.IncorrectBarcodes
public String getCodeText()
Gets the code text.
public String getCodeText(Charset encoding)
Gets the code text with encoding.
encoding
- The encoding for 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 int 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 BarCodeRegion getRegion()
Gets the barcode region.
public long getReadType()
Gets the barcode type.
public long getBarCodeReadType()
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 enabledMemoryStream ms = new MemoryStream(); using (BarCodeBuilder bb = new BarCodeBuilder()) { bb.CodeText = "�����"; bb.SymbologyType = Symbology.QR; bb.CodeTextEncoding = Encoding.UTF8; bb.Save(ms, BarCodeImageFormat.Png); } using (BarCodeReader reader = new BarCodeReader(ms, BarCodeReadType.QR)) { reader.SetDetectEncoding(true); while(reader.Read()) Console.WriteLine("BarCode CodeText: " + reader.GetCodeText()); } ms.Position = 0; using (BarCodeReader reader = new BarCodeReader(ms, BarCodeReadType.QR)) { reader.SetDetectEncoding(false); while(reader.Read()) Console.WriteLine("BarCode CodeText: " + reader.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(long type)
Sets BarCodeReadType for recognition. Must be called before Read() method.
type
- The type of barcode to read.Copyright (c) 2002-2015 Aspose Pty Ltd. All Rights Reserved.