Skip to content

Commit 7b68444

Browse files
committed
Added dotcode examples
1 parent 73e4c44 commit 7b68444

11 files changed

Lines changed: 668 additions & 0 deletions

File tree

examples/9.x/dotcode/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Java DotCode Reader
2+
These samples demonstrate how to decode **DotCode** using the [Dynamsoft Barcode Reader SDK](https://www.dynamsoft.com/barcode-reader/downloads/).
3+
4+
## License Key
5+
Get a [valid license](https://www.dynamsoft.com/customer/license/trialLicense/) and update the code in `src/main/java/com/java/barcode/App.java`:
6+
7+
```java
8+
BarcodeReader.initLicense("LICENSE-KEY");
9+
```
10+
11+
## Usage
12+
13+
- Command-line
14+
15+
```bash
16+
mvn clean package
17+
java -cp target/test-1.0-SNAPSHOT-jar-with-dependencies.jar com.java.barcode.App ../../../../images/dotcode.png
18+
```
19+
20+
- OpenCV
21+
22+
1. Install the OpenCV JAR file to your local Maven repository:
23+
24+
```bash
25+
cmd
26+
mvn install:install-file -Dfile=opencv-430.jar -DgroupId=org -DartifactId=opencv -Dversion=4.3.0 -Dpackaging=jar
27+
```
28+
29+
2. Build and run the project.
30+
31+
```bash
32+
mvn clean package
33+
java -cp target/test-1.0-SNAPSHOT-jar-with-dependencies.jar com.java.barcode.App
34+
```
35+
36+
![Java DotCode Reader](http://www.dynamsoft.com/codepool/img/2020/04/java-dotcode-reader.png)
37+
38+
## Blog
39+
[How to Build DotCode Reader in Java on Windows 10](https://www.dynamsoft.com/codepool/java-dotcode-reader-webcam-opencv.html)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.dynamsoft</groupId>
6+
<artifactId>test</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<properties>
9+
<maven.compiler.source>1.8</maven.compiler.source>
10+
<maven.compiler.target>1.8</maven.compiler.target>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
</properties>
13+
<dependencies>
14+
<dependency>
15+
<groupId>junit</groupId>
16+
<artifactId>junit</artifactId>
17+
<version>4.12</version>
18+
<scope>test</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.dynamsoft</groupId>
22+
<artifactId>dbr</artifactId>
23+
<version>9.6.40.1</version>
24+
</dependency>
25+
</dependencies>
26+
<repositories>
27+
<repository>
28+
<id>dbr</id>
29+
<url>https://download2.dynamsoft.com/maven/dbr/jar</url>
30+
</repository>
31+
</repositories>
32+
<build>
33+
<plugins>
34+
<plugin>
35+
<artifactId>maven-assembly-plugin</artifactId>
36+
<configuration>
37+
<descriptorRefs>
38+
<descriptorRef>jar-with-dependencies</descriptorRef>
39+
</descriptorRefs>
40+
</configuration>
41+
<executions>
42+
<execution>
43+
<id>make-assembly</id>
44+
<phase>package</phase>
45+
<goals>
46+
<goal>single</goal>
47+
</goals>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.java.barcode;
2+
3+
import com.dynamsoft.dbr.*;
4+
5+
public class App
6+
{
7+
public void decodefile(String filename) {
8+
9+
BarcodeReader br = null;
10+
try {
11+
BarcodeReader.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==");
12+
br = new BarcodeReader();
13+
//Best coverage settings
14+
br.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestCoverage\",\"DeblurLevel\":9,\"ExpectedBarcodesCount\":512,\"ScaleDownThreshold\":100000,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_SCAN_DIRECTLY\"},{\"Mode\":\"LM_STATISTICS\"},{\"Mode\":\"LM_LINES\"},{\"Mode\":\"LM_STATISTICS_MARKS\"}],\"GrayscaleTransformationModes\":[{\"Mode\":\"GTM_ORIGINAL\"},{\"Mode\":\"GTM_INVERTED\"}]}}", EnumConflictMode.CM_OVERWRITE);
15+
//Best speed settings
16+
//br.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"BestSpeed\",\"DeblurLevel\":3,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\"}],\"TextFilterModes\":[{\"MinImageDimension\":262144,\"Mode\":\"TFM_GENERAL_CONTOUR\"}]}}",EnumConflictMode.CM_OVERWRITE);
17+
//Balance settings
18+
//br.initRuntimeSettingsWithString("{\"ImageParameter\":{\"Name\":\"Balance\",\"DeblurLevel\":5,\"ExpectedBarcodesCount\":512,\"LocalizationModes\":[{\"Mode\":\"LM_CONNECTED_BLOCKS\"},{\"Mode\":\"LM_STATISTICS\"}]}}",EnumConflictMode.CM_OVERWRITE);
19+
20+
PublicRuntimeSettings runtimeSettings = br.getRuntimeSettings();
21+
runtimeSettings.barcodeFormatIds_2 = EnumBarcodeFormat_2.BF2_DOTCODE;
22+
br.updateRuntimeSettings(runtimeSettings);
23+
} catch (Exception e) {
24+
System.out.println(e);
25+
return;
26+
}
27+
28+
TextResult[] results = null;
29+
try {
30+
results = br.decodeFile(filename, "");
31+
} catch (Exception e) {
32+
System.out.println("decode buffered image: " + e);
33+
}
34+
35+
if (results != null && results.length > 0) {
36+
System.out.println("DBR result count: " + results.length);
37+
String pszTemp = null;
38+
for (TextResult result : results) {
39+
if (result.barcodeFormat != 0) {
40+
pszTemp = "Format: " + result.barcodeFormatString;
41+
} else {
42+
pszTemp = "Format: " + result.barcodeFormatString_2;
43+
}
44+
System.out.println(pszTemp);
45+
System.out.println("Text: " + result.barcodeText);
46+
System.out.println();
47+
}
48+
}
49+
}
50+
51+
public static void main( String[] args )
52+
{
53+
if (args.length == 0) {
54+
System.out.println("Please add an image file");
55+
return;
56+
}
57+
58+
final String filename = args[0];
59+
App test = new App();
60+
test.decodefile(filename);
61+
}
62+
}
637 KB
Binary file not shown.
46.9 MB
Binary file not shown.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.dynamsoft</groupId>
6+
<artifactId>test</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<properties>
9+
<maven.compiler.source>1.8</maven.compiler.source>
10+
<maven.compiler.target>1.8</maven.compiler.target>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
</properties>
13+
<dependencies>
14+
<dependency>
15+
<groupId>junit</groupId>
16+
<artifactId>junit</artifactId>
17+
<version>4.12</version>
18+
<scope>test</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.dynamsoft</groupId>
22+
<artifactId>dbr</artifactId>
23+
<version>9.6.40.1</version>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.opencv</groupId>
27+
<artifactId>opencv</artifactId>
28+
<version>4.3.0</version>
29+
</dependency>
30+
</dependencies>
31+
<repositories>
32+
<repository>
33+
<id>dbr</id>
34+
<url>https://download2.dynamsoft.com/maven/dbr/jar</url>
35+
</repository>
36+
</repositories>
37+
<build>
38+
<plugins>
39+
<plugin>
40+
<artifactId>maven-assembly-plugin</artifactId>
41+
<configuration>
42+
<descriptorRefs>
43+
<descriptorRef>jar-with-dependencies</descriptorRef>
44+
</descriptorRefs>
45+
</configuration>
46+
<executions>
47+
<execution>
48+
<id>make-assembly</id>
49+
<phase>package</phase>
50+
<goals>
51+
<goal>single</goal>
52+
</goals>
53+
</execution>
54+
</executions>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
</project>

0 commit comments

Comments
 (0)