Skip to content

Commit ed4e229

Browse files
Release 23.7.0 rev. 0
1 parent 91a1137 commit ed4e229

File tree

159 files changed

+31373
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+31373
-14
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: go
2+
3+
install:
4+
- go get -d -v .
5+
6+
script:
7+
- go build -v ./
8+

README.md

Lines changed: 138 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Aspose.OCR Cloud SDK for Go 23.6.0
1+
# Aspose.OCR Cloud SDK for Go 23.7.0
22

33
[![License](https://img.shields.io/github/license/aspose-ocr-cloud/aspose-ocr-cloud-dotnet)](LICENSE)
44

@@ -19,10 +19,8 @@ Aspose.OCR Cloud SDK for Go is open source under the MIT license. You can freely
1919

2020
- Internet connection.
2121
- Access to the **api.aspose.cloud** domain.
22-
- Операционка (если вообще роляет; если нет - то все подряд перечислять не надо).
23-
- Версия Гоу.
24-
- Сторонние депенденси, если нужно установить.
25-
- Гоу ведь компилируемый язык, в результате будет стандартное исполняемое приложение, не требующее интерпретатора?
22+
- Go version 1.18
23+
- The actual dependencies are listed in go.mod file
2624

2725
## Get started
2826

@@ -56,23 +54,64 @@ Aspose.OCR Cloud follows industry standards and best practices to keep your data
5654

5755
### Running demo
5856

59-
1. Вот тут надо описать шаги
60-
2. Чтот надо сделать для запуска демо-приложения
61-
3. В какую строчку кода вписать **Client ID** и **Client Secret**
62-
4. И как запустить проект
63-
5. Как будет готово, я вычитаю. Можно по-русски написать, если будет удобнее.
57+
1. Clone our repository
58+
2. Open [examples\example.go](examples\example.go) file and replace "YOUR_CLIENT_ID" and "YOUR_CLIENT_SECRET" with your credentials
59+
```go
60+
61+
func main(){
62+
63+
clientId := "YOUR_CLIENT_ID"
64+
clientSecret := "YOUR_CLIENT_SECRET"
65+
...
66+
```
67+
3. Open a new terminal and navigate to the aspose-ocr-cloud-go/example/ directory
68+
```shell
69+
cd <path_to_sdk>/aspose-ocr-cloud-go/example/
70+
```
71+
4. Run example
72+
```shell
73+
go run .\example.go
74+
```
75+
5. Files with test results will appear in the aspose-ocr-cloud-go/results/ folder
76+
77+
Also, as a demo application, you can use the tests
78+
1. Clone our repository
79+
2. Install dependencies
80+
```shell
81+
go get github.com/stretchr/testify/assert
82+
go get github.com/stretchr/testify/require
83+
go get golang.org/x/oauth2
84+
```
85+
2. In the file [test/test_config.go](test/test_config.go) enter **Client ID** and **Client Secret**
86+
```go
87+
package asposeocrcloud
88+
89+
var (
90+
ConfigClientID = "YOUR_CLIENT_ID"
91+
ConfigClientSecret = "YOUR_CLIENT_SECRET"
92+
)
93+
```
94+
3. Open a new terminal and navigate to the aspose-ocr-cloud-go/test/ directory
95+
```shell
96+
cd <path_to_sdk>/aspose-ocr-cloud-go/test/
97+
```
98+
4. Run the tests with the command
99+
```
100+
go test github.com/aspose-ocr-cloud/aspose-ocr-cloud-go/test
101+
```
102+
5. Files with test results will appear in the aspose-ocr-cloud-go/results/ folder
64103
65104
[Download demo as ZIP archive](https://github.com/aspose-ocr-cloud/aspose-ocr-cloud-go/archive/refs/heads/master.zip)
66105
67-
## What was changed in version 23.6.0
106+
## What was changed in version 23.7.0
68107
69108
This is the first release of Aspose.OCR Cloud SDK for Go. It supports all the features of [Aspose.OCR Cloud REST API 23.6.0](https://releases.aspose.cloud/ocr/release-notes/2023/aspose-ocr-cloud-23-6-0-release-notes/).
70109
71110
Stay tuned for further updates.
72111
73112
### Public API changes and backwards compatibility
74113
75-
This section lists all public API changes introduced in **Aspose.OCR Cloud SDK for Go 23.6.0** that may affect the code of existing applications.
114+
This section lists all public API changes introduced in **Aspose.OCR Cloud SDK for Go 23.7.0** that may affect the code of existing applications.
76115
77116
#### Added public APIs:
78117
@@ -91,8 +130,93 @@ _No changes._
91130
The example below illustrates how to use Aspose.OCR Cloud SDK for Go to extract text from an image:
92131
93132
```go
94-
Вот на Гоу я ни разу ничего не писал, от слова "совсем"
95-
Так что пример даже проверить не смогу
133+
package main
134+
135+
136+
import (
137+
"context"
138+
"encoding/base64"
139+
"fmt"
140+
"io/ioutil"
141+
asposeocrcloud "github.com/aspose-ocr-cloud/aspose-ocr-cloud-go"
142+
)
143+
144+
func main(){
145+
146+
clientId := "YOUR_CLIENT_ID"
147+
clientSecret := "YOUR_CLIENT_SECRET"
148+
configuration := asposeocrcloud.NewConfiguration(clientId, clientSecret)
149+
apiClient := asposeocrcloud.NewAPIClient(configuration)
150+
151+
152+
filePath := "../samples/latin.png" // Path to your file
153+
154+
// Read your file data and convert it into base64 string
155+
fileBytes, err := ioutil.ReadFile(filePath)
156+
if err != nil || fileBytes == nil {
157+
fmt.Println("Read file error:", err)
158+
return
159+
}
160+
fileb64Encoded := base64.StdEncoding.EncodeToString(fileBytes)
161+
162+
// Step 1: create request body and sent it to OCR Cloud to receive task ID
163+
recognitionSettings := *asposeocrcloud.NewOCRSettingsRecognizeImage()
164+
recognitionSettings.Language = asposeocrcloud.LANGUAGE_ENGLISH.Ptr()
165+
recognitionSettings.DsrMode = asposeocrcloud.DSRMODE_NO_DSR_NO_FILTER.Ptr()
166+
recognitionSettings.DsrConfidence = asposeocrcloud.DSRCONFIDENCE_DEFAULT.Ptr()
167+
*recognitionSettings.MakeBinarization = false
168+
*recognitionSettings.MakeSkewCorrect = false
169+
*recognitionSettings.MakeUpsampling = false
170+
*recognitionSettings.MakeSpellCheck = false
171+
*recognitionSettings.MakeContrastCorrection = false
172+
recognitionSettings.ResultType = asposeocrcloud.RESULTTYPE_TEXT.Ptr()
173+
recognitionSettings.ResultTypeTable = asposeocrcloud.RESULTTYPETABLE_TEXT.Ptr()
174+
175+
requestBody := *asposeocrcloud.NewOCRRecognizeImageBody(
176+
fileb64Encoded,
177+
recognitionSettings,
178+
)
179+
180+
taskId, httpRes, err := apiClient.RecognizeImageApi.PostRecognizeImage(context.Background()).OCRRecognizeImageBody(requestBody).Execute()
181+
if err != nil || httpRes.StatusCode != 200 {
182+
fmt.Println("API error:", err)
183+
return
184+
}
185+
186+
fmt.Printf("File successfully sent. Your TaskID is %s \n", taskId)
187+
188+
// Step 2: request task results using task ID
189+
ocrResp, httpRes, err := apiClient.RecognizeImageApi.GetRecognizeImage(context.Background()).Id(taskId).Execute()
190+
if err != nil|| httpRes.StatusCode != 200 || ocrResp == nil {
191+
fmt.Println("API error:", err)
192+
return
193+
}
194+
195+
if *ocrResp.TaskStatus == asposeocrcloud.OCRTASKSTATUS_COMPLETED {
196+
if !ocrResp.Results[0].Data.IsSet() {
197+
fmt.Println("Response is empty")
198+
return
199+
}
200+
201+
// Decode results and write to file
202+
decodedBytes, err := base64.StdEncoding.DecodeString(*ocrResp.Results[0].Data.Get())
203+
if err != nil {
204+
fmt.Println("Decode error:", err)
205+
return
206+
}
207+
208+
resultFilePath := "../results/" + taskId + ".txt"
209+
err = ioutil.WriteFile(resultFilePath, decodedBytes, 0644)
210+
if err != nil {
211+
fmt.Println("Write file error:", err)
212+
return
213+
}
214+
215+
fmt.Printf("Task result successfully saved at %s \n", resultFilePath)
216+
} else {
217+
fmt.Printf("Sorry, task %s is not completed yet. You can request results later. Task status: %s\n", taskId, *ocrResp.TaskStatus)
218+
}
219+
}
96220
```
97221
98222
## Other Aspose.OCR Cloud SDKs

0 commit comments

Comments
 (0)