Skip to content

Commit 2f1031a

Browse files
update
1 parent 8ea191f commit 2f1031a

7 files changed

Lines changed: 71 additions & 20 deletions

File tree

CustomTemplates/ReadOneDRetail.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@
1919
{
2020
"Name": "task-oned-retail",
2121
"ExpectedBarcodesCount": 0,
22-
"BarcodeFormatIds": [
23-
"BF_EAN_13", "BF_EAN_8", "BF_UPC_A", "BF_UPC_E"
24-
],
22+
"BarcodeFormatIds": [
23+
"BF_EAN_13",
24+
"BF_EAN_8",
25+
"BF_UPC_A",
26+
"BF_UPC_E",
27+
"BF_GS1_DATABAR"
28+
],
2529
"SectionArray": [
2630
{
2731
"Section": "ST_REGION_PREDETECTION",

Samples/GeneralSettings/GeneralSettings.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ int main()
7979
for (int i = 0; i < count; ++i)
8080
{
8181
const CCapturedResult* result = resultArray->GetResult(i);
82-
83-
8482
if (result->GetErrorCode() == ErrorCode::EC_UNSUPPORTED_JSON_KEY_WARNING)
8583
{
8684
cout << "Warning: " << result->GetErrorCode() << ", " << result->GetErrorString() << endl;
@@ -90,21 +88,31 @@ int main()
9088
cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
9189
}
9290

91+
int pageNumber = i + 1;
92+
93+
// It is usually necessary to determine 'ImageTagType' based on the original image tag.
94+
// Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
95+
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(result->GetOriginalImageTag());
96+
if(tag != nullptr)
97+
{
98+
pageNumber = tag->GetPageNumber() + 1;
99+
}
100+
93101
// 6. Output the barcode text.
94102
CDecodedBarcodesResult* barcodeResult = result->GetDecodedBarcodesResult();
95103
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
96104
{
97-
cout << "No barcode found in page " << i + 1 << endl;
105+
cout << "No barcode found in page " << pageNumber << endl;
98106
}
99107
else
100108
{
101109
int barcodeResultItemCount = barcodeResult->GetItemsCount();
102-
cout << "Page " << i + 1 << " decoded " << barcodeResultItemCount << " barcodes" << endl;
110+
cout << "Page " << pageNumber << " decoded " << barcodeResultItemCount << " barcodes" << endl;
103111

104112
for (int j = 0; j < barcodeResultItemCount; j++)
105113
{
106114
const CBarcodeResultItem* barcodeResultItem = barcodeResult->GetItem(j);
107-
cout << "Result " << i + 1 << "-" << j + 1 << endl;
115+
cout << "Result " << pageNumber << "-" << j + 1 << endl;
108116
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
109117
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
110118
}

Samples/HelloWorld/ReadAnImage/ReadAnImage.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ int main()
4444
for (int i = 0; i < count; ++i)
4545
{
4646
const CCapturedResult* result = resultArray->GetResult(i);
47-
48-
4947
if (result->GetErrorCode() == ErrorCode::EC_UNSUPPORTED_JSON_KEY_WARNING)
5048
{
5149
cout << "Warning: " << result->GetErrorCode() << ", " << result->GetErrorString() << endl;
@@ -54,20 +52,31 @@ int main()
5452
{
5553
cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
5654
}
55+
56+
int pageNumber = i + 1;
57+
58+
// It is usually necessary to determine 'ImageTagType' based on the original image tag.
59+
// Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
60+
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(result->GetOriginalImageTag());
61+
if(tag != nullptr)
62+
{
63+
pageNumber = tag->GetPageNumber() + 1;
64+
}
65+
5766
CDecodedBarcodesResult* barcodeResult = result->GetDecodedBarcodesResult();
5867
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
5968
{
60-
cout << "No barcode found in page " << i + 1 << endl;
69+
cout << "No barcode found in page " << pageNumber << endl;
6170
}
6271
else
6372
{
6473
int barcodeResultItemCount = barcodeResult->GetItemsCount();
65-
cout << "Page " << i + 1 << " decoded " << barcodeResultItemCount << " barcodes" << endl;
74+
cout << "Page " << pageNumber << " decoded " << barcodeResultItemCount << " barcodes" << endl;
6675

6776
for (int j = 0; j < barcodeResultItemCount; j++)
6877
{
6978
const CBarcodeResultItem* barcodeResultItem = barcodeResult->GetItem(j);
70-
cout << "Result " << i + 1 << "-" << j + 1 << endl;
79+
cout << "Result " << pageNumber << "-" << j + 1 << endl;
7180
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
7281
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
7382
}

Samples/HelloWorld/ReadMultipleImages/ReadMultipleImages.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MyCapturedResultReceiver : public CCapturedResultReceiver
3131
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(pResult->GetOriginalImageTag());
3232

3333
cout << "File: " << tag->GetFilePath() << endl;
34+
cout << "Page: " << tag->GetPageNumber() << endl;
3435

3536
if (pResult->GetErrorCode() == ErrorCode::EC_UNSUPPORTED_JSON_KEY_WARNING)
3637
{

Samples/MultiThreadDecoding/MultiThreadDecoding.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,26 @@ void ThreadDecodeFile(const char *filePath)
4848
for (int i = 0; i < count; ++i)
4949
{
5050
const CCapturedResult* result = resultArray->GetResult(i);
51-
cout << "Page " << i + 1 << ":" << endl;
51+
int pageNumber = i + 1;
52+
// It is usually necessary to determine 'ImageTagType' based on the original image tag.
53+
// Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
54+
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(result->GetOriginalImageTag());
55+
if(tag != nullptr)
56+
{
57+
pageNumber = tag->GetPageNumber() + 1;
58+
}
59+
cout << "Page " << pageNumber << ":" << endl;
5260
cout << "Error: " << result->GetErrorCode() << ", " << result->GetErrorString() << endl;
5361

5462
CDecodedBarcodesResult* barcodeResult = result->GetDecodedBarcodesResult();
5563

5664
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
5765
{
58-
cout << "No barcode found in page " << i + 1 << endl;
66+
cout << "No barcode found in page " << pageNumber << endl;
5967
}
6068
else
6169
{
62-
cout << "Total barcode(s) found in page " << i + 1 << ": " << barcodeResult->GetItemsCount() << endl;
70+
cout << "Total barcode(s) found in page " << pageNumber << ": " << barcodeResult->GetItemsCount() << endl;
6371
for (int index = 0; index < barcodeResult->GetItemsCount(); ++index)
6472
{
6573
const CBarcodeResultItem* barcode = barcodeResult->GetItem(index);
@@ -192,6 +200,9 @@ int main(int argc, const char *argv[])
192200
if (imagePath == "q" || imagePath == "Q")
193201
break;
194202

203+
if (imagePath.length() >= 2 && imagePath.front() == '"' && imagePath.back() == '"')
204+
imagePath = imagePath.substr(1, imagePath.length() - 2);
205+
195206
vector<string> vecFiles;
196207
GetFiles(imagePath, vecFiles);
197208

Samples/ParameterTuner/ParameterTuner.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,21 @@ void run(CCaptureVisionRouter* cvrInstance, const std::string& imagePath, const
163163
int count = resultArray->GetResultsCount();
164164
for (int i = 0; i < count; ++i)
165165
{
166-
std::cout << "Result" << (count > 1 ? " Page-" + std::to_string(i + 1) : "") << ":" << std::endl;
166+
167167
const CCapturedResult* result = resultArray->GetResult(i);
168168
if (!result)
169169
continue;
170170

171+
int pageNumber = i + 1;
172+
// It is usually necessary to determine 'ImageTagType' based on the original image tag.
173+
// Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
174+
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(result->GetOriginalImageTag());
175+
if(tag != nullptr)
176+
{
177+
pageNumber = tag->GetPageNumber() + 1;
178+
}
179+
std::cout << "Result" << (count > 1 ? " Page-" + std::to_string(pageNumber) : "") << ":" << std::endl;
180+
171181
int errorCode = result->GetErrorCode();
172182
if (errorCode != ErrorCode::EC_OK && errorCode != ErrorCode::EC_UNSUPPORTED_JSON_KEY_WARNING) {
173183
std::cout << "Error: " << errorCode << ", " << result->GetErrorString() << std::endl;

Samples/ReadDPMBarcode/ReadDPMBarcode.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,29 @@ int main()
5959
cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
6060
}
6161

62+
int pageNumber = i + 1;
63+
// It is usually necessary to determine 'ImageTagType' based on the original image tag.
64+
// Since imageFile is used, it is directly converted to 'const dynamsoft::basic_structures::CFileImageTag *'.
65+
const CFileImageTag *tag = dynamic_cast<const CFileImageTag *>(result->GetOriginalImageTag());
66+
if(tag != nullptr)
67+
{
68+
pageNumber = tag->GetPageNumber() + 1;
69+
}
6270
// 5. Output the barcode format and barcode text.
6371
CDecodedBarcodesResult* barcodeResult = result->GetDecodedBarcodesResult();
6472
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
6573
{
66-
cout << "No barcode found in page " << i + 1 << endl;
74+
cout << "No barcode found in page " << pageNumber << endl;
6775
}
6876
else
6977
{
7078
int barcodeResultItemCount = barcodeResult->GetItemsCount();
71-
cout << "Page " << i + 1 << " decoded " << barcodeResultItemCount << " barcodes" << endl;
79+
cout << "Page " << pageNumber << " decoded " << barcodeResultItemCount << " barcodes" << endl;
7280

7381
for (int j = 0; j < barcodeResultItemCount; j++)
7482
{
7583
const CBarcodeResultItem* barcodeResultItem = barcodeResult->GetItem(j);
76-
cout << "Barcode " << i + 1 << "-" << j + 1 << endl;
84+
cout << "Barcode " << pageNumber << "-" << j + 1 << endl;
7785
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
7886
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
7987
}

0 commit comments

Comments
 (0)