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("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(Bitmap image) | Initializes a new instance of the BarCodeReader class from an image. |
BarCodeReader(Bitmap image, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(Bitmap image, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(Bitmap image, Rect area, BaseDecodeType[] decodeTypes) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(String imagePath, Rect[] areas, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(InputStream stream, Rect area, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(String imagePath, Rect area, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(InputStream stream, Rect[] areas, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(Bitmap image, Rect[] areas, BaseDecodeType type) | Initializes a new instance of the BarCodeReader class. |
BarCodeReader(Bitmap image, Rect area, BaseDecodeType type) | |
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() | Gets the decode type of the input barcode decoding |
getBarcodeSettings() | The main BarCode decoding parameters. |
getClass() | |
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. |
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(Bitmap value) | Sets bitmap image for recognition. |
setBarCodeImage(Bitmap value, Rect area) | Sets bitmap image and area for recognition. |
setBarCodeImage(Bitmap value, Rect[] 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. |
setQualitySettings(QualitySettings value) | QualitySettings allows to configure recognition quality and speed manually. |
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("test.png"); for(BarCodeResult result : reader.readBarCodes()) { System.out.println("BarCode Type: " + result.getCodeTypeName()); System.out.println("BarCode CodeText: " + result.getCodeText()); }
BarCodeReader(Bitmap image)
public BarCodeReader(Bitmap image)
Initializes a new instance of the BarCodeReader class from an image.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | A Bitmap instance containing the image |
BarCodeReader(Bitmap image, BaseDecodeType[] decodeTypes)
public BarCodeReader(Bitmap image, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The image. |
decodeTypes | BaseDecodeType[] | Decode types. |
BarCodeReader(Bitmap image, BaseDecodeType type)
public BarCodeReader(Bitmap image, BaseDecodeType type)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The image. |
type | BaseDecodeType | The decode type1. It can be single or multy |
BarCodeReader(Bitmap image, Rect area, BaseDecodeType[] decodeTypes)
public BarCodeReader(Bitmap image, Rect area, BaseDecodeType[] decodeTypes)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The image. |
area | android.graphics.Rect | The area for recognition. |
decodeTypes | BaseDecodeType[] | Decode types. |
BarCodeReader(String imagePath, Rect[] areas, BaseDecodeType type)
public BarCodeReader(String imagePath, Rect[] 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 |
---|---|---|
imagePath | java.lang.String | The image path. |
areas | android.graphics.Rect[] | The area for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(InputStream stream, Rect area, BaseDecodeType type)
public BarCodeReader(InputStream stream, Rect area, 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 |
---|---|---|
stream | java.io.InputStream | The image stream. |
area | android.graphics.Rect | The area for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(String imagePath, Rect area, BaseDecodeType type)
public BarCodeReader(String imagePath, Rect area, 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 |
---|---|---|
imagePath | java.lang.String | The image path. |
area | android.graphics.Rect | The area for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(InputStream stream, Rect[] areas, BaseDecodeType type)
public BarCodeReader(InputStream stream, Rect[] 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 |
---|---|---|
stream | java.io.InputStream | The image stream. |
areas | android.graphics.Rect[] | The area for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(Bitmap image, Rect[] areas, BaseDecodeType type)
public BarCodeReader(Bitmap image, Rect[] areas, BaseDecodeType type)
Initializes a new instance of the BarCodeReader class.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The image. |
areas | android.graphics.Rect[] | The areas for recognition. |
type | BaseDecodeType | The decode type. |
BarCodeReader(Bitmap image, Rect area, BaseDecodeType type)
public BarCodeReader(Bitmap image, Rect area, BaseDecodeType type)
Parameters:
Parameter | Type | Description |
---|---|---|
image | android.graphics.Bitmap | |
area | android.graphics.Rect | |
type | BaseDecodeType |
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("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("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("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("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("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("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("test.png", DecodeType.CODE_39_STANDARD, DecodeType.CODE_128); Thread thread1 = new Thread(new Runnable() {
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()
Gets the decode type of the input barcode decoding
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
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getFoundBarCodes()
public BarCodeResult[] getFoundBarCodes()
Gets recognized BarCodeResult s array
This sample shows how to read barcodes with BarCodeReader BarCodeReader reader = new BarCodeReader("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("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("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("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("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
getTimeout()
public int getTimeout()
Gets the timeout of recognition process in milliseconds.
BarCodeReader reader = new BarCodeReader("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("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("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(Bitmap value)
public void setBarCodeImage(Bitmap value)
Sets bitmap image for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The bitmap image for recognition. |
setBarCodeImage(Bitmap value, Rect area)
public final void setBarCodeImage(Bitmap value, Rect area)
Sets bitmap image and area for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The bitmap image for recognition. |
area | android.graphics.Rect | area for recognition |
setBarCodeImage(Bitmap value, Rect[] areas)
public final void setBarCodeImage(Bitmap value, Rect[] areas)
Sets bitmap image and areas for recognition. Must be called before ReadBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes. Bitmap bmp = BitmapFactory.decodeFile("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 | android.graphics.Bitmap | The bitmap image for recognition. |
areas | android.graphics.Rect[] | 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("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("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("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("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. |
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("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("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("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 |
setTimeout(int value)
public void setTimeout(int value)
Sets the timeout of recognition process in milliseconds.
BarCodeReader reader = new BarCodeReader("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 |