Skip to content

Commit b712531

Browse files
update to v9.6.30
1 parent 3d64e59 commit b712531

File tree

26 files changed

+310
-31
lines changed

26 files changed

+310
-31
lines changed

LICENSE.md

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

33
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

5-
Copyright © 2003–2022 Dynamsoft. All rights reserved.
5+
Copyright © 2003–2023 Dynamsoft. All rights reserved.

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ This repository contains multiple samples that demonstrates how to use the [Dyna
2222
| [`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. |
2323
| [`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. |
2424
| [`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. |
25+
| [`DecodeWithConcurrentInstance`](samples/DecodeWithConcurrentInstance)` | This sample demonstrates how to decode barcodes in concurrent instance mode. |
2526

2627
## License
2728

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

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.
31+
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?architecture=dcv&product=dbr&utm_source=samples&package=java" target="_blank">Customer Portal</a> which works offline.
32+
33+
To run sample `DecodeWithConcurrentInstance`, please contact us at https://www.dynamsoft.com/company/contact/ to get a concurrent instance license first.
34+
35+
For more information, please refer to https://www.dynamsoft.com/license-server/docs/about/licensefaq.html.
3136

3237
## Contact Us
3338

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
34+
Binary file not shown.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.3.1.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.dynamsoft</groupId>
12+
<artifactId>concurrentInstanceTest</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>concurrentInstanceTest</name>
15+
<description>How to make concurrentInstanceLicense work? Let&apos;s have a try.</description>
16+
<properties>
17+
<java.version>11</java.version>
18+
<skipTests>true</skipTests>
19+
</properties>
20+
21+
<repositories>
22+
<repository>
23+
<id>dbr</id>
24+
<url>https://download2.dynamsoft.com/maven/dbr/jar</url>
25+
</repository>
26+
</repositories>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-web</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>com.dynamsoft</groupId>
35+
<artifactId>dbr</artifactId>
36+
<version>9.6.30</version>
37+
</dependency>
38+
</dependencies>
39+
40+
<build>
41+
<plugins>
42+
<plugin>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-maven-plugin</artifactId>
45+
</plugin>
46+
</plugins>
47+
</build>
48+
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dynamsoft.concurrentInstanceTest;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class ConcurrentInstanceTestApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(ConcurrentInstanceTestApplication.class, args);
11+
}
12+
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.dynamsoft.concurrentInstanceTest.controller;
2+
3+
import com.dynamsoft.concurrentInstanceTest.zzUtil;
4+
import com.dynamsoft.concurrentInstanceTest.service.DecodeService;
5+
import org.springframework.web.bind.annotation.PostMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RequestParam;
8+
import org.springframework.web.bind.annotation.RestController;
9+
import org.springframework.web.multipart.MultipartFile;
10+
11+
import javax.annotation.Resource;
12+
13+
@RestController
14+
@RequestMapping("/decode")
15+
public class DecodeController {
16+
17+
@Resource
18+
DecodeService decodeService;
19+
20+
@PostMapping(consumes = {"multipart/form-data"})
21+
String decode(@RequestParam("image")MultipartFile mpImage) throws Exception {
22+
var bytesImage = mpImage.getBytes();
23+
var results = decodeService.decode(bytesImage);
24+
return zzUtil.jsonMapper.writeValueAsString(results);
25+
}
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.dynamsoft.concurrentInstanceTest.service;
2+
3+
import com.dynamsoft.concurrentInstanceTest.zz3rdPart.DynamsoftBarcodeWrapper;
4+
import com.dynamsoft.dbr.TextResult;
5+
import org.springframework.stereotype.Service;
6+
7+
@Service("decodeService")
8+
public class DecodeService {
9+
public TextResult[] decode(byte[] bytes) throws Exception {
10+
return DynamsoftBarcodeWrapper.decode(bytes);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.dynamsoft.concurrentInstanceTest.zz3rdPart;
2+
3+
import com.dynamsoft.dbr.BarcodeReader;
4+
import com.dynamsoft.dbr.TextResult;
5+
import java.io.*;
6+
import java.nio.file.Files;
7+
import java.nio.file.Path;
8+
import java.nio.file.Paths;
9+
import java.nio.file.StandardCopyOption;
10+
import java.security.DigestInputStream;
11+
import java.security.MessageDigest;
12+
import java.security.NoSuchAlgorithmException;
13+
public class DynamsoftBarcodeWrapper {
14+
15+
public static Exception initException = null;
16+
17+
// For the sake of generality, spring's dependency injection mechanism is not used.
18+
static {
19+
// Contact us at https://www.dynamsoft.com/company/contact/ to get a concurrent instance license
20+
String license = "YOUR-LICENSE-KEY";
21+
int countForThisDevice = 1;
22+
int countForThisProcess = 1;
23+
try {
24+
BarcodeReader.setMaxConcurrentInstanceCount(countForThisDevice, countForThisProcess);
25+
BarcodeReader.initLicense(license);
26+
} catch (Exception ex) {
27+
ex.printStackTrace();
28+
initException = ex;
29+
}
30+
}
31+
public static TextResult[] decode(byte[] bytes) throws Exception {
32+
if(null != initException){ throw initException; }
33+
var reader = BarcodeReader.getInstance();
34+
if(reader == null)
35+
{
36+
try {
37+
BarcodeReader.initLicense("YOUR-LICENSE-KEY");
38+
} catch (Exception ex) {
39+
ex.printStackTrace();
40+
throw ex;
41+
}
42+
reader = BarcodeReader.getInstance();
43+
if(reader == null)
44+
{
45+
throw new Exception("Get Instance Failed.");
46+
}
47+
}
48+
var results = reader.decodeFileInMemory(bytes, "");
49+
reader.recycle();
50+
return results;
51+
}
52+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.dynamsoft.concurrentInstanceTest;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
5+
public class zzUtil {
6+
7+
public static final ObjectMapper jsonMapper = new ObjectMapper();
8+
}

0 commit comments

Comments
 (0)