Dev Center
Table of contents

Video Methods

Method Description
startFrameDecoding Decode barcodes from inner frame queue.
startFrameDecodingEx Decode barcodes from inner frame queue.
appendFrame Append a frame image buffer to the inner frame queue.
stopFrameDecoding Stop thread used for frame decoding.
initFrameDecodingParameters Initialize frame decoding parameter.
setErrorCallback Set callback interface to process errors which is triggered when the library finishes decoding a frame.
setTextResultCallback Set callback interface to process text results which is triggered when the library finishes decoding a frame.
setIntermediateResultCallback Set callback interface to process intermediate results which is triggered when the library finishes decoding a frame.
getLengthOfFrameQueue Get length of current inner frame queue.

startFrameDecoding

Start a new thread to decode barcodes from the inner frame queue with specific frame decoding setting passed in.

void com.dynamsoft.dbr.BarcodeReader.startFrameDecoding	(final int maxQueueLength, final int maxResultQueueLength, final int width, final int height, final int stride, final int enumImagePixelFormat, final String templateName) throws BarcodeReaderException

Parameters
maxQueueLength The max number of frames waiting for decoding.
maxResultQueueLength The max number of frames whose results (text result/localization result) will be kept.
width The width of the frame image in pixels.
height The height of the frame image in pixels.
stride The stride (or scan width) of the frame image.
format The image pixel format used in the image byte array.
templateName The template name.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    reader.setErrorCallback(new ErrorCallback() {
        @Override
        public void errorCallback(int frameId, int errorCode, Object userData) {
            //TODO add your code for using error code
        }
    }, null);
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    // add further process
    reader.recycle();
}

startFrameDecodingEx

Start a new thread to decode barcodes from the inner frame queue with specific frame decoding setting defined in FrameDecodingParameters struct.

void com.dynamsoft.dbr.BarcodeReader.startFrameDecodingEx(FrameDecodingParameters parameters, String templateName) throws BarcodeReaderException

Parameters
parameters The frame decoding parameters.
templateName The template name.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    FrameDecodingParameters parameters = reader.initFrameDecodingParameters();
    parameters.maxQueueLength = 2;
    parameters.maxResultQueueLength = 10;
    parameters.width = 1024;
    parameters.height = 720;
    parameters.stride = 1024;
    parameters.imagePixelFormat = EnumImagePixelFormat.IPF_GRAYSCALED;
    reader.setErrorCallback(new ErrorCallback() {
        @Override
        public void errorCallback(int frameId, int errorCode, Object userData) {
            //TODO add your code for using error code
        }
    }, null);
    reader.startFrameDecodingEx(parameters, "");
    // add further process
    reader.recycle();
}

appendFrame

Append a frame image buffer to the inner frame queue.

int com.dynamsoft.dbr.BarcodeReader.appendFrame(byte[] bufferBytes)	 

Parameters
bufferBytes The array of bytes which contain the image data.

Return Value
Returns the ID of the appended frame.

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    int frameId = reader.appendFrame(bufferBytes);
    // add further process
    reader.recycle();
}

stopFrameDecoding

Stop the frame decoding thread created by StartFrameDecoding or StartFrameDecodingEx.

void com.dynamsoft.dbr.BarcodeReader.stopFrameDecoding() throws BarcodeReaderException

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    // add further process
    reader.stopFrameDecoding();
    reader.recycle();
}

initFrameDecodingParameters

Initialize frame decoding parameters with default values.

FrameDecodingParameters com.dynamsoft.dbr.BarcodeReader.initFrameDecodingParameters() throws BarcodeReaderException

Return Value
The frame decoding parameters.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    FrameDecodingParameters parameters = reader.initFrameDecodingParameters();
    // add further process
    reader.recycle();
}

setErrorCallback

Set callback interface to process errors which is triggered when the library finishes decoding a frame.

void com.dynamsoft.dbr.BarcodeReader.setErrorCallback(ErrorCallback errorCallback, Object userData) throws BarcodeReaderException

Parameters
errorCallback Callback interface.
userData Customized arguments passed to your function.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    reader.setErrorCallback(new ErrorCallback() {
        @Override
        public void errorCallback(int frameId, int errorCode, Object userData) {
            //TODO add your code for using error code
        }
    }, null);
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    // add further process
    reader.recycle();
}

setTextResultCallback

Set callback interface to process text results which is triggered when the library finishes decoding a frame.

void com.dynamsoft.dbr.BarcodeReader.setTextResultCallback(TextResultCallback textResultCallback, Object userData) throws BarcodeReaderException	

Parameters
textResultCallback Callback interface.
userData Customized arguments passed to your function.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    reader.setTextResultCallback(new TextResultCallback() {
        @Override
        public void textResultCallback(int frameId, TextResult[] results, Object userData) {
            //TODO: add your code for processing all barcode results
        }
        public void uniqueBarcodeCallback(int frameId, TextResult[] results, Object userData) {
            //TODO: add your code for processing unique barcode results
        }
    }, null);
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    // add further process
    reader.recycle();
}

setIntermediateResultCallback

Set callback interface to process intermediate results which is triggered when the library finishes decoding a frame.

void com.dynamsoft.dbr.BarcodeReader.setIntermediateResultCallback(IntermediateResultCallback intermediateResultCallback, Object userData} throws BarcodeReaderException

Parameters
intermediateResultCallback Callback interface.
userData Customized arguments passed to your function.

Exception
BarcodeReaderException

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    PublicRuntimeSettings settings = reader.getRuntimeSettings();
    settings.intermediateResultTypes = EnumIntermediateResultType.IRT_ORIGINAL_IMAGE | EnumIntermediateResultType.IRT_COLOUR_CLUSTERED_IMAGE | EnumIntermediateResultType.IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE;
    reader.updateRuntimeSettings(settings);
    reader.setIntermediateResultCallback(new IntermediateResultCallback() {
        @Override
        public void intermediateResultCallback(int frameId, IntermediateResult[] results, Object userData) {
            //TODO add your code for using intermediate results
        }
    }, null);
    reader.startFrameDecoding(2, 10, 1024, 720, 1024, EnumImagePixelFormat.IPF_GRAYSCALED, "");
    // add further process
    reader.recycle();
}

getLengthOfFrameQueue

Get length of current inner frame queue.

int com.dynamsoft.dbr.BarcodeReader.getLengthOfFrameQueue()	

Return Value
Returns length of current inner frame queue.

Code Snippet

BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = BarcodeReader.getInstance();
if(reader != null)
{
    int length = reader.getLengthOfFrameQueue();
    // add further process
    reader.recycle();
}

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.4.10
    • Version 10.2.10
    • Version 10.2.0
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.0
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
  • Documentation Homepage
Change +