Skip to content

Commit ea243d0

Browse files
authored
Update Program.cs
1 parent 814bffa commit ea243d0

File tree

1 file changed

+40
-1
lines changed
  • samples/Performance/AccuracyFirstSettings

1 file changed

+40
-1
lines changed

samples/Performance/AccuracyFirstSettings/Program.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,32 @@ class Program
88
{
99
static public void configAccuracyFirst(ref BarcodeReader dbr)
1010
{
11+
// Obtain current runtime settings of instance.
1112
PublicRuntimeSettings settings = dbr.GetRuntimeSettings();
13+
14+
// 1. Set expected barcode format
15+
// The more precise the barcode format is set, the higher the accuracy.
16+
// Mostly, misreading only occurs on reading oneD barcode. So here we use OneD barcode format to demonstrate.
1217
settings.BarcodeFormatIds = (int)EnumBarcodeFormat.BF_ONED;
1318
settings.BarcodeFormatIds_2 = (int)EnumBarcodeFormat.BF_NULL;
19+
20+
// 2. Set the minimal result confidence.
21+
// The greater the confidence, the higher the accuracy.
22+
// Filter by minimal confidence of the decoded barcode. We recommend using 30 as the default minimal confidence value
1423
settings.MinResultConfidence = 30;
24+
25+
// 3. Sets the minimum length of barcode text for filtering.
26+
// The more precise the barcode text length is set, the higher the accuracy.
1527
settings.MinBarcodeTextLength = 6;
28+
29+
// Apply the new settings to the instance
1630
dbr.UpdateRuntimeSettings(settings);
1731

1832
}
1933
static public void configAccuracyFirstByTemplate(ref BarcodeReader mBarcodeReader)
2034
{
35+
// Compared with PublicRuntimeSettings, parameter templates have a richer ability to control parameter details.
36+
// Please refer to the parameter explanation in "AccuracyFirstTemplate.json" to understand how to control accuracy first.
2137
string strErrorMessage;
2238
EnumErrorCode ret = mBarcodeReader.InitRuntimeSettingsWithFile("AccuracyFirstTemplate.json", EnumConflictMode.CM_OVERWRITE, out strErrorMessage);
2339
}
@@ -44,31 +60,54 @@ static void Main(string[] args)
4460
{
4561
try
4662
{
63+
// Initialize license
64+
/*
65+
// By setting organizaion ID as "200001", a 7-day trial license will be used for license verification.
66+
// Note that network connection is required for this license to work.
67+
//
68+
// When using your own license, locate the following line and specify your Organization ID.
69+
// organizationID = "200001";
70+
//
71+
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=dotnet
72+
*/
4773
DMDLSConnectionParameters connectionInfo = BarcodeReader.InitDLSConnectionParameters();
4874
connectionInfo.OrganizationID = "200001";
4975
EnumErrorCode errorCode = BarcodeReader.InitLicenseFromDLS(connectionInfo, out string errorMsg);
5076
if (errorCode != EnumErrorCode.DBR_SUCCESS)
5177
{
5278
Console.WriteLine(errorMsg);
5379
}
54-
80+
81+
// Create an instance of Barcode Reader
5582
BarcodeReader dbr = new BarcodeReader();
5683
TextResult[] results = null;
5784
string fileName = "../../../../../images/AllSupportedBarcodeTypes.png";
5885

86+
// Accuracy = The number of correctly decoded barcodes/the number of all decoded barcodes
87+
// There are two ways to configure runtime parameters. One is through PublicRuntimeSettings, the other is through parameters template.
5988
Console.WriteLine("Decode through PublicRuntimeSettings:");
6089
{
90+
// config through PublicRuntimeSettings
6191
configAccuracyFirst(ref dbr);
92+
93+
// Decode barcodes from an image file by current runtime settings. The second parameter value "" means to decode through the current PublicRuntimeSettings.
6294
results = dbr.DecodeFile(fileName, "");
95+
96+
// Output the barcode format and barcode text.
6397
outputResults(results);
6498
}
6599

66100
Console.WriteLine("\r\n");
67101

68102
Console.WriteLine("Decode through parameters template:");
69103
{
104+
// config through parameters template
70105
configAccuracyFirstByTemplate(ref dbr);
106+
107+
// Decode barcodes from an image file by template.
71108
results = dbr.DecodeFile(fileName,"");
109+
110+
// Output the barcode format and barcode text.
72111
outputResults(results);
73112
}
74113
}

0 commit comments

Comments
 (0)