Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Oct 28, 2024
1 parent ce9d70d commit 705225b
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions examples/10.x/command-line/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,44 +172,46 @@ int main(int argc, char *argv[])
int errorCode = 0;

string path = string(pszImageFile);
if (endsWith(path, ".pdf") || endsWith(path, ".tif"))
{
fileFetcher->SetFile(pszImageFile);
errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
}
else
{
CCapturedResult *result = cvr->Capture(pszImageFile, CPresetTemplate::PT_READ_BARCODES);

if (result->GetErrorCode() != 0)
{
cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
}
CDecodedBarcodesResult *barcodeResult = result->GetDecodedBarcodesResult();
if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
{
cout << "No barcode found." << endl;
}
else
{
int barcodeResultItemCount = barcodeResult->GetItemsCount();
cout << "Decoded " << barcodeResultItemCount << " barcodes" << endl;

for (int j = 0; j < barcodeResultItemCount; j++)
{
const CBarcodeResultItem *barcodeResultItem = barcodeResult->GetItem(j);
cout << "Result " << j + 1 << endl;
cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
}
}
if (barcodeResult)
barcodeResult->Release();

result->Release();
}
fileFetcher->SetFile(pszImageFile);
errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
// if (endsWith(path, ".pdf") || endsWith(path, ".tif"))
// {
// fileFetcher->SetFile(pszImageFile);
// errorCode = cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);
// }
// else
// {
// CCapturedResult *result = cvr->Capture(pszImageFile, CPresetTemplate::PT_READ_BARCODES);

// if (result->GetErrorCode() != 0)
// {
// cout << "Error: " << result->GetErrorCode() << "," << result->GetErrorString() << endl;
// }
// CDecodedBarcodesResult *barcodeResult = result->GetDecodedBarcodesResult();
// if (barcodeResult == nullptr || barcodeResult->GetItemsCount() == 0)
// {
// cout << "No barcode found." << endl;
// }
// else
// {
// int barcodeResultItemCount = barcodeResult->GetItemsCount();
// cout << "Decoded " << barcodeResultItemCount << " barcodes" << endl;

// for (int j = 0; j < barcodeResultItemCount; j++)
// {
// const CBarcodeResultItem *barcodeResultItem = barcodeResult->GetItem(j);
// cout << "Result " << j + 1 << endl;
// cout << "Barcode Format: " << barcodeResultItem->GetFormatString() << endl;
// cout << "Barcode Text: " << barcodeResultItem->GetText() << endl;
// }
// }
// if (barcodeResult)
// barcodeResult->Release();

// result->Release();
// }
}

delete cvr, cvr = NULL, listener, capturedReceiver;
delete cvr, cvr = NULL, listener, capturedReceiver, fileFetcher;
return 0;
}

0 comments on commit 705225b

Please sign in to comment.