Skip to content

Commit 181f75c

Browse files
committed
Update command-line/main.cpp
1 parent d0e70ef commit 181f75c

1 file changed

Lines changed: 49 additions & 38 deletions

File tree

examples/10.x/command-line/main.cpp

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class MyCapturedResultReceiver : public CCapturedResultReceiver
5454
cout << "Result " << i + 1 << endl;
5555
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
5656
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
57+
CPoint *points = barcodeResultItem->GetLocation().points;
58+
for (int j = 0; j < 4; j++)
59+
{
60+
cout << "Point " << j + 1 << ": (" << points[j][0] << ", " << points[j][1] << ")" << endl;
61+
}
5762
}
5863
}
5964
}
@@ -171,44 +176,50 @@ int main(int argc, char *argv[])
171176
int errorCode = 0;
172177

173178
string path = string(pszImageFile);
174-
fileFetcher->SetFile(pszImageFile);
175-
errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
176-
// if (endsWith(path, ".pdf") || endsWith(path, ".tif"))
177-
// {
178-
// fileFetcher->SetFile(pszImageFile);
179-
// errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
180-
// }
181-
// else
182-
// {
183-
// CCapturedResult *result = cvr->Capture(pszImageFile, CPresetTemplate::PT_READ_BARCODES);
184-
185-
// if (result->GetErrorCode() != 0)
186-
// {
187-
// cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
188-
// }
189-
// CDecodedBarcodesResult *barcodeResult = result->GetDecodedBarcodesResult();
190-
// if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
191-
// {
192-
// cout << "No barcode found." << endl;
193-
// }
194-
// else
195-
// {
196-
// int barcodeResultItemCount = barcodeResult->GetItemsCount();
197-
// cout << "Decoded " << barcodeResultItemCount << " barcodes" << endl;
198-
199-
// for (int j = 0; j < barcodeResultItemCount; j++)
200-
// {
201-
// const CBarcodeResultItem *barcodeResultItem = barcodeResult->GetItem(j);
202-
// cout << "Result " << j + 1 << endl;
203-
// cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
204-
// cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
205-
// }
206-
// }
207-
// if (barcodeResult)
208-
// barcodeResult->Release();
209-
210-
// result->Release();
211-
// }
179+
// fileFetcher->SetFile(pszImageFile);
180+
// errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
181+
if (endsWith(path, ".pdf") || endsWith(path, ".tif"))
182+
{
183+
fileFetcher->SetFile(pszImageFile);
184+
errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
185+
}
186+
else
187+
{
188+
CCapturedResult *result = cvr->Capture(pszImageFile, CPresetTemplate::PT_READ_BARCODES);
189+
190+
if (result->GetErrorCode() != 0)
191+
{
192+
cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
193+
}
194+
CDecodedBarcodesResult *barcodeResult = result->GetDecodedBarcodesResult();
195+
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
196+
{
197+
cout << "No barcode found." << endl;
198+
}
199+
else
200+
{
201+
int barcodeResultItemCount = barcodeResult->GetItemsCount();
202+
cout << "Decoded " << barcodeResultItemCount << " barcodes" << endl;
203+
204+
for (int j = 0; j < barcodeResultItemCount; j++)
205+
{
206+
const CBarcodeResultItem *barcodeResultItem = barcodeResult->GetItem(j);
207+
cout << "Result " << j + 1 << endl;
208+
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
209+
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
210+
211+
CPoint *points = barcodeResultItem->GetLocation().points;
212+
for (int j = 0; j < 4; j++)
213+
{
214+
cout << "Point " << j + 1 << ": (" << points[j][0] << ", " << points[j][1] << ")" << endl;
215+
}
216+
}
217+
}
218+
if (barcodeResult)
219+
barcodeResult->Release();
220+
221+
result->Release();
222+
}
212223
}
213224

214225
delete cvr, cvr = NULL, listener, capturedReceiver, fileFetcher;

0 commit comments

Comments
 (0)