Skip to content

Commit de83c39

Browse files
committed
unify analyze commands and fix imports for analyze_multi_page snippet
1 parent aa8c857 commit de83c39

File tree

23 files changed

+76
-83
lines changed

23 files changed

+76
-83
lines changed

examples/c/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The example supports four modes: **scan**, **analyze**, **classify**, and **pars
6767
## Example
6868
```bash
6969
./scanbotsdk_example scan barcode --file images/example.jpg --license <KEY>
70-
./scanbotsdk_example analyze analyse_multi_page --file files/doc.pdf --license <KEY>
70+
./scanbotsdk_example analyze analyze_multi_page --file files/doc.pdf --license <KEY>
7171
./scanbotsdk_example analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license <KEY>
7272
./scanbotsdk_example parse mrz --text "P<UTOERIKSSON<<ANNA<MARIA<<<<<<" --license <KEY>
7373
```

examples/c/include/snippets/document/analyse_multi_page.h

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef ANALYZE_MULTI_PAGE_H
2+
#define ANALYZE_MULTI_PAGE_H
3+
4+
#include <ScanbotSDK.h>
5+
6+
scanbotsdk_error_code_t analyze_multi_page(char* path);
7+
8+
#endif

examples/c/include/snippets/document/crop_and_analyse.h renamed to examples/c/include/snippets/document/crop_and_analyze.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
#include <ScanbotSDK.h>
55

6-
scanbotsdk_error_code_t crop_and_analyse(scanbotsdk_image_t *image, char* save_path);
6+
scanbotsdk_error_code_t crop_and_analyze(scanbotsdk_image_t *image, char* save_path);
77

88
#endif

examples/c/src/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#include <snippets/datacapture/mrz_parser.h>
2020

2121
#include <snippets/document/detect_document.h>
22-
#include <snippets/document/analyse_multi_page.h>
23-
#include <snippets/document/crop_and_analyse.h>
22+
#include <snippets/document/analyze_multi_page.h>
23+
#include <snippets/document/crop_and_analyze.h>
2424
#include <snippets/document/document_classifier.h>
2525

2626
static const int SCANBOTSDK_LICENSE_CHECK_TIMEOUT_MS = 15000;
@@ -86,17 +86,17 @@ int main(int argc, char *argv[]) {
8686
if (strcmp(command, "document") == 0) ec = classify_document(image);
8787
else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; }
8888
}
89-
else if (strcmp(category, "analyse") == 0) {
89+
else if (strcmp(category, "analyze") == 0) {
9090
if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; }
9191

92-
if (strcmp(command, "analyse_multi_page") == 0) {
93-
ec = analyse_multi_page(file_path);
92+
if (strcmp(command, "analyze_multi_page") == 0) {
93+
ec = analyze_multi_page(file_path);
9494
}
9595
else if (strcmp(command, "crop_analyze") == 0) {
9696
ec = load_image_from_path(file_path, &image);
9797
if (ec != SCANBOTSDK_OK) goto cleanup;
9898

99-
ec = crop_and_analyse(image, save_path);
99+
ec = crop_and_analyze(image, save_path);
100100
}
101101
else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; }
102102
}

examples/c/src/snippets/document/analyse_multi_page.c renamed to examples/c/src/snippets/document/analyze_multi_page.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ static scanbotsdk_error_code_t process_page(scanbotsdk_extracted_page_t *page, s
4242

4343
for (size_t j = 0; j < page_images_count; j++) {
4444
scanbotsdk_image_t *image = NULL;
45-
scanbotsdk_document_quality_analyzer_result_t *analyse_result = NULL;
45+
scanbotsdk_document_quality_analyzer_result_t *analyze_result = NULL;
4646

4747
ec = scanbotsdk_extracted_image_get_image(images[j], &image);
4848
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "extracted_image_get_image: %d: %s\n", ec, error_message(ec)); goto inner_cleanup; }
4949

50-
ec = scanbotsdk_document_quality_analyzer_run(analyzer, image, &analyse_result);
50+
ec = scanbotsdk_document_quality_analyzer_run(analyzer, image, &analyze_result);
5151
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "analyzer_run: %d: %s\n", ec, error_message(ec)); goto inner_cleanup; }
5252

53-
print_analyzer_result(analyse_result);
53+
print_analyzer_result(analyze_result);
5454

5555
inner_cleanup:
5656
if (ec != SCANBOTSDK_OK) { goto cleanup; }
@@ -61,7 +61,7 @@ static scanbotsdk_error_code_t process_page(scanbotsdk_extracted_page_t *page, s
6161
return ec;
6262
}
6363

64-
scanbotsdk_error_code_t analyse_multi_page(char* path) {
64+
scanbotsdk_error_code_t analyze_multi_page(char* path) {
6565
scanbotsdk_error_code_t ec = SCANBOTSDK_OK;
6666

6767
scanbotsdk_random_access_source_t* access_source = NULL;

examples/c/src/snippets/document/crop_and_analyse.c renamed to examples/c/src/snippets/document/crop_and_analyze.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <stdio.h>
2-
#include <snippets/document/crop_and_analyse.h>
2+
#include <snippets/document/crop_and_analyze.h>
33
#include <utils/utils.h>
44

55
scanbotsdk_error_code_t detect_document_cropped(
@@ -105,37 +105,37 @@ void print_result(scanbotsdk_document_quality_analyzer_result_t *result) {
105105
}
106106
}
107107

108-
static scanbotsdk_error_code_t analyse_document_quality(
108+
static scanbotsdk_error_code_t analyze_document_quality(
109109
scanbotsdk_image_t *cropped_image
110110
) {
111111
scanbotsdk_error_code_t ec = SCANBOTSDK_OK;
112-
scanbotsdk_document_quality_analyzer_configuration_t *analyse_config = NULL;
112+
scanbotsdk_document_quality_analyzer_configuration_t *analyze_config = NULL;
113113
scanbotsdk_document_quality_analyzer_t *analyzer = NULL;
114-
scanbotsdk_document_quality_analyzer_result_t *analyse_result = NULL;
114+
scanbotsdk_document_quality_analyzer_result_t *analyze_result = NULL;
115115

116116
// region Setup analyzer
117-
ec = scanbotsdk_document_quality_analyzer_configuration_create_with_defaults(&analyse_config);
117+
ec = scanbotsdk_document_quality_analyzer_configuration_create_with_defaults(&analyze_config);
118118
// Configure other parameters as needed.
119119

120-
ec = scanbotsdk_document_quality_analyzer_create(analyse_config, &analyzer);
120+
ec = scanbotsdk_document_quality_analyzer_create(analyze_config, &analyzer);
121121
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "analyzer_create: %d: %s\n", ec, error_message(ec)); goto cleanup; }
122122
// endregion
123123

124-
// region Analyse quality
125-
ec = scanbotsdk_document_quality_analyzer_run(analyzer, cropped_image, &analyse_result);
124+
// region Analyze quality
125+
ec = scanbotsdk_document_quality_analyzer_run(analyzer, cropped_image, &analyze_result);
126126
if (ec != SCANBOTSDK_OK) { fprintf(stderr, "analyzer_run: %d: %s\n", ec, error_message(ec)); goto cleanup; }
127127

128-
print_result(analyse_result);
128+
print_result(analyze_result);
129129
// endregion
130130

131131
cleanup:
132-
scanbotsdk_document_quality_analyzer_result_free(analyse_result);
132+
scanbotsdk_document_quality_analyzer_result_free(analyze_result);
133133
scanbotsdk_document_quality_analyzer_free(analyzer);
134-
scanbotsdk_document_quality_analyzer_configuration_free(analyse_config);
134+
scanbotsdk_document_quality_analyzer_configuration_free(analyze_config);
135135
return ec;
136136
}
137137

138-
scanbotsdk_error_code_t crop_and_analyse(
138+
scanbotsdk_error_code_t crop_and_analyze(
139139
scanbotsdk_image_t *image,
140140
char *save_path
141141
) {
@@ -151,7 +151,7 @@ scanbotsdk_error_code_t crop_and_analyse(
151151
if (ec != SCANBOTSDK_OK) goto cleanup;
152152
}
153153

154-
ec = analyse_document_quality(cropped_image);
154+
ec = analyze_document_quality(cropped_image);
155155
if (ec != SCANBOTSDK_OK) goto cleanup;
156156

157157
cleanup:

examples/c/src/utils/utils.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void print_usage(const char *prog) {
7575
printf("or\n");
7676
printf(" %s classify <command> --file <path/to/file.jpg> [--license <KEY>]\n", prog);
7777
printf("or\n");
78-
printf(" %s analyse <command> --file <path/to/file.jpg> --save <path/to/save.jpg> [--license <KEY>]\n", prog);
78+
printf(" %s analyze <command> --file <path/to/file.jpg> --save <path/to/save.jpg> [--license <KEY>]\n", prog);
7979
printf("or\n");
8080
printf(" %s parse <command> --text \"<input>\" [--license <KEY>]\n\n", prog);
8181

@@ -86,21 +86,21 @@ void print_usage(const char *prog) {
8686
printf("Available classify commands:\n");
8787
printf(" document \n\n");
8888

89-
printf("Available analyse commands:\n");
90-
printf(" analyse_multi_page | crop_analyze\n\n");
89+
printf("Available analyze commands:\n");
90+
printf(" analyze_multi_page | crop_analyze\n\n");
9191

9292
printf("Available parse commands:\n");
9393
printf(" mrz | barcode_doc\n\n");
9494

9595
printf("Note:\n");
96-
printf(" The --save argument is optional and only used with analyse/crop_analyze.\n");
96+
printf(" The --save argument is optional and only used with analyze/crop_analyze.\n");
9797
printf(" The --license argument is optional. If not provided, the program will\n");
9898
printf(" \tcheck the placeholder <SCANBOTSDK-LICENSE> in main.c\n");
9999

100100
printf("Examples:\n");
101101
printf(" %s scan barcode --file images/example.jpg --license <KEY>\n", prog);
102-
printf(" %s analyse analyse_multi_page --file files/doc.pdf --license <KEY>\n", prog);
103-
printf(" %s analyse crop_analyze --file images/doc.jpg --save out/crop.jpg --license <KEY>\n", prog);
102+
printf(" %s analyze analyze_multi_page --file files/doc.pdf --license <KEY>\n", prog);
103+
printf(" %s analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license <KEY>\n", prog);
104104
printf(" %s parse mrz --text \"P<UTOERIKSSON<<ANNA<MARIA<<<<<<\" --license <KEY>\n", prog);
105105
printf("\n");
106106
}

examples/java/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The example supports four commands: **scan**, **analyze**, **classify**, and **p
2222
## Example
2323
```bash
2424
./gradlew run --args='scan barcode --file images/example.jpg --license <KEY>'
25-
./gradlew run --args='analyze analyse_multi_page --resource files/doc.pdf --license <KEY>'
25+
./gradlew run --args='analyze analyze_multi_page --resource files/doc.pdf --license <KEY>'
2626
./gradlew run --args='analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license <KEY>'
2727
./gradlew run --args='parse mrz --text "P<UTOERIKSSON<<ANNA<MARIA<<<<<<" --license <KEY>'
2828
```

examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public static void main(String[] args) throws Exception {
7272
}
7373
break;
7474
}
75-
case "analyse": {
75+
case "analyze": {
7676
if (file == null && resource == null) { ExampleUsage.print(); return; }
7777
switch (subcommand) {
78-
case "analyse_multi_page": AnalyzeMultiPageSnippet.run(file, resource); break;
78+
case "analyze_multi_page": AnalyzeMultiPageSnippet.run(file, resource); break;
7979
case "crop_analyze": CropAndAnalyzeSnippet.run(file, resource, save); break;
8080
default: ExampleUsage.print();
8181
}

0 commit comments

Comments
 (0)