# Migrate from 9.x to 11.x

Dynamsoft Barcode Reader SDK has been refactored to integrate with the [`DynamsoftCaptureVision (DCV)`](https://www.dynamsoft.com/capture-vision/docs/core/architecture/index.md) architecture since version 10.0. This guide helps you upgrade from version 9.x by highlighting the key API changes and providing migration paths.

The actual migration effort depends on which APIs you currently use. In many cases, only the interfaces you actively use need to be updated - review the sections below to identify the changes that affect your integration.

> [!NOTE]
> If you are new to the DCV architecture and prefer to start fresh, refer to the [User Guide](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/user-guide.md) for a quick-start tutorial.

## Update the License Key

You may need to update your license key before upgrading to version 11.x.

- **30-Day Free Trial License**: Visit the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=docs){:target="_blank"} page to obtain a free license for evaluation.
- **Annual Online Full License**: Your license will continue to work with the new SDK version. Go to <a href="https://www.dynamsoft.com/customer/license/fullLicense" target="_blank">Customer Portal</a> to get your license key.
- **Perpetual License**: Please contact our [sales team](https://www.dynamsoft.com/contact){:target="_blank"} to update your license.

## Migrate Project Configuration

Since the SDK architecture has changed, you need to update your project configuration including headers, libraries, and runtime files.

### Update Headers and Libraries

```cpp
#include "[INSTALLATION FOLDER]/Include/DynamsoftCaptureVisionRouter.h"

using namespace std;
using namespace dynamsoft::license;
using namespace dynamsoft::cvr;
using namespace dynamsoft::dbr;
using namespace dynamsoft::utility;

#if defined(_WIN64) || defined(_WIN32)
    #ifdef _WIN64
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x64/DynamsoftCorex64.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x64/DynamsoftLicensex64.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x64/DynamsoftCaptureVisionRouterx64.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x64/DynamsoftUtilityx64.lib")
    #else
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x86/DynamsoftCorex86.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x86/DynamsoftLicensex86.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x86/DynamsoftCaptureVisionRouterx86.lib")
        #pragma comment(lib, "[INSTALLATION FOLDER]/Dist/Lib/Windows/x86/DynamsoftUtilityx86.lib")
    #endif
#endif
```

### Deploy Runtime Files

- Copy the folders `Templates` and `Models` under `[INSTALLATION FOLDER]/Dist/` to the same folder as the executable program.
- Copy the libraries to the same folder as the executable program.
  - For Windows: Copy **ALL** `*.dll` files under `[INSTALLATION FOLDER]/Dist/Lib/Windows/[platform]`. Replace `[platform]` with your project's platform setting.
  - For Linux: Copy **ALL** `*.so` files under `[INSTALLATION FOLDER]/Dist/Lib/Linux/[platform]`. Replace `[platform]` with your project's platform setting.

## Migrate License Activation Code

Starting from 10.0, we have unified the API for setting licenses across different Dynamsoft products.

| Old APIs | New APIs |
| :----------- | :------- |
| `CBarcodeReader.InitLicense` | [CLicenseManager.InitLicense](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/license/license-manager.md#initlicense) |

## Migrate Decoding APIs

### Single Image Decoding

The APIs for decoding single image have been adjusted as follows:

| Old APIs | New APIs |
| :----------- | :------- |
| `CBarcodeReader.DecodeFile` | [CCaptureVisionRouter.Capture](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capture) or [CCaptureVisionRouter.CaptureMultiPages](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capturemultipages) |
| `CBarcodeReader.DecodeFileInMemory` | [CCaptureVisionRouter.Capture](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capture) or [CCaptureVisionRouter.CaptureMultiPages](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capturemultipages) |
| `CBarcodeReader.DecodeBuffer` | [CCaptureVisionRouter.Capture](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capture) |
| `struct TextResult` | [class CBarcodeResultItem](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/barcode-result-item.md) |
| `struct TextResultArray` | [class CCapturedResult](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/auxiliary-classes/captured-result.md) |
| `CBarcodeReader.DecodeBase64String` | [CImageIO.ReadFromBase64String](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/utility/image-io.md#readfrombase64string) + [CCaptureVisionRouter.Capture](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/single-file-processing.md#capture) |
| `CBarcodeReader.DecodeDIB` | **Not available**. |

### Video Streaming Decoding

`CImageSourceAdapter` is added to replace the `FrameDecodingParameters` and the previous video methods. You should implement `CImageSourceAdapter` to transfer image data from camera or video file to buffer. The following code snippet demonstrates basic usage of decoding video frames:

```cpp
class MyVideoSource : public CProactiveImageSourceAdapter 
{
    // You should implement the `HasNextImageToFetch` method to indicate if there is a next frame
    bool HasNextImageToFetch() const override 
    {
        return true;
    }

    // You should implement the `FetchImage` method to get the next frame
    CImageData* FetchImage() override
    {
        // Add code to get the video frame from camera or video file
    }
};

class MyBarcodeResultReceiver: public CCapturedResultReceiver
{
public:
    virtual void OnDecodedBarcodesReceived(CDecodedBarcodesResult* result) {
        // Add code to process the result
    }
};

int main()
{
    CCaptureVisionRouter *cvRouter = new CCaptureVisionRouter;

    // Create your video source and bind it to the router
    MyVideoSource *source = new MyVideoSource;
    cvRouter->SetInput(source);

    // Create a CCapturedResultReceiver instance 
    MyBarcodeResultReceiver *barcodesReceiver = new MyBarcodeResultReceiver;
    cvRouter->AddResultReceiver(barcodesReceiver);

    // Start capturing
    char errorMsg[512] = {0};
    int errorCode = cvRouter->StartCapturing(CPresetTemplate::PT_READ_BARCODES, true, errorMsg, 512);

    delete barcodesReceiver;
    delete source;
    delete cvRouter;
}
```

## Upgrade Template Files

The template file format has changed in the new version. Templates created for version 9.x are not compatible with version 11.x. Use the <a href="https://www.dynamsoft.com/tools/template-upgrade/" target="_blank">Template Upgrade Tool</a> to automatically convert your existing templates to the new format.


## Migrate Template APIs

The template-based APIs have been updated as follows:

| Old APIs | New APIs |
| :----------- | :------- |
| `CBarcodeReader.InitRuntimeSettingsWithFile` | [CCaptureVisionRouter.InitSettingsFromFile](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#initsettingsfromfile) |
| `CBarcodeReader.InitRuntimeSettingsWithString` | [CCaptureVisionRouter.InitSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#initsettings) |
| `CBarcodeReader.OutputSettingsToFile` | [CCaptureVisionRouter.OutputSettingsToFile](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#outputsettingstofile) |
| `CBarcodeReader.OutputSettingsToString` | [CCaptureVisionRouter.OutputSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#outputsettings) |
| `CBarcodeReader.ResetRuntimeSettings` | [CCaptureVisionRouter.ResetSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#resetsettings) |
| `CBarcodeReader.AppendTplFileToRuntimeSettings` | **Not available**. |
| `CBarcodeReader.AppendTplStringToRuntimeSettings` | **Not available**. |

## Migrate Runtime Settings

The struct `PublicRuntimeSettings` has been refactored. It retains commonly used properties while removing the previously complex property settings, which are now exclusively supported through templates.

The APIs for accessing and updating `PublicRuntimeSettings` have been adjusted as follows:

| Old APIs | New APIs |
| :----------- | :------- |
| `CBarcodeReader.GetRuntimeSettings` | [CCaptureVisionRouter.GetSimplifiedSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#getsimplifiedsettings) |
| `CBarcodeReader.UpdateRuntimeSettings` | [CCaptureVisionRouter.UpdateSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/settings.md#updatesettings) |

### Properties with Direct API Replacement

The following properties are replaced by similar properties under `SimplifiedCaptureVisionSettings` or `SimplifiedBarcodeReaderSettings`. They can also be set via a template file.

#### SimplifiedCaptureVisionSettings

| PublicRuntimeSettings Property | SimplifiedCaptureVisionSettings Parameter | Template File Parameter |
| ------------------------------- | ----------------------------------------- | ----------------------- |
| `region` | [`roi`](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/structs/simplified-capture-vision-settings.md#roi) & [`roiMeasuredInPercentage`](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/structs/simplified-capture-vision-settings.md#roimeasuredinpercentage) | [`TargetROIDef.Location.Offset`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/target-roi-def/location.md) |
| `timeout` | [`timeout`](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/capture-vision-router/structs/simplified-capture-vision-settings.md#timeout) | [`CaptureVisionTemplates.Timeout`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/capture-vision-template/timeout.md) |

#### SimplifiedBarcodeReaderSettings

| PublicRuntimeSettings Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
| ------------------------------- | ----------------------------------------- | ----------------------- |
| `minBarcodeTextLength` | [`minBarcodeTextLength`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#minbarcodetextlength) | [`BarcodeFormatSpecification.BarcodeTextLengthRangeArray`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-format-specification/barcode-text-length-range-array.md) |
| `minResultConfidence` | [`minResultConfidence`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#minresultconfidence) | [`BarcodeFormatSpecification.MinResultConfidence`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-format-specification/min-result-confidence.md) |
| `localizationModes` | [`localizationModes`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#localizationmodes) | [`BarcodeReaderTaskSetting.LocalizationModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/localization-modes.md) |
| `expectedBarcodesCount` | [`expectedBarcodesCount`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#expectedbarcodescount) | [`BarcodeReaderTaskSetting.ExpectedBarcodesCount`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/expected-barcodes-count.md) |
| `barcodeFormatIds` | [`barcodeFormatIds`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#barcodeformatids) | [`BarcodeReaderTaskSetting.BarcodeFormatIds`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/barcode-format-ids.md) |
| `barcodeFormatIds_2` | [`barcodeFormatIds`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#barcodeformatids) | [`BarcodeReaderTaskSetting.BarcodeFormatIds`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/barcode-format-ids.md) |
| `deblurModes` | [`deblurModes`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#deblurmodes) | [`BarcodeReaderTaskSetting.DeblurModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/deblur-modes.md) |
| `deblurLevel` | [`deblurModes`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#deblurmodes) | [`BarcodeReaderTaskSetting.DeblurModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/deblur-modes.md) |
| `maxAlgorithmThreadCount` | [`maxThreadsInOneTask`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#maxthreadsinonetask) | [`BarcodeReaderTaskSetting.MaxThreadsInOneTask`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/max-threads-in-one-task.md) |

> Remarks:
>
> * The 2 groups of barcode formats are merged.
> * `DeblurLevel` is deprecated. You can use `DeblurModes` instead.

| FurtherModes Property | SimplifiedBarcodeReaderSettings Property | Template File Parameter |
| ---------------------- | ----------------------------------------- | ----------------------- |
| `grayscaleTransformationModes` | [`grayscaleTransformationModes`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#grayscaletransformationmodes) | [`ImageParameter.GrayscaleTransformationModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/grayscale-transformation-modes.md) |
| `imagePreprocessingModes` | [`grayscaleEnhancementModes`](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/api-reference/simplified-barcode-reader-settings.md#grayscaleenhancementmodes) | [`ImageParameter.GrayscaleEnhancementModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/grayscale-enhancement-modes.md) |

> Remarks: The mode `IPM_MORPHOLOGY` of `imagePreprocessingModes` is migrated to `BinarizationModes`. The mode arguments `MorphOperation`, `MorphOperationKernelSizeX`, `MorphOperationKernelSizeY`, `MorphShape` are now available for all modes of `BinarizationModes`.

### Properties Requiring Template File

The following properties can only be set via a template file. Please call `CBarcodeReader.OutputSettingsToFile` first with the old version to export the settings and then use the <a href="https://www.dynamsoft.com/tools/template-upgrade/" target="_blank">template upgrade tool</a> to upgrade your template.

| PublicRuntimeSettings Property | Template File Parameter |
| ------------------------------- | ----------------------- |
| `scaleDownThreshold` | [`ImageParameter.ImageScaleSettings`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/image-scale-settings.md) |
| `binarizationModes` | [`ImageParameter.BinarizationModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/binarization-modes.md) |
| `textResultOrderModes` | [`BarcodeReaderTaskSetting.TextResultOrderModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/text-result-order-modes.md) |
| `returnBarcodeZoneClarity` | [`BarcodeReaderTaskSetting.ReturnBarcodeZoneClarity`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/return-barcode-zone-clarity.md) |
| `scaleUpModes` | [`BarcodeReaderTaskSetting.BarcodeScaleModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/barcode-scale-modes.md) |
| `barcodeZoneMinDistanceToImageBorders` | [`BarcodeFormatSpecification.BarcodeZoneMinDistanceToImageBorders`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-format-specification/barcode-zone-min-distance-to-image-borders.md) |

| FurtherModes Property | Template File Parameter |
| ---------------------- | ----------------------- |
| `colourConversionModes` | [`ImageParameter.ColourConversionModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/colour-conversion-modes.md) |
| `regionPredetectionModes` | [`BarcodeReaderTaskSetting.RegionPredetectionModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/region-predetection-modes.md) |
| `textureDetectionModes` | [`ImageParameter.TextureDetectionModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/texture-detection-modes.md) |
| `textFilterModes` | [`ImageParameter.TextDetectionMode`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/text-detection-mode.md) & [`ImageParameter.IfEraseTextZone`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/image-parameter/if-erase-text-zone.md) |
| `dpmCodeReadingModes` | [`BarcodeReaderTaskSetting.DPMCodeReadingModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/dpm-code-reading-modes.md) |
| `deformationResistingModes` | [`BarcodeReaderTaskSetting.DeformationResistingModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/deformation-resisting-modes.md) |
| `barcodeComplementModes` | [`BarcodeReaderTaskSetting.BarcodeComplementModes`](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/barcode-reader-task-settings/barcode-complement-modes.md) |

### Properties Migrated to Other APIs

The PDF properties of PublicRuntimeSettings are moved to set via the `setPDFReadingParameter` method of `CDirectoryFetcher` and `CFileFetcher` with a [`CPDFReadingParameter`](https://www.dynamsoft.com/capture-vision/docs/server/programming/cplusplus/api-reference/core/basic-structures/pdf-reading-parameter.md) parameter.

| PublicRuntimeSettings Property |
| --------------------------------------- |
| `pdfReadingMode` |
| `pdfRasterDPI` |

### Removed Properties (No Replacement)

The following properties are removed.

| PublicRuntimeSettings Property|
| --------------------- |
| `barcodeColourModes` |
| `intermediateResultTypes` |
| `intermediateResultSavingMode` |
| `resultCoordinateType` |
| `terminatePhase` |

| FurtherModes Property|
| --------------------- |
| `colourClusteringModes` |
