|
| 1 | +--- |
| 2 | +layout: default-layout |
| 3 | +title: Accuracy - Dynamsoft Barcode Reader Performance |
| 4 | +description: This page illustrates how to maximize the accuracy of Dynamsoft Barcode Reader |
| 5 | +Keywords: accuracy |
| 6 | +needAutoGenerateSidebar: true |
| 7 | +noTitleIndex: false |
| 8 | +breadcrumbText: Accuracy |
| 9 | +permalink: /performance/accuracy.html |
| 10 | +--- |
| 11 | + |
| 12 | +<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> |
| 13 | + |
| 14 | +<script type="text/x-mathjax-config"> |
| 15 | + |
| 16 | + MathJax.Hub.Config({ |
| 17 | + |
| 18 | + tex2jax: { |
| 19 | + |
| 20 | + skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'], |
| 21 | + |
| 22 | + inlineMath: [['$','$']] |
| 23 | + |
| 24 | + } |
| 25 | + |
| 26 | + }); |
| 27 | + |
| 28 | +</script> |
| 29 | + |
| 30 | +# How to Boost Barcode Reading Accuracy |
| 31 | + |
| 32 | +There are 3 basic metrics for measuring the performance of a barcode reader application: **speed**, **accuracy** and **read-rate**. The Dynamsoft Barcode Reader SDK (DBR) has been carefully designed to have excellent performance in all three of these metrics. In this article, we try to investigate all the possible methods you can take to let DBR focus on **accuracy**. |
| 33 | + |
| 34 | +As the ultimate guide on how to configure DBR to realize its full accuracy potential, we will start with some general methods that are both simple and effective, and then delve into some of the more niche or specific methods to achieve higher accuracy. Lastly, we'll cover some external settings such as those of the Camera Enhancer SDK which can be useful in certain situations. |
| 35 | + |
| 36 | +> The following shows the definition of the three metrics. |
| 37 | +> |
| 38 | +>$ Accuracy = \frac{Number~of~Correctly~Decoded~Barcode~Results}{Number~of~All~Decoded~Barcode~Results} $ |
| 39 | +> |
| 40 | +>$ Speed = \frac{Number~of~All~Decoded~Barcode~Results}{Total~Time~Consumed} $ |
| 41 | +> |
| 42 | +>$ Read~Rate = \frac{Number~of~All~Decoded~Barcode~Results}{Number~of~All~Target~Barcodes} $ |
| 43 | +> |
| 44 | +>Do bear in mind that if one of these metrics is prioritized, the other two may not be ideal. |
| 45 | +
|
| 46 | +## General Settings |
| 47 | + |
| 48 | +The following settings can be applied to nearly all usage scenarios to improve the barcode reading accuracy. |
| 49 | + |
| 50 | +### Filter the Result by Confidence |
| 51 | + |
| 52 | +The confidence attribute of the barcode results is determined by the reliability of that result. Users can set the [`MinResultConfidence`]({{site.dcvb_parameters_reference}}barcode-format-specification/min-result-confidence.html) to make a filter on the barcode results by the confidence value. For Dynamsoft Barcode Reader v8.8 or later, the default value of the confidence is optimized to 30, which can filter out the majority of misread barcode results. A higher `MinResultConfidence` setting will definitely improve the accuracy of the barcode results but reduce the read rate and speed at the same time. Therefore, please set the `MinResultConfidence` according to your actual usage scenario to balance the accuracy, speed read rate. |
| 53 | + |
| 54 | + |
| 55 | +### Enable Multi-frame Verification |
| 56 | + |
| 57 | +For interactive video scenarios, it is possible to receive duplicate results for a single barcode across multiple frames. By adding a `CMultiFrameResultCrossFilter` and enabling result cross-verification, the result is verified and output only if a certain barcode result appears twice or more within the past few frames. Otherwise, it is considered a misread result and discarded. |
| 58 | + |
| 59 | +## Specific Settings |
| 60 | + |
| 61 | +When configuring the specific settings, you have to know some basic information about your usage scenario. This type of information will help exclude undesired barcode results or put a filter on the barcode results. |
| 62 | + |
| 63 | +### Specify the Barcode Formats |
| 64 | + |
| 65 | +The barcode format specification is the most basic decode setting that affects all three metrics of the performance. Sometimes, misreading a 1D barcode is caused by misrecognizing the 1D barcode as another 1D barcode type. If the targeted 1D barcodes are scoped, you can specify the barcode format in your project to lower the probability of misread results. |
| 66 | + |
| 67 | +The related parameters are [ `BarcodeFormatIds` ]({{ site.dcvb_parameters_reference }}barcode-reader-task-settings/barcode-format-ids.html). |
| 68 | + |
| 69 | +### Enable Result Text Filter |
| 70 | + |
| 71 | +When the target barcodes are confirmed, the barcode texts might have common features that help you implement a result filter on the result text. Using the [`BarcodeFormatSpecification`]({{site.dcvb_parameters}}file/auxiliary/barcode-format-specification.html) parameters, you can add barcode result text restrictions like [`regular expression`]({{site.dcvb_parameters_reference}}barcode-format-specification/barcode-text-regex-pattern.html) requirements and [`text length`]({{site.dcvb_parameters_reference}}barcode-format-specification/barcode-text-length-range-array.html) range. |
| 72 | + |
| 73 | + |
| 74 | +### Exclude Small-Module Barcodes |
| 75 | + |
| 76 | +The module size of the barcode refers to the pixel size of the barcode modules (e.g. the pixel width of a 1D barcode line or the smallest cell size of a QR code). The smaller the module size of the barcodes, the higher risk of a misread. If it is not necessary to decode all the small-size barcodes in the scenario, you can skip the small-module barcodes by specifying the minimum acceptable module size of the barcodes via parameter [`ModuleSizeRangeArray`]({{site.dcvb_parameters_reference}}barcode-format-specification/module-size-range-array.html). |
| 77 | + |
| 78 | +When processing large-size images, DBR scales down the images based on the [`ScaleDownThreshold`]({{site.dcvb_parameters_reference}}scale-down-threshold.html) before decoding. However, sometimes the barcode on the image might be shrunk too small. You can increase the [`scaleDownThreshold`]({{site.dcvb_parameters_reference}}image-parameter/scale-down-threshold.html) value to ensure the module size of the barcodes is big enough to get the correct barcode results. |
| 79 | + |
| 80 | +**Recommendation** |
| 81 | + |
| 82 | +By increasing the `MinValue` of the `ModuleSizeRangeArray`, the SDK can skip the small-module barcodes and their potential misreads, thus ensuring a higher accuracy. Increasing the value of `ScaleDownThreshold` can also potentially lead to better accuracy, while lowering it offers better speed. |
| 83 | + |
| 84 | +### Optimize DeblurModes Settings |
| 85 | + |
| 86 | +[`DeblurModes`]({{site.dcvb_parameters_reference}}barcode-reader-task-settings/deblur-modes.html) is the parameter that controls how much effort DBR will spend in processing the located barcodes. It is set to the highest level by default so that DBR will try its best to process every localized barcode even if they are highly blurred. However, the blurriness of the barcodes and the accuracy of the barcode results are inversely proportional. As a result, when the read rate is high enough with the current settings, you can try to simplify the `DeblurModes` array to reduce the possibility of any misreads. |
| 87 | + |
| 88 | +Generally, the simpler the `DeblurModes` array is, the higher the accuracy. As a result, when accuracy is prioritized, the aim is to find the simplest `DeblurModes` configuration that covers the requirements. To find the simplest configuration, it is recommended to approach this from a trial and error standpoint and continuously test each configuration. For this approach, you can start with the full `DeblurModes` array and incrementally reduce the enabled `DeblurModes` till the read rate is no longer acceptable. |
| 89 | + |
| 90 | +**Recommendation** |
| 91 | + |
| 92 | +Please note, `DM_DEEP_ANALYSIS` is the most effective, but most complicated, mode to process blurry barcodes and you can remove this mode first with this approach. `DM_BASED_ON_LOC_BIN` and `DM_THRESHOLD_BINARIZATION` are the most basic `DeblurModes`, and should be kept to retain the minimum barcode decoding capability. |
| 93 | + |
| 94 | +## External Settings – Camera Enhancer Settings |
| 95 | + |
| 96 | +For the interactive video scenarios, promoting the quality of the video will definitely improve the barcode decoding accuracy. Although there is no camera control APIs within the Dynamsoft Barcode Reader API, Dynamsoft Camera Enhancer (DCE) APIs offer the ability to take control of the input video streaming. DCE is an SDK that integrates the camera control API and video frame pre-processing features. It can be easily bound to the Barcode Reader and enables users to optimize the input video streaming when using the Barcode Reader. The following DCE settings and functions can help improve the accuracy of barcode decoding: |
| 97 | + |
| 98 | +### Filter Out the Blurry Frames |
| 99 | + |
| 100 | +When the frame filter feature of DCE is enabled, a quick sharpness evaluation will be implemented on each video frame - low sharpness frames will be discarded to ensure the barcode reader will process high-quality frames only. Since the Barcode Reader doesn't need to process the blurry video frames, the accuracy will be highly improved. |
| 101 | + |
| 102 | +**Recommendation** |
| 103 | + |
| 104 | +The frame-filter feature of DCE can be enabled via the <a href="https://www.dynamsoft.com/camera-enhancer/docs/mobile/programming/android/primary-api/camera-enhancer.html#enableenhancedfeatures" target="_blank">`enableEnhancedFeatures`</a> method. |
| 105 | + |
| 106 | +### Enhance the Camera Focus |
| 107 | + |
| 108 | +It is highly recommended that this feature be implemented on low-end devices. Enhancing the camera focus ability will reduce the blurry frames in the video streaming, which benefits the barcode reading accuracy. |
| 109 | + |
| 110 | + |
| 111 | +**Recommendation** |
| 112 | + |
| 113 | +To enable the enhanced-focus feature of DCE, please use <a href="https://www.dynamsoft.com/camera-enhancer/docs/mobile/programming/android/primary-api/camera-enhancer.html#enableenhancedfeatures" target="_blank">`enableEnhancedFeatures`</a>. |
| 114 | + |
| 115 | +### Set Higher Resolution |
| 116 | + |
| 117 | +A higher resolution will promote the sharpness of the video frames and enlarge the module size of barcodes. Increasing the resolution will definitely benefit the barcode reading accuracy while sacrificing speed. In addition, please remember to set the `MinValue` of `ScaleDownThreshold` to a higher value if you want to decode on high-resolution video streaming. If the `ScaleDownThershold` is smaller than the size of video frames, the video frames will be shrunk to a smaller size before being decoded. |
| 118 | + |
| 119 | +**Recommendation** |
| 120 | + |
| 121 | +To configure the resolution, please use the <a href="https://www.dynamsoft.com/camera-enhancer/docs/mobile/programming/android/primary-api/camera-enhancer.html#setresolution" target="_blank">`setResolution`</a> method. |
| 122 | + |
| 123 | +### Define the Scan Region |
| 124 | + |
| 125 | +Using DCE, you can specify the scan region so that the SDK only works with a specific area of the image or frame. The video frames will be cropped before barcode decoding so that the barcode reader will ignore the areas that are of no interest to the decoding process, thus resulting in faster and more accurate results. |
| 126 | + |
| 127 | +**Recommendation** |
| 128 | + |
| 129 | +You can specify the scan region via the DCE method <a href="https://www.dynamsoft.com/camera-enhancer/docs/mobile/programming/android/primary-api/camera-enhancer.html#setscanregion" target="_blank">`setScanRegion`</a>. |
| 130 | + |
| 131 | +## Summary |
| 132 | + |
| 133 | +In this article, we explored the accuracy-friendly settings. In summary, the methods that improve the accuracy can be categorized as follows: |
| 134 | + |
| 135 | +- Enhance the image/video source before decoding |
| 136 | +- Exclude the areas of the image or frame that are not related to the barcode when decoding |
| 137 | +- Filter out the incorrect results after decoding |
| 138 | + |
| 139 | +Some of the accuracy-friendly settings may benefit the speed or read rate at the same time. For example, when the non-supported barcode formats are excluded, both the processing speed and the accuracy are improved. Hardly does this setting affect the read rate metric. However, some other accuracy-friendly settings, for example, the confidence filter (increasing the `MinResultConfidence`), may worsen both the processing speed and read rate. To adjust the parameter setting to fit your usage scenario, you might need to find the balance between the 3 dimensions of performance. |
| 140 | + |
| 141 | +The following links are the article that explains how to make settings when either speed or read rate is prioritized. Reading the articles will help you further understand the parameter settings and measure how to configure the setting for your own project. |
| 142 | + |
| 143 | +- [How to boost Speed]({{ site.performance }}speed.html) |
| 144 | +- [How to boost Read Rate]({{ site.performance }}read-rate.html) |
| 145 | + |
| 146 | +If you are not sure where to start regarding which dimension of the performance should be prioritized or you are still puzzled by the parameter settings, please feel free to [contact us](https://www.dynamsoft.com/contact/) to get support from our technical support team. Our team can give you professional suggestions on the parameter settings that best fulfill your requirements. |
0 commit comments