Dev Center
Table of contents

How to Use Intermediate Results

Apart from getting the results like barcode type, value, location, Dynamsoft Barcode Reader (DBR) also provides APIs for you to obtain the intermediate results like original image, transformed grayscale image, binarized image, text zone, and more for further analysis. See enum IntermediateResultUnitType for the full list of supported intermediate result types. All these results can be obtained from a specific callback function within the class CIntermediateResultReceiver.

Note: You will need a separate license to obtain the intermediate results.

Here we will show how to save the binarized image to your file system and output the localized barcode zone:

  • C++
class MyIntermediateResultReceiver : public CIntermediateResultReceiver
{
public:
    virtual void OnBinaryImageUnitReceived(CBinaryImageUnit* pResult, const IntermediateResultExtraInfo* info)
    {
        const CImageData* img = pResult->GetImageData();
        CImageManager* imgManager = new CImageManager;
        imgManager->SaveToFile(img, "FULL-FILE-PATH", true);
        delete imgManager, imgManager = NULL;
    }
    virtual void OnLocalizedBarcodesReceived(CLocalizedBarcodesUnit* pResult, const IntermediateResultExtraInfo* info)
    {
        int count = pResult->GetCount();
        cout << "Localized " << count << " items" << endl;
        for (int i = 0; i < count; i++) {
            const CLocalizedBarcodeElement* locBarcode = pResult->GetLocalizedBarcode(i);
            CQuadrilateral location = locBarcode->GetLocation();
            cout << "Result " << i + 1 << endl;
            cout << "    Point 0: [" << location.points[0][0] << ", " << location.points[0][1] << "]" << endl;
            cout << "    Point 1: [" << location.points[1][0] << ", " << location.points[1][1] << "]" << endl;
            cout << "    Point 2: [" << location.points[2][0] << ", " << location.points[2][1] << "]" << endl;
            cout << "    Point 3: [" << location.points[3][0] << ", " << location.points[3][1] << "]" << endl;
        }
    }
};
int main()
{
    CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
    CDirectoryFetcher* dirFetcher = new CDirectoryFetcher;
    dirFetcher->SetDirectory("THE-DIRECTORY-THAT-HOLDS-THE-IMAGES");
    cvr->SetInput(dirFetcher);
    CIntermediateResultManager* irm = cvr->GetIntermediateResultManager();
    CIntermediateResultReceiver* irr = new MyIntermediateResultReceiver();
    irm->AddResultReceiver(irr);
    cvr->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true);
}

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.2.0
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.42
    • Version 9.6.40
    • Version 9.6.33
    • Version 9.6.32
    • Version 9.6.31
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.0
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
  • Documentation Homepage
Change +