Skip to content

Commit 304d1d5

Browse files
update to internal commit 50052d7c
1 parent db02737 commit 304d1d5

File tree

3 files changed

+189
-14
lines changed

3 files changed

+189
-14
lines changed

programming-old/java/release-notes/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ permalink: /programming/java/release-notes/index.html
99

1010
# Release Notes - Java
1111

12+
- [2.2.10 (06/27/2024)](java-2.md#2210-06272024)
1213
- [2.0 (08/26/2021)](java-2.md#20-08262021)
1314
- [1.2.1 (06/08/2021)](java-1.md#121-06082021)
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
layout: default-layout
3+
title: Java User Guide - Dynamsoft Label Recognizer
4+
description: This is the user guide page of Dynamsoft Label Recognizer for Java Language.
5+
keywords: java, user guide
6+
needAutoGenerateSidebar: true
7+
needGenerateH3Content: true
8+
permalink: /programming/java/user-guide-v2.0.0.html
9+
---
10+
11+
# User Guide - Java
12+
13+
- [User Guide - Java](#user-guide---java)
14+
- [Requirements](#requirements)
15+
- [Installation](#installation)
16+
- [Build your First Application](#build-your-first-application)
17+
- [Create a New Project](#create-a-new-project)
18+
- [Include the Label Recognizer library](#include-the-label-recognizer-library)
19+
- [Initialize the Label Recognizer](#initialize-the-label-recognizer)
20+
- [Recognition Process and How to Use the Results](#recognition-process-and-how-to-use-the-results)
21+
- [Build and Run the Project](#build-and-run-the-project)
22+
23+
## Requirements
24+
25+
- Operating systems:
26+
- Windows 7, 8, 10
27+
- Windows Server 2003, 2008, 2008 R2, 2012
28+
- Linux x64 (Ubuntu 14.04.4+ LTS, Debian 8+, etc.)
29+
- JDK 1.7 and above
30+
31+
- Environment: Eclipse 3.7 and above.
32+
33+
## Installation
34+
35+
If you don't have SDK yet, please go to <a href="https://www.dynamsoft.com/survey/dlr/?utm_source=docs" target="_blank">Dynamsoft website</a> to get it. After the sdk is decompressed, the root directory of the DLR installation package is `DynamsoftLabelRecognizer`, which is represented by `[INSTALLATION FOLDER]`.
36+
37+
## Build your First Application
38+
39+
Let's start by creating a console application which demonstrates how to use the minimum code to recognize text from an image file.
40+
41+
>You can download the similar complete source code from [Here](https://github.com/Dynamsoft/label-recognizer-java-samples/tree/master/samples/HelloWorld).
42+
43+
### Create a New Project
44+
45+
1. Open Eclipse. Go to File > New > Project, create a new Java project `DLRJavaSample`.
46+
47+
2. Add a new Class named `DLRJavaSample` into the project.
48+
49+
### Include the Label Recognizer library
50+
51+
1. Add the Dynamsoft Label Recognizer JAR file to your project.
52+
Click File > Properties > Java Build Path > Libraries > Add external JARs, add `dynamsoft-labelrecognizer-{version number}.jar` and `dynamsoft-core-{version number}.jar` click Apply.
53+
>Note: The JAR file can be found at `[INSTALLATION FOLDER]\lib`.
54+
55+
2. Import the package in the file `DLRJavaSample.java`
56+
57+
```java
58+
import com.dynamsoft.dlr.*;
59+
```
60+
61+
### Initialize the Label Recognizer
62+
63+
1. Initialize the license key
64+
65+
```java
66+
// 1.Initialize license.
67+
LabelRecognizer.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInByb2R1Y3RzIjoyfQ==");
68+
```
69+
70+
>Note:
71+
>- Network connection is required for the license to work.
72+
>- "DLS2***" is a default free public trial license used in the sample.
73+
>- You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dlr&utm_source=guide&package=java){:target="_blank"} link.
74+
75+
2. Create an instance of Dynamsoft Label Recognizer
76+
77+
```java
78+
// 2.Create an instance of Label Recognizer.
79+
LabelRecognizer dlr = new LabelRecognizer();
80+
```
81+
82+
### Recognition Process and How to Use the Results
83+
84+
1. Recognizing text in an image
85+
86+
```java
87+
DLRResult[] results = null;
88+
89+
try {
90+
results = dlr.recognizeByFile("../../SampleImages/dlr-sample-vin.png", "");
91+
} catch (LabelRecognizerException ex) {
92+
ex.printStackTrace();
93+
}
94+
```
95+
96+
>You can download the image [dlr-sample-vin.png](../assets/dlr-sample-vin.png) for testing. In addition, you can replace it with the full path of the image you want to recognize.
97+
>For the error handling mechanism, when an error occurs during the recognition process, an exception will be thrown. You should add codes for error handling based on your needs. Check out [Error Code]({{site.dlr_enumerations}}error-code.html) for full supported error codes.
98+
99+
2. Get and output the recognition results
100+
101+
```java
102+
if (results != null && results.length > 0) {
103+
for (int i = 0; i < results.length; i++) {
104+
105+
// Get result of each text area (also called label).
106+
DLRResult result = results[i];
107+
System.out.println("Result " + i + ":");
108+
for (int j = 0; j < result.lineResults.length; j++) {
109+
110+
// Get the result of each text line in the label.
111+
DLRLineResult lineResult = result.lineResults[j];
112+
System.out.println(">>Line Result " + j + ": " + lineResult.text);
113+
}
114+
}
115+
} else {
116+
System.out.println("No data detected.");
117+
}
118+
```
119+
120+
The recognition results of SDK are organized into a four-tier structure:
121+
- `DLRResult[]` corresponds to the results of an `image`
122+
- `DLRResult` corresponds to the result of a `TextArea` (also called Label)
123+
- `DLRLineResult` corresponds to the result of each `TextLine` in the Label
124+
- `DLRCharacterResult` corresponds to the result of each `Character` in the `TextLine`
125+
126+
The structure is shown in the figure below:
127+
128+
<div align="center">
129+
<img src="../assets/dlr_result2.png" alt="DLR Result Structure" width="80%"/>
130+
<p>Figure 1DLR Result Structure</p>
131+
</div>
132+
133+
You can download the similar complete source code from [Here](https://github.com/Dynamsoft/label-recognizer-java-samples/tree/master/samples/HelloWorld).
134+
135+
### Build and Run the Project
136+
137+
1. Right click the project, click Run As > Java Application.

programming-old/java/user-guide.md

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ permalink: /programming/java/user-guide.html
1616
- [Build your First Application](#build-your-first-application)
1717
- [Create a New Project](#create-a-new-project)
1818
- [Include the Label Recognizer library](#include-the-label-recognizer-library)
19+
- [Option 1: Add the Libraries Manually](#option-1-add-the-libraries-manually)
20+
- [Option 2: Add the Libraries via Maven](#option-2-add-the-libraries-via-maven)
1921
- [Initialize the Label Recognizer](#initialize-the-label-recognizer)
2022
- [Recognition Process and How to Use the Results](#recognition-process-and-how-to-use-the-results)
2123
- [Build and Run the Project](#build-and-run-the-project)
@@ -40,50 +42,85 @@ Let's start by creating a console application which demonstrates how to use the
4042

4143
>You can download the similar complete source code from [Here](https://github.com/Dynamsoft/label-recognizer-java-samples/tree/master/samples/HelloWorld).
4244
43-
### Create a New Project
45+
### Create a New Project
4446

4547
1. Open Eclipse. Go to File > New > Project, create a new Java project `DLRJavaSample`.
4648

4749
2. Add a new Class named `DLRJavaSample` into the project.
4850

4951
### Include the Label Recognizer library
5052

51-
1. Add the Dynamsoft Label Recognizer JAR file to your project.
52-
Click File > Properties > Java Build Path > Libraries > Add external JARs, add `dynamsoft-labelrecognizer-{version number}.jar` and `dynamsoft-core-{version number}.jar` click Apply.
53-
>Note: The JAR file can be found at `[INSTALLATION FOLDER]\lib`.
53+
There are two ways to add the libraries into your project - **Manually** and **Maven**.
5454

55+
#### Option 1: Add the Libraries Manually
5556

56-
2. Import the package in the file `DLRJavaSample.java`
57-
```java
58-
import com.dynamsoft.dlr.*;
57+
1. Click File > Properties > Java Build Path > Libraries > Add external JARs
58+
59+
2. add `dynamsoft-labelrecognizer-{version number}.jar` and `dynamsoft-core-{version number}.jar` click Apply.
60+
61+
>Note: The JAR file can be found at `[INSTALLATION FOLDER]\lib`.
62+
63+
#### Option 2: Add the Libraries via Maven
64+
65+
1. Include the following repository configuration in your pom.xml file:
66+
67+
```xml
68+
<repositories>
69+
<repository>
70+
<id>dlr</id>
71+
<url>https://download2.dynamsoft.com/maven/jar</url>
72+
</repository>
73+
</repositories>
74+
```
75+
76+
2. Add the following dependencies to your pom.xml file:
77+
78+
```xml
79+
<dependencies>
80+
<dependency>
81+
<groupId>com.dynamsoft</groupId>
82+
<artifactId>dlr</artifactId>
83+
<version>2.2.10</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>com.dynamsoft</groupId>
87+
<artifactId>dc</artifactId>
88+
<version>1.0.0</version>
89+
</dependency>
90+
</dependencies>
5991
```
6092

6193
### Initialize the Label Recognizer
6294

63-
1. Initialize the license key
95+
1. Import the package in the file `DLRJavaSample.java`
6496

6597
```java
66-
// 1.Initialize license.
98+
import com.dynamsoft.dlr.*;
99+
```
100+
101+
2. Initialize the license key
102+
103+
```java
104+
// 1.Initialize license.
67105
LabelRecognizer.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInByb2R1Y3RzIjoyfQ==");
68-
```
69-
106+
```
107+
70108
>Note:
71109
>- Network connection is required for the license to work.
72110
>- "DLS2***" is a default free public trial license used in the sample.
73111
>- You can request a 30-day trial license via the [Request a Trial License](https://www.dynamsoft.com/customer/license/trialLicense?product=dlr&utm_source=guide&package=java){:target="_blank"} link.
74112

75-
2. Create an instance of Dynamsoft Label Recognizer
113+
3. Create an instance of Dynamsoft Label Recognizer
76114

77115
```java
78116
// 2.Create an instance of Label Recognizer.
79117
LabelRecognizer dlr = new LabelRecognizer();
80118
```
81119

82-
83120
### Recognition Process and How to Use the Results
84121

85122
1. Recognizing text in an image
86-
123+
87124
```java
88125
DLRResult[] results = null;
89126

0 commit comments

Comments
 (0)