Dev Center
Table of contents

How to Preprocess Images based on Different Scenarios

The default configuration of Dynamsoft Barcode Reader (DBR) can handle most common scenarios. However, there are still some specific scenarios where the default configuration of DBR cannot locate the code area for decoding. For these specific scenarios, DBR has built-in ImagePreprocessingModes to configure the image preprocessing algorithm. For different scenarios, a specific pre-processing algorithm can effectively improve the success rate when detecting areas of interest. This article will detail how to choose the appropriate pre-processing mode according to the scenario.

Image preprocessing mode

DBR provides multiple image preprocessing modes to deal with different situations. After configuring the preprocessing modes, we can judge the effectiveness and make adjustments by looking at the intermediate result IRT_PREPROCESSED_IMAGE, which is the pre-processed grayscale image, and IRT_BINARIZED_IMAGE, which is the binarized image. Below we will introduce the scenarios where one of the four modes IPM_GRAY_EQUALIZE, IPM_GRAY_SMOOTH, IPM_SHARPEN_SMOOTH and IPM_MORPHOLOGY helps.

  • IPM_GRAY_EQUALIZE

Gray-level equalization, which is used to enhance the contrast of an image. The sample image below demonstrates the effect, before and after grayscale equalization. The colours of the QR code on the original image (left) is too similar to the background color, which would makes decoding, as is, more difficult. The picture on the right is the result of preprocessing through IPM_GRAY_EQUALIZE. The QR code becomes much more pronounced, which will make the subsequent decoding process much easier.

Before EqualizingAfter Equalizing

This mode has an additional parameter Sensitivity, where the default value is 5, and the range is [1~9]. When you set IPM_GRAY_EQUALIZE, DBR does not necessarily perform equalization but will judge whether to perform it based on the gray distribution and Sensitivity of the image itself. The greater the value of Sensitivity, the more likely that DBR will perform the equalization process. Setting it to 9 means that gray-scale equalization must be performed while 1 means to skip the process.

  • IPM_GRAY_SMOOTH

Grayscale smoothing, which is used to reduce image noise and texture. The following sample image shows a grayscale image with more noise and its corresponding binarized image. Obviously, there are many noises which will be bad for barcode reading.

Grayscale Before SmoothingBinarized Before Smoothing

After configuring IPM_GRAY_SMOOTH for smoothing. The noise of the binarized image are well handled well as shown below.

Grayscale After SmoothingBinarized After Smoothing

  • IPM_SHARPEN_SMOOTH

Sharpening and smoothing are used to reduce blur. The following sample image demonstrates the effect before and after processing in this mode. It is obvious that the processed picture is much clearer.

Before Sharpen-SmoothingAfter Sharpen-Smoothing

  • IPM_MORPHOLOGY

This mode improves the binarization process by eliminating noise and filling holes through corrosion and expansion operations. It is suitable for when the barcode area is polluted or destroyed. The following sample image demonstrates the effect.

Before MorphologyAfter Morphology

Combination of pre-processing modes

If the image to be processed is more complicated, you can use the above image preprocessing modes in combination. After configuring multiple modes through ImagePreprocessingModes, DBR will try each mode in sequence until the number of successful decoded barcodes meets the expected value (ExpectedBarcodeCount), or the algorithm combination is exhausted.

Sample Code

  • Using RuntimeSetting
  • JavaScript
  • C
  • C++
  • C#
  • Java
  • Android
  • Objective-C
  • Swift
  • Python
// Obtains the current runtime settings of DBR.
let rs = await scanner.getRuntimeSettings();
// Sets the preprocessing modes
rs.furtherModes.imagePreprocessingModes[0] = Dynamsoft.DBR.EnumImagePreprocessingMode.IPM_GRAY_EQUALIZE;
rs.furtherModes.imagePreprocessingModes[1] = Dynamsoft.DBR.EnumImagePreprocessingMode.IPM_GRAY_SMOOTH;
rs.furtherModes.imagePreprocessingModes[2] = Dynamsoft.DBR.EnumImagePreprocessingMode.IPM_SHARPEN_SMOOTH;
rs.furtherModes.imagePreprocessingModes[3] = Dynamsoft.DBR.EnumImagePreprocessingMode.IPM_MORPHOLOGY;
// Updates the settings.
await scanner.updateRuntimeSettings(rs);
// Fine-tunes some arguments of these modes
scanner.setModeArgument("imagePreprocessingModes", 0, "Sensitivity", "9");
scanner.setModeArgument("imagePreprocessingModes", 1, "SmoothBlockSizeX", "10");
scanner.setModeArgument("imagePreprocessingModes", 1, "SmoothBlockSizeY", "10");
scanner.setModeArgument("imagePreprocessingModes", 2, "SharpenBlockSizeX", "5");
scanner.setModeArgument("imagePreprocessingModes", 2, "SharpenBlockSizeY", "5");
scanner.setModeArgument("imagePreprocessingModes", 3, "MorphOperation", "Close");
scanner.setModeArgument("imagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7");
scanner.setModeArgument("imagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7");
await scanner.show();
int iRet = -1;
char errorBuf[512];
iRet = DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    printf("%s\n", errorBuf);
}
void* barcodeReader = DBR_CreateInstance();
PublicRuntimeSettings runtimeSettings;
DBR_GetRuntimeSettings(barcodeReader, &runtimeSettings); //Get the current RuntimeSettings
runtimeSettings.furtherModes.imagePreprocessingModes[0] = IPM_GRAY_EQUALIZE;
runtimeSettings.furtherModes.imagePreprocessingModes[1] = IPM_GRAY_SMOOTH;
runtimeSettings.furtherModes.imagePreprocessingModes[2] = IPM_SHARPEN_SMOOTH;
runtimeSettings.furtherModes.imagePreprocessingModes[3] = IPM_MORPHOLOGY;
DBR_UpdateRuntimeSettings(barcodeReader, &runtimeSettings, errorBuf, 512); // Update RuntimeSettings with above setting
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 0, "Sensitivity", "9", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 3, "MorphOperation", "Close", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7", sError, 512);
DBR_SetModeArgument(barcodeReader, "ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7", sError, 512);
DBR_DecodeFile(barcodeReader, "YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
char errorBuf[512];
int iRet = -1;
iRet = dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    cout << errorBuf << endl;
}
CBarcodeReader* reader = new CBarcodeReader();
PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();
reader->GetRuntimeSettings(runtimeSettings); //Get the current RuntimeSettings
runtimeSettings->furtherModes.imagePreprocessingModes[0] = IPM_GRAY_EQUALIZE;
runtimeSettings->furtherModes.imagePreprocessingModes[1] = IPM_GRAY_SMOOTH;
runtimeSettings->furtherModes.imagePreprocessingModes[2] = IPM_SHARPEN_SMOOTH;
runtimeSettings->furtherModes.imagePreprocessingModes[3] = IPM_MORPHOLOGY;
reader->UpdateRuntimeSettings(runtimeSettings, errorBuf, 512); // Update RuntimeSettings with above setting
reader->SetModeArgument("ImagePreprocessingModes", 0, "Sensitivity", "9", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 3, "MorphOperation", "Close", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7", sError, 512);
reader->SetModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7", sError, 512);
reader->DecodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
string errorMsg;
EnumErrorCode iRet = BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
if (iRet != EnumErrorCode.DBR_SUCCESS)
{
    Console.WriteLine(errorMsg);
}
BarcodeReader reader = new BarcodeReader();
PublicRuntimeSettings settings = reader.GetRuntimeSettings(); //Get the current RuntimeSettings
settings.FurtherModes.ImagePreprocessingModes[0] = EnumImagePreprocessingMode.IPM_GRAY_EQUALIZE;
settings.FurtherModes.ImagePreprocessingModes[1] = EnumImagePreprocessingMode.IPM_GRAY_SMOOTH;
settings.FurtherModes.ImagePreprocessingModes[2] = EnumImagePreprocessingMode.IPM_SHARPEN_SMOOTH;
settings.FurtherModes.ImagePreprocessingModes[3] = EnumImagePreprocessingMode.IPM_MORPHOLOGY;
reader.UpdateRuntimeSettings(settings); // Update RuntimeSettings with above setting
reader.SetModeArgument("ImagePreprocessingModes", 0, "Sensitivity", "9", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 3, "MorphOperation", "Close", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7", out errorMsg);
reader.SetModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7", out errorMsg);
TextResult[] result = reader.DecodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = new BarcodeReader();
PublicRuntimeSettings settings = reader.getRuntimeSettings(); //Get the current RuntimeSettings
settings.furtherModes.imagePreprocessingModes[0] = EnumImagePreprocessingMode.IPM_GRAY_EQUALIZE;
settings.furtherModes.imagePreprocessingModes[1] = EnumImagePreprocessingMode.IPM_GRAY_SMOOTH;
settings.furtherModes.imagePreprocessingModes[2] = EnumImagePreprocessingMode.IPM_SHARPEN_SMOOTH;
settings.furtherModes.imagePreprocessingModes[3] = EnumImagePreprocessingMode.IPM_MORPHOLOGY;
reader.updateRuntimeSettings(settings); // Update RuntimeSettings with above setting
reader.setModeArgument("ImagePreprocessingModes", 0, "Sensitivity", "9");
reader.setModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10");
reader.setModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10");
reader.setModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5");
reader.setModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperation", "Close");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7");
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = new BarcodeReader();
PublicRuntimeSettings settings = reader.getRuntimeSettings(); //Get the current RuntimeSettings
settings.furtherModes.imagePreprocessingModes[0] = EnumImagePreprocessingMode.IPM_GRAY_EQUALIZE;
settings.furtherModes.imagePreprocessingModes[1] = EnumImagePreprocessingMode.IPM_GRAY_SMOOTH;
settings.furtherModes.imagePreprocessingModes[2] = EnumImagePreprocessingMode.IPM_SHARPEN_SMOOTH;
settings.furtherModes.imagePreprocessingModes[3] = EnumImagePreprocessingMode.IPM_MORPHOLOGY;
reader.updateRuntimeSettings(settings); // Update RuntimeSettings with above setting
reader.setModeArgument("ImagePreprocessingModes", 0, "Sensitivity", "9");
reader.setModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10");
reader.setModeArgument("ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10");
reader.setModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5");
reader.setModeArgument("ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperation", "Close");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7");
reader.setModeArgument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7");
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-PATH"); // Start decoding
// Add further process
NSError *err = nil;
DynamsoftBarcodeReader* reader = [[DynamsoftBarcodeReader alloc] init];
iPublicRuntimeSettings* settings = [reader getRuntimeSettings:&err];//Get the current RuntimeSettings
settings.furtherModes.imagePreprocessingModes[0] = EnumImagePreprocessingModeGrayEqualize;
settings.furtherModes.imagePreprocessingModes[1] = EnumImagePreprocessingModeGraySmooth;
settings.furtherModes.imagePreprocessingModes[2] = EnumImagePreprocessingModeSharpenSmooth;
settings.furtherModes.imagePreprocessingModes[3] = EnumImagePreprocessingModeMorphology;
[reader updateRuntimeSettings:settings error:&err]; // Update RuntimeSettings with above setting
[reader setModeArgument:@"ImagePreprocessingModes" index:0 argumentName:@"Sensitivity" argumentValue:@"9" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:1 argumentName:@"SmoothBlockSizeX" argumentValue:@"10" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:1 argumentName:@"SmoothBlockSizeY" argumentValue:@"10" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:2 argumentName:@"SharpenBlockSizeX" argumentValue:@"5" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:2 argumentName:@"SharpenBlockSizeY" argumentValue:@"5" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:3 argumentName:@"MorphOperation" argumentValue:@"Close" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:3 argumentName:@"MorphOperationKernelSizeX" argumentValue:@"7" error:&err];
[reader setModeArgument:@"ImagePreprocessingModes" index:3 argumentName:@"MorphOperationKernelSizeY" argumentValue:@"7" error:&err];
NSArray<iTextResult*>* result = [reader decodeFileWithName:@"YOUR-IMAGE-FILE-PATH" error:&err]; // Start decoding
// Add further process
let reader = DynamsoftBarcodeReader.init()
let settings = try? reader.getRuntimeSettings() //Get the current RuntimeSettings
settings?.furtherModes.imagePreprocessingModes = [EnumImagePreprocessingMode.grayEqualize, EnumImagePreprocessingMode.graySmooth, EnumImagePreprocessingMode.sharpenSmooth, EnumImagePreprocessingMode.morphology]
do {
    try reader.updateRuntimeSettings(settings) // Update RuntimeSettings with above setting
    try reader.setModeArgument("ImagePreprocessingModes", index:0, argumentName:"Sensitivity", argumentValue:"9")
    try reader.setModeArgument("ImagePreprocessingModes", index:1, argumentName:"SmoothBlockSizeX", argumentValue:"10")
    try reader.setModeArgument("ImagePreprocessingModes", index:1, argumentName:"SmoothBlockSizeY", argumentValue:"10")
    try reader.setModeArgument("ImagePreprocessingModes", index:2, argumentName:"SharpenBlockSizeX", argumentValue:"5")
    try reader.setModeArgument("ImagePreprocessingModes", index:2, argumentName:"SharpenBlockSizeY", argumentValue:"5")
    try reader.setModeArgument("ImagePreprocessingModes", index:3, argumentName:"MorphOperation", argumentValue:"Close")
    try reader.setModeArgument("ImagePreprocessingModes", index:3, argumentName:"MorphOperationKernelSizeX", argumentValue:"7")
    try reader.setModeArgument("ImagePreprocessingModes", index:3, argumentName:"MorphOperationKernelSizeY", argumentValue:"7")
    let result = try reader.decodeFileWithName("YOUR-IMAGE-FILE-PATH") // Add further process
} catch let err {
}
// Add further process
error = BarcodeReader.init_license("YOUR-LICENSE-KEY")
if error[0] != EnumErrorCode.DBR_OK:
    print(error[1])
dbr = BarcodeReader()
settings = dbr.get_runtime_settings()
settings.image_preprocessing_modes[0] = EnumImagePreprocessingMode.IPM_GRAY_EQUALIZE
settings.image_preprocessing_modes[1] = EnumImagePreprocessingMode.IPM_GRAY_SMOOTH
settings.image_preprocessing_modes[2] = EnumImagePreprocessingMode.IPM_SHARPEN_SMOOTH
settings.image_preprocessing_modes[3] = EnumImagePreprocessingMode.IPM_MORPHOLOGY
dbr.update_runtime_settings(settings)
dbr.set_mode_argument("ImagePreprocessingModes", 0, "Sensitivity", "9")
dbr.set_mode_argument("ImagePreprocessingModes", 1, "SmoothBlockSizeX", "10")
dbr.set_mode_argument("ImagePreprocessingModes", 1, "SmoothBlockSizeY", "10")
dbr.set_mode_argument("ImagePreprocessingModes", 2, "SharpenBlockSizeX", "5")
dbr.set_mode_argument("ImagePreprocessingModes", 2, "SharpenBlockSizeY", "5")
dbr.set_mode_argument("ImagePreprocessingModes", 3, "MorphOperation", "Close")
dbr.set_mode_argument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeX", "7")
dbr.set_mode_argument("ImagePreprocessingModes", 3, "MorphOperationKernelSizeY", "7")
text_results = dbr.decode_file("YOUR-IMAGE-FILE-PATH")
# Add further process
  • Using a JSON template
  • JavaScript
  • C
  • C++
  • C#
  • Java
  • Android
  • Objective-C
  • Swift
  • Python
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
// Defines settings for the preprocessing in a template.
let jsonString = "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}";
// Configures the BarcodeScanner object with the settings.
await scanner.initRuntimeSettingsWithString(jsonString);
scanner.show();
int iRet = -1;
char errorBuf[512];
iRet = DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    printf("%s\n", errorBuf);
}
void* barcodeReader = DBR_CreateInstance();
DBR_InitRuntimeSettingsWithString(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", CM_OVERWRITE, errorBuf, 512);
DBR_DecodeFile(barcodeReader, "YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
char errorBuf[512];
int iRet = -1;
iRet = dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    cout << errorBuf << endl;
}
CBarcodeReader* reader = new CBarcodeReader();
reader->InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", CM_OVERWRITE, errorBuf, 512);
reader->DecodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
string errorMsg;
EnumErrorCode iRet = BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
if (iRet != EnumErrorCode.DBR_SUCCESS)
{
    Console.WriteLine(errorMsg);
}
BarcodeReader reader = new BarcodeReader();
reader.InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", EnumConflictMode.CM_OVERWRITE, out errorMsg);
TextResult[] result = reader.DecodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = new BarcodeReader();
reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", EnumConflictMode.CM_OVERWRITE);
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-PATH", ""); // Start decoding
// Add further process
BarcodeReader reader = new BarcodeReader();
reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", EnumConflictMode.CM_OVERWRITE);
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-PATH"); // Start decoding
// Add further process
NSError* error = nil;
DynamsoftBarcodeReader* reader = [[DynamsoftBarcodeReader alloc] init];
[reader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}" confictMode:EnumConflictModeOverwrite error:&error];
NSArray<iTextResult*>* result = [reader decodeFileWithName:@"YOUR-IMAGE-FILE-PATH" error:&err]; // Start decoding
// Add further process
let reader = DynamsoftBarcodeReader()
try? reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\",\"ImagePreprocessingModes\": [{\"Mode\": \"IPM_GRAY_EQUALIZE\",\"Sensitivity\": 9},{\"Mode\": \"IPM_GRAY_SMOOTH\",\"SmoothBlockSizeX\": 10,\"SmoothBlockSizeY\": 10},{\"Mode\": \"IPM_SHARPEN_SMOOTH\",\"SharpenBlockSizeX\": 5,\"SharpenBlockSizeY\": 5},{\"Mode\": \"IPM_MORPHOLOGY\",\"MorphOperation\": \"Close\",\"MorphOperationKernelSizeX\": 7,\"MorphOperationKernelSizeY\": 7}]}}", confictMode:EnumConflictMode.overwrite)
let result = try? reader.decodeFileWithName("YOUR-IMAGE-FILE-PATH") // Start decoding
// Add further process
error = BarcodeReader.init_license("YOUR-LICENSE-KEY")
if error[0] != EnumErrorCode.DBR_OK:
    print(error[1])
dbr = BarcodeReader()
dbr.init_runtime_settings_with_string('{"Version":"3.0", "ImageParameter":{"Name":"IP1","ImagePreprocessingModes": [{"Mode": "IPM_GRAY_EQUALIZE","Sensitivity": 9},{"Mode": "IPM_GRAY_SMOOTH","SmoothBlockSizeX": 10,"SmoothBlockSizeY": 10},{"Mode": "IPM_SHARPEN_SMOOTH","SharpenBlockSizeX": 5,"SharpenBlockSizeY": 5},{"Mode": "IPM_MORPHOLOGY","MorphOperation": "Close","MorphOperationKernelSizeX": 7,"MorphOperationKernelSizeY": 7}]}}')
text_results = dbr.decode_file("YOUR-IMAGE-FILE-PATH")
# Add further process

This page is compatible for:

Is this page helpful?

YesYes NoNo

version 9.6.42

  • 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 +