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 function to process errors which is triggered when the library finishes decoding a frame. |
SetTextResultCallback |
Set callback function to process text results which is triggered when the library finishes decoding a frame. |
SetUniqueBarcodeCallback |
Set callback function to process text results which is triggered when the library finishes decoding a frame and finds unique barcodes. |
SetIntermediateResultCallback |
Set callback function 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.
int dynamsoft::dbr::CBarcodeReader::StartFrameDecoding (const int maxQueueLength, const int maxResultQueueLength, const int width, const int height, const int stride, const ImagePixelFormat format, const char* pTemplateName = "")
Parameters
[in] maxQueueLength
The max number of frames waiting for decoding.
[in] maxResultQueueLength
The max number of frames whose results (text result/localization result) will be kept.
[in] width
The width of the frame image in pixels.
[in] height
The height of the frame image in pixels.
[in] stride
The stride (or scan width) of the frame image.
[in] format
The image pixel format used in the image byte array.
[in] pTemplateName
Optional The template name.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS; DBRERR_PARAMETER_VALUE_INVALID.
You can call GetErrorString
to get detailed error message.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
delete reader;
Remarks
If no template name is specified, current runtime settings will be used.
StartFrameDecodingEx
Start a new thread to decode barcodes from the inner frame queue with specific frame decoding setting defined in FrameDecodingParameters
struct.
int dynamsoft::dbr::CBarcodeReader::StartFrameDecodingEx (FrameDecodingParameters parameters, const char* pTemplateName = "")
Parameters
[in] parameters
The frame decoding parameters.
[in] pTemplateName
Optional The template name.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS; DBRERR_PARAMETER_VALUE_INVALID.
You can call GetErrorString
to get detailed error message.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
FrameDecodingParameters parameters;
int errorCode = reader->InitFrameDecodingParameters(¶meters);
if(errorCode == DBR_OK)
{
parameters.maxQueueLength = 3;
parameters.maxResultQueueLength = 10;
parameters.width = 20;
parameters.height = 30;
parameters.stride = 10;
parameters.imagePixelFormat = IPF_GRAYSCALED;
parameters.region.regionMeasuredByPercentage = 1;
parameters.region.regionTop = 0;
parameters.region.regionBottom = 100;
parameters.region.regionLeft = 0;
parameters.region.regionRight = 100;
parameters.threshold = 0.1;
parameters.fps = 0;
reader->StartFrameDecodingEx(parameters, "");
}
delete reader;
Remarks
If no template name is specified, current runtime settings will be used.
AppendFrame
Append a frame image buffer to the inner frame queue.
int dynamsoft::dbr::CBarcodeReader::AppendFrame (unsigned char* pBufferBytes)
Parameters
[in] pBufferBytes
The array of bytes which contain the image data.
Return Value
Returns the ID of the appended frame.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
int frameId = reader->AppendFrame(pBufferBytes);
delete reader;
StopFrameDecoding
Stop the frame decoding thread created by StartFrameDecoding
or StartFrameDecodingEx
.
int dynamsoft::dbr::CBarcodeReader::StopFrameDecoding()
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_STOP_DECODING_THREAD_FAILED.
You can call GetErrorString
to get detailed error message.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
int errorCode = reader->StopFrameDecoding();
delete reader;
InitFrameDecodingParameters
Initialize frame decoding parameters with default values.
int dynamsoft::dbr::CBarcodeReader::InitFrameDecodingParameters (FrameDecodingParameters* pParameters)
Parameters
[in,out] pParameters
The frame decoding parameters.
Return Value
Returns error code. Possible return(s): DBR_OK.
You can call GetErrorString
to get detailed error message.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
FrameDecodingParameters parameters;
int errorCode = reader->InitFrameDecodingParameters(¶meters);
if(errorCode == DBR_OK)
{
parameters.maxQueueLength = 3;
parameters.maxResultQueueLength = 10;
parameters.width = 20;
parameters.height = 30;
parameters.stride = 10;
parameters.imagePixelFormat = IPF_GRAYSCALED;
parameters.region.regionMeasuredByPercentage = 1;
parameters.region.regionTop = 0;
parameters.region.regionBottom = 100;
parameters.region.regionLeft = 0;
parameters.region.regionRight = 100;
parameters.threshold = 0.1;
parameters.fps = 0;
reader->StartFrameDecodingEx(parameters, "");
}
delete reader;
SetErrorCallback
Set callback function to process errors which is triggered when the library finishes decoding a frame.
int dynamsoft::dbr::CBarcodeReader::SetErrorCallback (CB_Error cbFunction, void* pUser)
Parameters
[in] cbFunction
Callback function.
[in] pUser
Customized arguments passed to your function.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS.
You can call GetErrorString
to get detailed error message.
Code Snippet
void ErrorFunction(int frameId, int errorCode, void * pUser)
{
//TODO add your code for using error code
}
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
reader->SetErrorCallback(ErrorFunction, NULL);
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
SetTextResultCallback
Set callback function to process text results which is triggered when the library finishes decoding a frame.
int dynamsoft::dbr::CBarcodeReader::SetTextResultCallback (CB_TextResult cbFunction, void* pUser)
Parameters
[in] cbFunction
Callback function.
[in] pUser
Customized arguments passed to your function.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS.
You can call GetErrorString
to get detailed error message.
Code Snippet
void TextResultFunction(int frameId, TextResultArray *pResults, void * pUser)
{
//TODO add your code for using text results
}
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
reader->SetTextResultCallback(TextResultFunction, NULL);
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
SetUniqueBarcodeCallback
Set callback function to process text results which is triggered when the library finishes decoding a frame and finds unique barcodes.
int dynamsoft::dbr::CBarcodeReader::SetUniqueBarcodeCallback(CB_TextResult cbFunction, void* pUser)
Parameters
[in] cbFunction
Callback function.
[in] pUser
Customized arguments passed to your function.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS.
You can call GetErrorString
to get detailed error message.
Code Snippet
void TextResultFunction(int frameId, TextResultArray *pResults, void * pUser)
{
//TODO add your code for using text results
}
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
reader->SetUniqueBarcodeCallback(TextResultFunction, NULL);
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
SetIntermediateResultCallback
Set callback function to process intermediate results which is triggered when the library finishes decoding a frame.
int dynamsoft::dbr::CBarcodeReader::SetIntermediateResultCallback (CB_IntermediateResult cbFunction, void* pUser)
Parameters
[in] cbFunction
Callback function.
[in] pUser
Customized arguments passed to your function.
Return Value
Returns error code. Possible return(s): DBR_OK; DBRERR_FRAME_DECODING_THREAD_EXISTS.
You can call GetErrorString
to get detailed error message.
Code Snippet
void IntermediateResultFunction(int frameId, IntermediateResultArray *pResults, void * pUser)
{
//TODO add your code for using intermediate results
}
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
PublicRuntimeSettings* pSettings = new PublicRuntimeSettings;
reader->GetRuntimeSettings(pSettings);
pSettings->intermediateResultTypes = IRT_ORIGINAL_IMAGE | IRT_COLOUR_CLUSTERED_IMAGE | IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE;
char errorMessage[256];
reader->UpdateRuntimeSettings(pSettings, errorMessage, 256);
reader->SetIntermediateResultCallback(IntermediateResultFunction, NULL);
reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, "");
GetLengthOfFrameQueue
Get length of current inner frame queue.
int dynamsoft::dbr::CBarcodeReader::GetLengthOfFrameQueue ()
Return Value
Returns length of current inner frame queue.
Code Snippet
char errorBuf[512];
dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
CBarcodeReader* reader = new CBarcodeReader();
int frameLength = reader->GetLengthOfFrameQueue();
delete reader;