Skip to content

Commit

Permalink
update_to_v9.6.30
Browse files Browse the repository at this point in the history
  • Loading branch information
DMGithubPublisher committed Aug 29, 2023
1 parent c2b866b commit b0bd000
Show file tree
Hide file tree
Showing 27 changed files with 291 additions and 144 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
License Notice

This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement  https://www.dynamsoft.com/Products/barcode-reader-license-agreement.aspx ("Commercial License"). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Copyright © 2003–2022 Dynamsoft. All rights reserved.
Copyright © 2003–2023 Dynamsoft. All rights reserved.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This repository contains multiple samples that demonstrates how to use the <a hr

The library requires a license to work, you use the API InitLicense to initialize license key and activate the SDK.

These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp" target="_blank">Customer Portal</a> which works offline.
These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp" target="_blank">Customer Portal</a> which works offline.

## Contact Us

Expand Down
49 changes: 44 additions & 5 deletions include/DynamsoftBarcodeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2716,12 +2716,42 @@ typedef struct tagLineSegment
typedef struct tagDM_DLSConnectionParameters DM_DLSConnectionParameters;
typedef struct tagDM_DLSConnectionParameters DM_LTSConnectionParameters;

/**
* @brief Struct to represent the status of an instance pool.
*
* This struct contains information about the current status of an instance pool,
* including the number of authorized instances, remaining available instances,
* instances waiting to be acquired, and the total occurrences of waiting events.
*/

typedef struct tagInstancePoolStatus
{
/** The number of authorized instances, which represents the maximum available instances. */
int authorizedInstancesCount;
/** The count of available instances that are currently not in use. */
int remainingInstancesCount;
/** The number of 'GetInstance' requests that are currently waiting because there are no available instances in the pool. */
int waitingCreationInstances;
/** The total count of times that any operation has encountered a wait state. */
int totalWaitOccurrences;
}InstancePoolStatus;




/**
* @}defgroup Struct Struct
*/




#pragma pack(pop)

#pragma endregion
Expand Down Expand Up @@ -3599,18 +3629,19 @@ extern "C" {
*
* @param [in] countForThisDevice The maximum number of concurrent instances that the current device can run.
* @param [in] countForThisProcess Optional The maximum number of concurrent instances that the current process can run.
* @param [in] timeOut The maximum time(in millseconds) to wait for an available authorization or instance when calling Initlicense,GetInstance,or Deocode functions.
*
*/
DBR_API void DBR_SetMaxConcurrentInstanceCount(int countForThisDevice, int countForThisProcess);
DBR_API int DBR_SetMaxConcurrentInstanceCount(int countForThisDevice, int countForThisProcess,int timeOut);

/**
* Gets an idle Dynamsoft Barcode Reader instance running on concurrent instance mode.
* Creates an instance of Dynamsoft Barcode Reader.
*
*/
DBR_API void* DBR_GetInstance();

/**
*Recycles a Dynamsoft Barcode Reader instance running on concurrent instance mode.
*Restroys an instance of Dynamsoft Barcode Reader.
*
*/
DBR_API void DBR_RecycleInstance(void* barcodeReader);
Expand Down Expand Up @@ -3642,6 +3673,10 @@ extern "C" {
*Frees memory allocated for the string.
*/
DBR_API void DBR_FreeString(char** content);



DBR_API InstancePoolStatus DBR_GetInstancePoolStatus();
/**
* @}defgroup CCallback
*/
Expand Down Expand Up @@ -4497,17 +4532,18 @@ namespace dynamsoft
*
* @param [in] countForThisDevice The maximum number of concurrent instances that the current device can run.
* @param [in] countForThisProcess Optional The maximum number of concurrent instances that the current process can run.
* @param [in] timeOut The maximum time(in millseconds) to wait for an available authorization or instance when calling Initlicense,GetInstance,or Deocode functions.
*
*/
static void SetMaxConcurrentInstanceCount(int countForThisDevice, int countForThisProcess = 0);
static int SetMaxConcurrentInstanceCount(int countForThisDevice, int countForThisProcess = 0,int timeout = 0);

/**
* Gets an idle Dynamsoft Barcode Reader instance running on concurrent instance mode.
*
*/
static CBarcodeReader* GetInstance();

/**
/**
*Recycles a Dynamsoft Barcode Reader instance running on concurrent instance mode.
*
*/
Expand All @@ -4530,6 +4566,9 @@ namespace dynamsoft
*Frees memory allocated for the string.
*/
static void FreeString(char** content);


static InstancePoolStatus GetInstancePoolStatus();
private:
CBarcodeReader(const CBarcodeReader& r);

Expand Down
Binary file modified lib/Linux/ARM32/libDynamsoftBarcodeReader.so
Binary file not shown.
Binary file modified lib/Linux/ARM32/libDynamsoftLicenseClient.so
Binary file not shown.
Binary file modified lib/Linux/ARM64/libDynamsoftBarcodeReader.so
Binary file not shown.
Binary file modified lib/Linux/ARM64/libDynamsoftLicenseClient.so
Binary file not shown.
Binary file modified lib/Linux/x64/libDynamsoftBarcodeReader.so
Binary file not shown.
Binary file modified lib/Linux/x64/libDynamsoftLicenseClient.so
Binary file not shown.
Binary file modified lib/Windows/x64/DBRx64.lib
Binary file not shown.
Binary file modified lib/Windows/x64/DynamsoftBarcodeReaderx64.dll
Binary file not shown.
Binary file modified lib/Windows/x64/DynamsoftLicenseClientx64.dll
Binary file not shown.
Binary file modified lib/Windows/x86/DBRx86.lib
Binary file not shown.
Binary file modified lib/Windows/x86/DynamsoftBarcodeReaderx86.dll
Binary file not shown.
Binary file modified lib/Windows/x86/DynamsoftLicenseClientx86.dll
Binary file not shown.
21 changes: 14 additions & 7 deletions samples/C++/GeneralSettings/GeneralSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,26 @@ int main()

// 1.Initialize license.
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp
errorCode = CBarcodeReader::InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", szErrorMsg, 512);
if (errorCode != DBR_OK)
{
cout << szErrorMsg << endl;
}

// 2. Create an instance of Barcode Reader
CBarcodeReader dbr;

CBarcodeReader* dbr = CBarcodeReader::GetInstance();
if (dbr == NULL)
{
cout << "Get instance failed." << endl;
return -1;
}
// 3. Configure settings

// 3.1 Through PublicRuntimeSetting

// 3.1.1 Call GetRuntimeSettings to get current runtime settings.
dbr.GetRuntimeSettings(&settings);
dbr->GetRuntimeSettings(&settings);

// 3.1.2 Configure one or more specific settings
// In this sample, we configure three settings:
Expand All @@ -62,18 +66,18 @@ int main()
settings.region.regionMeasuredByPercentage = 1;

// 3.1.3 Call UpdateRuntimeSettings to apply above settings
dbr.UpdateRuntimeSettings(&settings, szErrorMsg, 512);
dbr->UpdateRuntimeSettings(&settings, szErrorMsg, 512);

// 3.2 Through JSON template
//dbr.InitRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"S1\",\"RegionDefinitionNameArray\":[\"R1\"]},\"RegionDefinition\":{\"Name\":\"R1\",\"BarcodeFormatIds\":[\"BF_PDF417\"],\"BarcodeFormatIds_2\":[\"BF2_POSTALCODE\"],\"ExpectedBarcodesCount\":2,\"Left\":0,\"Right\":100,\"Top\":50,\"Bottom\":100,\"MeasuredByPercentage\":1}}", CM_IGNORE, szErrorMsg, 512);

// 4. Read barcode from an image file
errorCode = dbr.DecodeFile("../../../images/AllSupportedBarcodeTypes.png", "");
errorCode = dbr->DecodeFile("../../../images/AllSupportedBarcodeTypes.png", "");
if (errorCode != DBR_OK)
cout << CBarcodeReader::GetErrorString(errorCode) << endl;

// 5. Get all barcode results
dbr.GetAllTextResults(&barcodeResults);
dbr->GetAllTextResults(&barcodeResults);


if (barcodeResults != NULL && barcodeResults->resultsCount > 0)
Expand All @@ -100,6 +104,9 @@ int main()
if (barcodeResults != NULL)
CBarcodeReader::FreeTextResults(&barcodeResults);

dbr->Recycle();
dbr = NULL;

cout << "Press any key to quit..." << endl;
cin.ignore();
return 0;
Expand Down
17 changes: 13 additions & 4 deletions samples/C++/HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ int main()

// 1.Initialize license.
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp
errorCode = CBarcodeReader::InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", szErrorMsg, 256);
if (errorCode != DBR_OK)
{
cout << szErrorMsg << endl;
}

// 2. Create an instance of Barcode Reader
CBarcodeReader dbr;
CBarcodeReader* dbr = CBarcodeReader::GetInstance();
if (dbr == NULL)
{
cout << "Get instance failed." << endl;
return -1;
}

// 3. Read barcode from an image file
errorCode = dbr.DecodeFile("../../../images/AllSupportedBarcodeTypes.png", "");
errorCode = dbr->DecodeFile("../../../images/AllSupportedBarcodeTypes.png", "");
if (errorCode != DBR_OK)
cout << CBarcodeReader::GetErrorString(errorCode) << endl;

// 4. Get all barcode results
dbr.GetAllTextResults(&barcodeResults);
dbr->GetAllTextResults(&barcodeResults);

if (barcodeResults != NULL && barcodeResults->resultsCount > 0)
{
Expand All @@ -68,6 +73,10 @@ int main()
if (barcodeResults != NULL)
CBarcodeReader::FreeTextResults(&barcodeResults);

// 6. Free the memory allocated for instance of Barcode Reader
dbr->Recycle();
dbr = NULL;

cout << "Press any key to quit..." << endl;
cin.ignore();
return 0;
Expand Down
20 changes: 14 additions & 6 deletions samples/C++/MultiThreadDecoding/MultiThreadDecoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,22 @@ void ThreadDecodeFile(void* pInfo)
pMultiThreadDecodeFileInfo->mutexInfo->unlock();


CBarcodeReader reader;

CBarcodeReader* reader = CBarcodeReader::GetInstance();
if (reader == NULL)
{
cout << "Get instance failed." << endl;
continue;
}

char errorMessage[256];
//Best coverage settings
reader.InitRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}", CM_OVERWRITE, errorMessage, 256);
reader->InitRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}", CM_OVERWRITE, errorMessage, 256);
//Best speend settings
//reader.InitRuntimeSettingsWithString(temphBarcode, "{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}", CM_OVERWRITE, errorMessage, 256);
//Balance settings
//reader.InitRuntimeSettingsWithString(temphBarcode, "{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_STATISTICS\"}]}}", CM_OVERWRITE, errorMessage, 256);

int iRet = reader.DecodeFile(strImageFile.c_str());
int iRet = reader->DecodeFile(strImageFile.c_str());

cout << "Thread: " << this_thread::get_id() << " File Name:" << strImageFile << endl;

Expand All @@ -78,7 +83,7 @@ void ThreadDecodeFile(void* pInfo)
else
{
TextResultArray *paryResult = NULL;
reader.GetAllTextResults(&paryResult);
reader->GetAllTextResults(&paryResult);

if (paryResult->resultsCount == 0)
{
Expand All @@ -93,6 +98,9 @@ void ThreadDecodeFile(void* pInfo)
}

cout << endl;

reader->Recycle();
reader = NULL;
}
}

Expand Down Expand Up @@ -184,7 +192,7 @@ int main(int argc, const char* argv[])

// 1.Initialize license.
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp
errorCode = CBarcodeReader::InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", szErrorMsg, 256);
if (errorCode == DBR_OK)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,20 @@ int main() {
TextResultArray* barcodeResults = NULL;
// 1.Initialize license.
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp
errorCode = CBarcodeReader::InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", szErrorMsg, 256);
if (errorCode != DBR_OK)
{
cout << szErrorMsg << endl;
}
// Create an instance of Barcode Reader
CBarcodeReader reader;
CBarcodeReader* reader = CBarcodeReader::GetInstance();
if (reader == NULL)
{
cout << "Get instance failed." << endl;
return -1;
}

AccuracyFirstSettings af;

string fileName = "../../../../images/AllSupportedBarcodeTypes.png";
Expand All @@ -100,32 +106,36 @@ int main() {
cout << "Decode through PublicRuntimeSettings:" << endl;
{
// config through PublicRuntimeSettings
af.configAccuracyFirst(&reader);
af.configAccuracyFirst(reader);

// Decode barcodes from an image file by current runtime settings. The second parameter value "" means to decode through the current PublicRuntimeSettings.
reader.DecodeFile(fileName.c_str(), "");
reader->DecodeFile(fileName.c_str(), "");

// Get all barcode results
reader.GetAllTextResults(&barcodeResults);
reader->GetAllTextResults(&barcodeResults);

// Output the barcode format and barcode text.
af.outputResults(barcodeResults, reader);
af.outputResults(barcodeResults, *reader);
}
cout << endl;
cout << "Decode through parameters template:" << endl;
{
// config through parameters template
af.configAccuracyFirstByTemplate(&reader);
af.configAccuracyFirstByTemplate(reader);

// Decode barcodes from an image file by template.
reader.DecodeFile(fileName.c_str(), "");
reader->DecodeFile(fileName.c_str(), "");

// Get all barcode results
reader.GetAllTextResults(&barcodeResults);
reader->GetAllTextResults(&barcodeResults);

// Output the barcode format and barcode text.
af.outputResults(barcodeResults, reader);
af.outputResults(barcodeResults, *reader);
}

reader->Recycle();
reader = NULL;

cout << "Press any key to quit..." << endl;
cin.ignore();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion samples/C++/Performance/BatchDecode/BatchDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int main(int argc, char* argv[])
char szErrorMsg[256];
// 1.Initialize license.
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?architecture=dcv&product=dbr&utm_source=samples&package=c_cpp
int errorCode = dynamsoft::dbr::CBarcodeReader::InitLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", szErrorMsg, 256);
if (errorCode != DBR_OK)
{
Expand Down
14 changes: 11 additions & 3 deletions samples/C++/Performance/BatchDecode/DbrBarcodeFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@

CDbrBarcodeFileReader::CDbrBarcodeFileReader()
{
m_pBarcodeReader = new dynamsoft::dbr::CBarcodeReader();
m_pBarcodeReader = dynamsoft::dbr::CBarcodeReader::GetInstance();
}

CDbrBarcodeFileReader::~CDbrBarcodeFileReader()
{

SAFE_DELETE(m_pBarcodeReader);
if (m_pBarcodeReader)
{
m_pBarcodeReader->Recycle();
m_pBarcodeReader = nullptr;
}
}

void CDbrBarcodeFileReader::Run()
{
if (!m_pBarcodeReader)
{
cout << "Get instance failed." << endl;
return;
}
LoadRuntimeSettings("templates");
if (m_listSettingsFile.size() > 0)
{
Expand Down
Loading

0 comments on commit b0bd000

Please sign in to comment.