Skip to content

Commit c3e7966

Browse files
Merge branch 'main' into main
2 parents 443c59c + 3661fcf commit c3e7966

File tree

3 files changed

+68
-68
lines changed

3 files changed

+68
-68
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
License Notice
22

3-
This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement   https://www.dynamsoft.com/barcode-reader/license-agreement/ (Commercial License). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3+
This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement   https://www.dynamsoft.com/barcode-reader/license-agreement/ ("Commercial License"). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44

55
Copyright © 2003–2022 Dynamsoft. All rights reserved.

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,19 @@ This repository contains multiple samples that demonstrates how to use the [Dyna
1616

1717
| Sample Name | Description |
1818
| ----------- | ----------- |
19-
| `HelloWorld` | This is a Java sample that illustrates the simplest way to recognize barcodes from images with Dynamsoft Barcode Reader SDK. |
20-
| `GeneralSettings` | This is a Java sample that illustrates how to make general settings (including barcode format/barcode count/scan region) when using Dynamsoft Barcode Reader. |
21-
| `ImageDecoding` | This is a Java sample that illustrates how to decode images in various format (including Base64/BufferedImage/file bytes/image buffer) when using Dynamsoft Barcode Reader. |
22-
| `SpeedFirstSettings` | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as fast as possible. The downside is that read-rate and accuracy might be affected. |
23-
| `ReadRateFirstSettings` | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read as many barcodes as possible at one time. The downside is that speed and accuracy might be affected. It is recommended to apply these configurations when decoding multiple barcodes from a single image. |
24-
| `AccuracyFirstSettings` | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as accurately as possible. The downside is that speed and read-rate might be affected. It is recommended to apply these configurations when misreading is unbearable. |
19+
| [`HelloWorld`](samples/HelloWorld) | This is a Java sample that illustrates the simplest way to recognize barcodes from images with Dynamsoft Barcode Reader SDK. |
20+
| [`GeneralSettings`](samples/GeneralSettings)` | This is a Java sample that illustrates how to make general settings (including barcode format/barcode count/scan region) when using Dynamsoft Barcode Reader. |
21+
| [`ImageDecoding`](samples/ImageDecoding) | This is a Java sample that illustrates how to decode images in various format (including Base64/BufferedImage/file bytes/image buffer) when using Dynamsoft Barcode Reader. |
22+
| [`SpeedFirstSettings`](samples/Performance/SpeedFirstSettings) | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as fast as possible. The downside is that read-rate and accuracy might be affected. |
23+
| [`ReadRateFirstSettings`](samples/Performance/ReadRateFirstSettings) | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read as many barcodes as possible at one time. The downside is that speed and accuracy might be affected. It is recommended to apply these configurations when decoding multiple barcodes from a single image. |
24+
| [`AccuracyFirstSettings`](samples/Performance/AccuracyFirstSettings)` | This is a Java sample that shows how to configure Dynamsoft Barcode Reader to read barcodes as accurately as possible. The downside is that speed and read-rate might be affected. It is recommended to apply these configurations when misreading is unbearable. |
2525

2626
## License
2727

2828
The library requires a license to work, you use the API initLicense to initialize license key and activate the SDK.
2929

30-
These samples use a <a href="https://www.dynamsoft.com/license-server/docs/about/terms.html?ver=latest&product=dbr&utm_source=samples&package=java#public-trial-license" target="_blank">free public trial license</a>. Note that network connection is required for this license to work.
31-
32-
You can also request a 30-day trial license from <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=java" target="_blank">Customer Portal</a>
30+
These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license key from <a href="https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=java" target="_blank">Customer Portal</a> which works offline.
3331

3432
## Contact Us
3533

36-
https://www.dynamsoft.com/company/contact/
34+
https://www.dynamsoft.com/company/contact/
Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,65 @@
11
import com.dynamsoft.dbr.*;
22

33
public class GeneralSettings {
4-
public static void main(String[] args) {
5-
try {
6-
7-
// 1.Initialize license.
4+
public static void main(String[] args) {
5+
try {
6+
7+
// 1.Initialize license.
88
// The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work.
99
// You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=java
10-
BarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
11-
12-
// 2.Create an instance of Dynamsoft Barcode Reader.
13-
BarcodeReader dbr = new BarcodeReader();
14-
15-
// There are two ways to configure runtime parameters. One is through PublicRuntimeSettings, the other is through parameters template.
16-
// 3. General settings (including barcode format, barcode count and scan region) through PublicRuntimeSettings
17-
// 3.1 Obtain current runtime settings of instance.
18-
PublicRuntimeSettings sts = dbr.getRuntimeSettings();
19-
20-
// 3.2 Set the expected barcode format you want to read.
21-
// The barcode format our library will search for is composed of BarcodeFormat group 1 and BarcodeFormat group 2.
22-
// So you need to specify the barcode format in group 1 and group 2 individually.
23-
sts.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_PDF417 | EnumBarcodeFormat.BF_DATAMATRIX;
24-
sts.barcodeFormatIds_2 = EnumBarcodeFormat.BF_NULL;
25-
26-
// 3.3 Set the expected barcode count you want to read.
27-
sts.expectedBarcodesCount = 10;
28-
29-
// 3.4 Set the ROI(region of insterest) to speed up the barcode reading process.
30-
// Note: DBR supports setting coordinates by pixels or percentages. The origin of the coordinate system is the upper left corner point.
31-
RegionDefinition region = new RegionDefinition();
32-
region.regionMeasuredByPercentage = 1;
33-
region.regionLeft = 0;
34-
region.regionRight = 100;
35-
region.regionTop = 0;
36-
region.regionBottom = 100;
37-
sts.region = region;
38-
39-
// 3.5 Apply the new settings to the instance
40-
dbr.updateRuntimeSettings(sts);
41-
42-
// 3. General settings (including barcode format, barcode count and scan region) through parameters template.
43-
// dbr.initRuntimeSettingsWithString("{\"ImageParameter\":{\"BarcodeFormatIds\":[\"BF_ONED\",\"BF_PDF417\",\"BF_QR_CODE\",\"BF_DATAMATRIX\"],\"BarcodeFormatIds_2\":null,\"ExpectedBarcodesCount\":10,\"Name\":\"sts\",\"RegionDefinitionNameArray\":[\"region0\"]},\"RegionDefinition\":{\"Bottom\":100,\"Left\":0,\"MeasuredByPercentage\":1,\"Name\":\"region0\",\"Right\":100,\"Top\":0}}", EnumConflictMode.CM_OVERWRITE);
44-
45-
// 4.Decode barcodes from an image file.
46-
TextResult[] results = dbr.decodeFile("../../images/AllSupportedBarcodeTypes.png", "");
47-
48-
// 5.Output the barcode format and barcode text.
49-
if (results != null && results.length > 0) {
50-
for (int i = 0; i < results.length; i++) {
51-
TextResult result = results[i];
52-
53-
String barcodeFormat = result.barcodeFormatString;
54-
System.out.println("Barcode " + i + ":" + barcodeFormat + ","+ result.barcodeText);
55-
}
56-
} else {
57-
System.out.println("No data detected.");
58-
}
59-
} catch (BarcodeReaderException ex) {
60-
ex.printStackTrace();
61-
}
62-
}
10+
BarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
11+
12+
// 2.Create an instance of Dynamsoft Barcode Reader.
13+
BarcodeReader reader = new BarcodeReader();
14+
15+
// There are two ways to configure runtime parameters. One is through PublicRuntimeSettings, the other is through parameters template.
16+
// 3. General settings (including barcode format, barcode count and scan region) through PublicRuntimeSettings
17+
// 3.1 Obtain current runtime settings of instance.
18+
PublicRuntimeSettings runtimeSettings = reader.getRuntimeSettings();
19+
20+
// 3.2 Set the expected barcode format you want to read.
21+
// The barcode format our library will search for is composed of BarcodeFormat group 1 and BarcodeFormat group 2.
22+
// So you need to specify the barcode format in group 1 and group 2 individually.
23+
runtimeSettings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE;
24+
runtimeSettings.barcodeFormatIds_2 = EnumBarcodeFormat_2.BF2_POSTALCODE | EnumBarcodeFormat_2.BF2_DOTCODE;
25+
26+
// 3.3 Set the expected barcode count you want to read.
27+
runtimeSettings.expectedBarcodesCount = 10;
28+
29+
// 3.4 Set the ROI(region of insterest) to speed up the barcode reading process.
30+
// Note: DBR supports setting coordinates by pixels or percentages. The origin of the coordinate system is the upper left corner point.
31+
RegionDefinition region = new RegionDefinition();
32+
region.regionMeasuredByPercentage = 1;
33+
region.regionLeft = 0;
34+
region.regionRight = 100;
35+
region.regionTop = 0;
36+
region.regionBottom = 100;
37+
runtimeSettings.region = region;
38+
39+
// 3.5 Apply the new settings to the instance
40+
reader.updateRuntimeSettings(runtimeSettings);
41+
42+
// 3. General settings (including barcode format, barcode count and scan region) through parameters template.
43+
// reader.initRuntimeSettingsWithString("{\"ImageParameter\":{\"BarcodeFormatIds\":[\"BF_ONED\",\"BF_PDF417\",\"BF_QR_CODE\",\"BF_DATAMATRIX\"],\"BarcodeFormatIds_2\":null,\"ExpectedBarcodesCount\":10,\"Name\":\"IP1\",\"RegionDefinitionNameArray\":[\"region0\"]},\"RegionDefinition\":{\"Bottom\":100,\"Left\":0,\"MeasuredByPercentage\":1,\"Name\":\"region0\",\"Right\":100,\"Top\":0}}", EnumConflictMode.CM_OVERWRITE);
44+
45+
// 4.Decode barcodes from an image file.
46+
TextResult[] results = reader.decodeFile("../../images/AllSupportedBarcodeTypes.png", "");
47+
48+
// 5.Output the barcode format and barcode text.
49+
if (results != null && results.length > 0) {
50+
System.out.println("Total barcodes found: " + results.length);
51+
for (int iIndex = 0; iIndex < results.length; iIndex++) {
52+
System.out.println("Barcode " + (iIndex + 1));
53+
System.out.println(" Barcode Format: " + results[iIndex].barcodeFormatString);
54+
System.out.println(" Barcode Text: " + results[iIndex].barcodeText);
55+
}
56+
} else {
57+
System.out.println("No barcode detected.");
58+
}
59+
reader.destroy();
60+
}
61+
catch (BarcodeReaderException exp) {
62+
System.out.println(exp.getMessage());
63+
}
64+
}
6365
}

0 commit comments

Comments
 (0)