From 464ce1fd477b0b94c656e6c230202781e97d2b27 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Thu, 18 Jun 2026 08:45:32 +0200 Subject: [PATCH 01/19] Add document enhancement feature and update examples to v9.0 --- examples/c/README.md | 7 +- .../snippets/enhancer/document_enhancer.h | 8 +++ examples/c/src/main.c | 10 +++ .../snippets/document/analyze_multi_page.c | 12 +--- .../src/snippets/document/crop_and_analyze.c | 11 +-- .../src/snippets/enhancer/document_enhancer.c | 70 +++++++++++++++++++ examples/c/src/utils/utils.c | 5 ++ examples/java/README.md | 4 +- examples/java/build.gradle | 2 +- .../io/scanbot/sdk/ScanbotSDKExample.java | 11 +++ .../document/AnalyzeMultiPageSnippet.java | 6 +- .../document/CropAndAnalyzeSnippet.java | 3 +- .../enhancer/DocumentEnhancerSnippet.java | 30 ++++++++ examples/nodejs/README.md | 6 +- examples/nodejs/package-lock.json | 8 +-- examples/nodejs/package.json | 2 +- examples/nodejs/src/index.ts | 12 ++++ .../snippets/document/analyze-multipage.ts | 5 +- .../src/snippets/document/crop-analyze.ts | 2 +- .../snippets/enhancer/document-enhancer.ts | 22 ++++++ examples/python/README.md | 4 +- examples/python/main.py | 7 ++ .../snippets/document/analyze_multi_page.py | 1 - .../snippets/enhancer/document_enhancer.py | 16 +++++ 24 files changed, 220 insertions(+), 44 deletions(-) create mode 100644 examples/c/include/snippets/enhancer/document_enhancer.h create mode 100644 examples/c/src/snippets/enhancer/document_enhancer.c create mode 100644 examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java create mode 100644 examples/nodejs/src/snippets/enhancer/document-enhancer.ts create mode 100644 examples/python/snippets/enhancer/document_enhancer.py diff --git a/examples/c/README.md b/examples/c/README.md index 1051ffd..8ca796f 100644 --- a/examples/c/README.md +++ b/examples/c/README.md @@ -83,16 +83,14 @@ In order to build all examples, run the following commands: ## Usage -The example supports four modes: **scan**, **analyze**, **classify**, and **parse**. +The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. ```bash ./scanbotsdk_example scan --file [--license ] -./scanbotsdk_example scan --file [--license ] -./scanbotsdk_example analyze --file [--save ] [--license ] ./scanbotsdk_example analyze --file [--save ] [--license ] ./scanbotsdk_example classify --file [--license ] +./scanbotsdk_example enhance --file [--license ] ./scanbotsdk_example parse --text "" [--license ] ./scanbotsdk_example live --file [--license ] [--use_tensorrt] - ``` ## Example @@ -100,6 +98,7 @@ The example supports four modes: **scan**, **analyze**, **classify**, and **pars ./scanbotsdk_example scan barcode --file images/example.jpg --license ./scanbotsdk_example analyze analyze_multi_page --file files/doc.pdf --license ./scanbotsdk_example analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license +./scanbotsdk_example enhance document --file images/doc.jpg --license ./scanbotsdk_example parse mrz --text "P ./scanbotsdk_example live barcode --file images/example.jpg --license ``` diff --git a/examples/c/include/snippets/enhancer/document_enhancer.h b/examples/c/include/snippets/enhancer/document_enhancer.h new file mode 100644 index 0000000..6826eea --- /dev/null +++ b/examples/c/include/snippets/enhancer/document_enhancer.h @@ -0,0 +1,8 @@ +#ifndef DOCUMENT_ENHANCER_H +#define DOCUMENT_ENHANCER_H + +#include + +scanbotsdk_error_code_t enhance_document(scanbotsdk_image_t *image); + +#endif diff --git a/examples/c/src/main.c b/examples/c/src/main.c index ee2d8e7..bd0029f 100644 --- a/examples/c/src/main.c +++ b/examples/c/src/main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -78,6 +79,15 @@ int main(int argc, char *argv[]) { if (strcmp(command, "document") == 0) ec = classify_document(image); else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; } } + else if (strcmp(category, "enhance") == 0) { + if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; } + + ec = load_image_from_path(file_path, &image); + if (ec != SCANBOTSDK_OK) goto cleanup; + + if (strcmp(command, "document") == 0) ec = enhance_document(image); + else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; } + } else if (strcmp(category, "analyze") == 0) { if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; } diff --git a/examples/c/src/snippets/document/analyze_multi_page.c b/examples/c/src/snippets/document/analyze_multi_page.c index e767e8c..d157c65 100644 --- a/examples/c/src/snippets/document/analyze_multi_page.c +++ b/examples/c/src/snippets/document/analyze_multi_page.c @@ -5,22 +5,16 @@ #include void print_analyzer_result(scanbotsdk_document_quality_analyzer_result_t *result) { - char* quality_str[] = { "Very poor", "Poor", "Reasonable", "Good", "Excellent"}; + char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN"}; bool document_found; - scanbotsdk_document_quality_t *quality = NULL; + scanbotsdk_document_quality_assessment_t quality; scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); printf("Document detection: %s\n", document_found ? "Found" : "Not found"); - - if (quality) - { - printf("Document quality: %s\n", quality_str[*quality]); - } else { - printf("No document found.\n"); - } + printf("Document quality: %s\n", quality_str[quality]); } static scanbotsdk_error_code_t process_page(scanbotsdk_extracted_page_t *page, scanbotsdk_document_quality_analyzer_t *analyzer) diff --git a/examples/c/src/snippets/document/crop_and_analyze.c b/examples/c/src/snippets/document/crop_and_analyze.c index 70d7b83..7af1ba9 100644 --- a/examples/c/src/snippets/document/crop_and_analyze.c +++ b/examples/c/src/snippets/document/crop_and_analyze.c @@ -88,21 +88,16 @@ scanbotsdk_error_code_t save_cropped_image( } void print_result(scanbotsdk_document_quality_analyzer_result_t *result) { - const char* quality_str[] = { "Very poor", "Poor", "Reasonable", "Good", "Excellent" }; + const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN"}; bool document_found = false; - scanbotsdk_document_quality_t *quality = NULL; + scanbotsdk_document_quality_assessment_t quality; scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); printf("Document detection: %s\n", document_found ? "Found" : "Not found"); - - if (quality) { - printf("Document quality: %s (%d)\n", quality_str[*quality], *quality); - } else { - printf("No document found.\n"); - } + printf("Document quality: %s (%d)\n", quality_str[quality], quality); } static scanbotsdk_error_code_t analyze_document_quality( diff --git a/examples/c/src/snippets/enhancer/document_enhancer.c b/examples/c/src/snippets/enhancer/document_enhancer.c new file mode 100644 index 0000000..dc637e1 --- /dev/null +++ b/examples/c/src/snippets/enhancer/document_enhancer.c @@ -0,0 +1,70 @@ +#include +#include + +#include +#include + +scanbotsdk_error_code_t enhance_document(scanbotsdk_image_t *image) { + scanbotsdk_error_code_t ec = SCANBOTSDK_OK; + + scanbotsdk_document_straightening_result_t *result = NULL; + scanbotsdk_document_straightening_parameters_t *straightening_params = NULL; + scanbotsdk_document_enhancer_t *enhancer = NULL; + scanbotsdk_image_t *straightened_image = NULL; + + scanbotsdk_aspect_ratio_t *aspect_ratios[4] = {0}; + + ec = scanbotsdk_aspect_ratio_create(5.0, 7.0, &aspect_ratios[0]); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "aspect_ratio_create(5:7): %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_aspect_ratio_create(1.0, 1.0, &aspect_ratios[1]); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "aspect_ratio_create(1:1): %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_aspect_ratio_create(16.0, 9.0, &aspect_ratios[2]); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "aspect_ratio_create(16:9): %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_aspect_ratio_create(3.0, 4.0, &aspect_ratios[3]); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "aspect_ratio_create(3:4): %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_document_straightening_parameters_create( + SCANBOTSDK_DOCUMENT_STRAIGHTENING_MODE_STRAIGHTEN, + aspect_ratios, + 4, + &straightening_params + ); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straightening_parameters_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_document_enhancer_create(&enhancer); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_enhancer_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_document_enhancer_straighten( + enhancer, + image, + straightening_params, + NULL, + 0, + &result + ); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_enhancer_straighten: %d: %s\n", ec, error_message(ec)); goto cleanup; } + + ec = scanbotsdk_document_straightening_result_get_straightened_image(result, &straightened_image); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straightening_result_get_straightened_image: %d: %s\n", ec, error_message(ec)); goto cleanup; } + + if (straightened_image == NULL) { + fprintf(stderr, "No straightened image returned.\n"); + } + + /* straightened_image can be saved or processed further here */ + +cleanup: + scanbotsdk_document_enhancer_free(enhancer); + scanbotsdk_document_straightening_result_free(result); + scanbotsdk_document_straightening_parameters_free(straightening_params); + + scanbotsdk_aspect_ratio_free(aspect_ratios[0]); + scanbotsdk_aspect_ratio_free(aspect_ratios[1]); + scanbotsdk_aspect_ratio_free(aspect_ratios[2]); + scanbotsdk_aspect_ratio_free(aspect_ratios[3]); + + return ec; +} \ No newline at end of file diff --git a/examples/c/src/utils/utils.c b/examples/c/src/utils/utils.c index cd1cc84..0faed5d 100644 --- a/examples/c/src/utils/utils.c +++ b/examples/c/src/utils/utils.c @@ -90,6 +90,8 @@ void print_usage(const char *prog) { printf("or\n"); printf(" %s classify --file [--license ]\n", prog); printf("or\n"); + printf(" %s enhance --file [--license ]\n", prog); + printf("or\n"); printf(" %s analyze --file --save [--license ]\n", prog); printf("or\n"); printf(" %s parse --text \"\" [--license ]\n\n", prog); @@ -103,6 +105,9 @@ void print_usage(const char *prog) { printf("Available classify commands:\n"); printf(" document \n\n"); + printf("Available enhance commands:\n"); + printf(" document \n\n"); + printf("Available analyze commands:\n"); printf(" analyze_multi_page | crop_analyze\n\n"); diff --git a/examples/java/README.md b/examples/java/README.md index ea8f421..c1c3a9a 100644 --- a/examples/java/README.md +++ b/examples/java/README.md @@ -9,13 +9,14 @@ def SCANBOTSDK_VERSION = "" // e.g., 8.1.0 ``` ## Usage -The example supports four commands: **scan**, **analyze**, **classify**, and **parse**. +The example supports five commands: **scan**, **analyze**, **classify**, **enhance**, and **parse**. ```bash ./gradlew run --args='scan --file [--license ]' ./gradlew run --args='scan --resource [--license ]' ./gradlew run --args='analyze --file --save [--license ]' ./gradlew run --args='analyze --resource --save [--license ]' ./gradlew run --args='classify --file|--resource [--license ]' +./gradlew run --args='enhance --file [--license ]' ./gradlew run --args='parse --text "" [--license ]' ``` @@ -24,6 +25,7 @@ The example supports four commands: **scan**, **analyze**, **classify**, and **p ./gradlew run --args='scan barcode --file images/example.jpg --license ' ./gradlew run --args='analyze analyze_multi_page --resource files/doc.pdf --license ' ./gradlew run --args='analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license ' +./gradlew run --args='enhance document --file images/doc.jpg --license ' ./gradlew run --args='parse mrz --text "P' ``` diff --git a/examples/java/build.gradle b/examples/java/build.gradle index ce3694a..f8dd311 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -4,7 +4,7 @@ plugins { } // TODO Add your SCANBOTSDK_VERSION here. -def SCANBOTSDK_VERSION = "0.810.7" +def SCANBOTSDK_VERSION = "0.900.7" def arch = System.getProperty("os.arch") def SCANBOTSDK_ARCHITECTURE = (arch.contains("arm") || arch.contains("aarch64")) ? "aarch64" : "x86_64" diff --git a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java index 315c169..f2e0d63 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java +++ b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java @@ -7,6 +7,7 @@ import io.scanbot.sdk.snippets.barcode.*; import io.scanbot.sdk.snippets.datacapture.*; import io.scanbot.sdk.snippets.document.*; +import io.scanbot.sdk.snippets.enhancer.DocumentEnhancerSnippet; import io.scanbot.sdk.utils.*; import java.util.Arrays; @@ -83,6 +84,16 @@ public static void main(String[] args) throws Exception { break; } } + case "enhance": { + if (file == null && resource == null) { ExampleUsage.print(); return; } + try (ImageRef image = Utils.createImageRef(file, resource)) { + switch (subcommand) { + case "document": DocumentEnhancerSnippet.run(image); break; + default: ExampleUsage.print(); + } + break; + } + } case "parse": { if (text == null || text.trim().isEmpty()) { ExampleUsage.print(); return; } switch (subcommand) { diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java index 0752356..fc9539a 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java @@ -15,7 +15,6 @@ public class AnalyzeMultiPageSnippet { public static void run(String filePath, String resourcePath) throws Exception { DocumentQualityAnalyzerConfiguration analyze_config = new DocumentQualityAnalyzerConfiguration(); analyze_config.getProcessByTileConfiguration().setTileSize(300);; - analyze_config.setDetectOrientation(true); analyze_config.setMinEstimatedNumberOfSymbolsForDocument(20); // Configure other parameters as needed. @@ -37,9 +36,8 @@ public static void run(String filePath, String resourcePath) throws Exception { // early to avoid keeping too many decompressed images in memory. try (ImageRef image = images.get(imageIndex).getImage()) { DocumentQualityAnalyzerResult result = analyzer.run(image); - System.out.printf("Page %d, Image %d -> Found: %b, Quality: %s%n", - pageIndex + 1, imageIndex + 1, - result.getDocumentFound(), result.getQuality()); + System.out.printf("Page %d, Image %d -> Quality: %s%n", + pageIndex + 1, imageIndex + 1, result.getQuality()); System.out.printf("Orientation: %f", result.getOrientation()); } } diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/CropAndAnalyzeSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/CropAndAnalyzeSnippet.java index 6d03ebb..180fc31 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/CropAndAnalyzeSnippet.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/CropAndAnalyzeSnippet.java @@ -46,8 +46,7 @@ public static void run(String filePath, String resourcePath, String savePath) th } DocumentQualityAnalyzerResult result = analyzer.run(cropped); - System.out.printf("Found: %b, Quality: %s%n", - result.getDocumentFound(), result.getQuality()); + System.out.printf("Quality: %s%n", result.getQuality()); } } } diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java new file mode 100644 index 0000000..ae6b48a --- /dev/null +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java @@ -0,0 +1,30 @@ +package io.scanbot.sdk.snippets.enhancer; +import java.util.List; + +import io.scanbot.sdk.documentscanner.DocumentEnhancer; +import io.scanbot.sdk.documentscanner.DocumentStraighteningMode; +import io.scanbot.sdk.documentscanner.DocumentStraighteningParameters; +import io.scanbot.sdk.documentscanner.DocumentStraighteningResult; +import io.scanbot.sdk.geometry.AspectRatio; +import io.scanbot.sdk.image.ImageRef; + +public class DocumentEnhancerSnippet { + public static void run(ImageRef image) throws Exception { + DocumentStraighteningParameters params = new DocumentStraighteningParameters(); + params.setStraighteningMode(DocumentStraighteningMode.STRAIGHTEN); + params.setAspectRatios(List.of( + new AspectRatio(5.0, 7.0), + new AspectRatio(1.0, 1.0), + new AspectRatio(16.0, 9.0), + new AspectRatio(3.0, 4.0) + )); + + try ( + DocumentEnhancer enhancer = new DocumentEnhancer() + ) { + DocumentStraighteningResult result = enhancer.straighten(image, params, List.of()); + // The straightened image can be accessed via result.getStraightenedImage() and saved or further processed as needed. + + } + } +} diff --git a/examples/nodejs/README.md b/examples/nodejs/README.md index 724cba3..ba372c3 100644 --- a/examples/nodejs/README.md +++ b/examples/nodejs/README.md @@ -16,13 +16,12 @@ node -e "console.log(require('scanbotsdk') ? 'Scanbot SDK loaded' : 'Error')" ``` ## Usage -The example supports four modes: **scan**, **analyze**, **classify**, and **parse**. +The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. ```bash npx ts-node src/index.ts scan --file [--license ] -npx ts-node src/index.ts scan --file [--license ] -npx ts-node src/index.ts analyze --file [--save ] [--license ] npx ts-node src/index.ts analyze --file [--save ] [--license ] npx ts-node src/index.ts classify --file [--license ] +npx ts-node src/index.ts enhance --file [--license ] npx ts-node src/index.ts parse --text "" [--license ] ``` @@ -31,6 +30,7 @@ npx ts-node src/index.ts parse --text "" [--license ] npx ts-node src/index.ts scan barcode --file images/example.jpg --license npx ts-node src/index.ts analyze analyze_multi_page --file files/doc.pdf --license npx ts-node src/index.ts analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license +npx ts-node src/index.ts enhance document --file images/doc.jpg --license npx ts-node src/index.ts parse mrz --text "P ``` diff --git a/examples/nodejs/package-lock.json b/examples/nodejs/package-lock.json index 3a70624..5edff02 100644 --- a/examples/nodejs/package-lock.json +++ b/examples/nodejs/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.810.7/nodejs-scanbotsdk-0.810.7.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz" }, "devDependencies": { "@types/node": "^24.3.0", @@ -154,9 +154,9 @@ "license": "ISC" }, "node_modules/scanbotsdk": { - "version": "0.810.7", - "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.810.7/nodejs-scanbotsdk-0.810.7.tgz", - "integrity": "sha512-ro8X14c/ytXzXzG1rekqoHNKwS8GptRrBi1uJhVms9g1uc9SQrzyEV+u67/GddpPHCykGp1F/JVvjiLRsgcTBg==", + "version": "0.900.7", + "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz", + "integrity": "sha512-/pFpFk3H4eNmFpA+tmQI5A4uit5YiPFtyJhWvQJ35ukyw6KdaLrGV1GW6fMNBqyGBYyljn1CcCEP6kiVjfW2Cw==", "hasInstallScript": true, "license": "Commercial", "os": [ diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index b9c5408..e797c5f 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -15,6 +15,6 @@ "typescript": "^5.9.2" }, "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.810.7/nodejs-scanbotsdk-0.810.7.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz" } } diff --git a/examples/nodejs/src/index.ts b/examples/nodejs/src/index.ts index 66bbb6f..c153784 100644 --- a/examples/nodejs/src/index.ts +++ b/examples/nodejs/src/index.ts @@ -17,6 +17,7 @@ import { MrzParserSnippet } from "./snippets/datacapture/mrz-parser"; import { ParseBarcodeDocumentSnippet } from "./snippets/barcode/parse-barcode-document"; import { AnalyzeMultiPageSnippet } from "./snippets/document/analyze-multipage"; import { CropAndAnalyzeSnippet } from "./snippets/document/crop-analyze"; +import { DocumentEnhancerSnippet } from "./snippets/enhancer/document-enhancer"; async function awaitPromise(promise: Promise, maxAwaitTimeMs: number = 60 * 1000): Promise { const timer = setTimeout(() => { @@ -106,6 +107,17 @@ async function main(): Promise { break; } + case "enhance": { + if (!file) { printUsage(); return; } + const image = await ScanbotSDK.ImageRef.fromPath(file); + + switch (subcommand) { + case "document": await DocumentEnhancerSnippet.run(image); break; + default: printUsage(); + } + break; + } + case "parse": { if (!text || text.trim().length === 0) { printUsage(); return; } diff --git a/examples/nodejs/src/snippets/document/analyze-multipage.ts b/examples/nodejs/src/snippets/document/analyze-multipage.ts index ddf8df1..5614c28 100644 --- a/examples/nodejs/src/snippets/document/analyze-multipage.ts +++ b/examples/nodejs/src/snippets/document/analyze-multipage.ts @@ -5,7 +5,6 @@ export class AnalyzeMultiPageSnippet { public static async run(filePath: string): Promise { const analyzeConfig = new ScanbotSDK.DocumentQualityAnalyzerConfiguration(); analyzeConfig.processByTileConfiguration.tileSize = 300; - analyzeConfig.detectOrientation = true; analyzeConfig.minEstimatedNumberOfSymbolsForDocument = 20; // configure other parameters as needed @@ -31,9 +30,7 @@ export class AnalyzeMultiPageSnippet { // `await using` ensures the result is properly disposed when the scope ends, as it holds unmanaged resources. await using result = await analyzer.run(extractedImage); console.log( - `Page ${pageIndex + 1}, Image ${imageIndex + 1} -> Found: ${ - result.documentFound - }, Quality: ${result.quality}` + `Page ${pageIndex + 1}, Image ${imageIndex + 1} -> Quality: ${result.quality}` ); } } diff --git a/examples/nodejs/src/snippets/document/crop-analyze.ts b/examples/nodejs/src/snippets/document/crop-analyze.ts index 9e4755b..156d170 100644 --- a/examples/nodejs/src/snippets/document/crop-analyze.ts +++ b/examples/nodejs/src/snippets/document/crop-analyze.ts @@ -43,7 +43,7 @@ export class CropAndAnalyzeSnippet { await using result = await analyzer.run(cropped); console.log( - `Found: ${result.documentFound}, Quality: ${result.quality}` + `Quality: ${result.quality}` ); } } diff --git a/examples/nodejs/src/snippets/enhancer/document-enhancer.ts b/examples/nodejs/src/snippets/enhancer/document-enhancer.ts new file mode 100644 index 0000000..fddebcc --- /dev/null +++ b/examples/nodejs/src/snippets/enhancer/document-enhancer.ts @@ -0,0 +1,22 @@ +import * as ScanbotSDK from "scanbotsdk"; +import { AspectRatio } from "scanbotsdk"; + +export class DocumentEnhancerSnippet { + public static async run(image: ScanbotSDK.ImageRef): Promise { + var params = new ScanbotSDK.DocumentStraighteningParameters(); + params.straighteningMode = "STRAIGHTEN"; + params.aspectRatios =[ + new AspectRatio({ width: 5.0, height: 7.0 }), + new AspectRatio({ width: 1.0, height: 1.0 }), + new AspectRatio({ width: 16.0, height: 9.0 }), + new AspectRatio({ width: 3.0, height: 4.0 }) + ]; + + // `await using` ensures both enhancer and result are properly disposed + // when the scope ends, as they hold unmanaged resources. + await using enhancer = await ScanbotSDK.DocumentEnhancer.create(); + await using result = await enhancer.straighten(image, params); + + // The straightened image can be accessed via result.straightenedImage and saved or further processed as needed. + } +} diff --git a/examples/python/README.md b/examples/python/README.md index c3daf1b..0c2773d 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -132,11 +132,12 @@ Replace `` with the actual version number of the SDK you wa ``` ## Usage -The example supports four modes: **scan**, **analyze**, **classify**, and **parse**. +The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. ```bash python main.py scan --file [--license ] python main.py analyze --file [--save ] [--license ] python main.py classify --file|--resource [--license ] +python main.py enhance --file [--license ] python main.py parse --text "" [--license ] python main.py live --device "" [--license ] [--preview] [--use_tensorrt] ``` @@ -146,6 +147,7 @@ python main.py live --device "" [--license ] [-- python main.py scan barcode --file images/example.jpg --license python main.py analyze analyze_multi_page --file files/doc.pdf --license python main.py analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license +python main.py enhance document --file images/doc.jpg --license python main.py parse mrz --text "P python main.py live barcode --device "0" --license ``` diff --git a/examples/python/main.py b/examples/python/main.py index ddaa035..cb8ae0f 100644 --- a/examples/python/main.py +++ b/examples/python/main.py @@ -1,6 +1,7 @@ import sys import scanbotsdk +from examples.python.snippets.enhancer.document_enhancer import enhance_document from snippets.document.document_classifier import classify_document from snippets.document.analyze_multi_page import analyze_multi_page from snippets.document.crop_and_analyze import crop_and_analyze @@ -72,6 +73,12 @@ def main(): with create_image_ref(file_path) as image: if subcommand == "document": classify_document(image) else: print_usage() + + elif category == "enhance": + if not file_path: print_usage(); return + with create_image_ref(file_path) as image: + if subcommand == "document": enhance_document(image) + else: print_usage() elif category == "analyze": if not file_path: print_usage(); return diff --git a/examples/python/snippets/document/analyze_multi_page.py b/examples/python/snippets/document/analyze_multi_page.py index 7aac17d..380dbfb 100644 --- a/examples/python/snippets/document/analyze_multi_page.py +++ b/examples/python/snippets/document/analyze_multi_page.py @@ -2,7 +2,6 @@ def analyze_multi_page(file_path: str): configuration = DocumentQualityAnalyzerConfiguration( - detect_orientation=True, min_estimated_number_of_symbols_for_document=20, process_by_tile_configuration=ProcessByTileConfiguration( tile_size=300 diff --git a/examples/python/snippets/enhancer/document_enhancer.py b/examples/python/snippets/enhancer/document_enhancer.py new file mode 100644 index 0000000..1f51408 --- /dev/null +++ b/examples/python/snippets/enhancer/document_enhancer.py @@ -0,0 +1,16 @@ +from scanbotsdk import * + +def enhance_document(image: ImageRef): + params = DocumentStraighteningParameters() + params.straightening_mode = DocumentStraighteningMode.STRAIGHTEN + params.aspect_ratios = [ + AspectRatio(width=5.0, height=7.0), + AspectRatio(width=1.0, height=1.0), + AspectRatio(width=16.0, height=9.0), + AspectRatio(width=3.0, height=4.0) + ] + + enhancer = DocumentEnhancer() + result: DocumentStraighteningResult = enhancer.straighten(image=image, parameters=params) + + # The straightened image can be accessed via result.straightened_image and saved or further processed as needed. From 9bfd17c62f78533b68f7849a2978b305e31d55fa Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Fri, 19 Jun 2026 14:30:13 +0200 Subject: [PATCH 02/19] Remove document classification feature and update usage examples across all languages --- examples/c/README.md | 3 +- .../snippets/document/document_classifier.h | 8 ---- examples/c/src/main.c | 10 ----- .../snippets/document/document_classifier.c | 45 ------------------- examples/c/src/utils/utils.c | 5 --- examples/java/README.md | 3 +- examples/java/build.gradle | 2 +- .../io/scanbot/sdk/ScanbotSDKExample.java | 10 ----- .../document/DocumentClassifierSnippet.java | 24 ---------- .../io/scanbot/sdk/utils/ExampleUsage.java | 5 --- examples/nodejs/README.md | 3 +- examples/nodejs/package-lock.json | 8 ++-- examples/nodejs/package.json | 2 +- examples/nodejs/src/index.ts | 14 +----- .../snippets/document/document-classifier.ts | 19 -------- .../src/snippets/utils/example-usage.ts | 1 - examples/python/README.md | 3 +- examples/python/main.py | 9 +--- .../snippets/document/document_classifier.py | 20 --------- examples/python/utils.py | 3 -- test-scripts/test-c.sh | 2 - test-scripts/test-java.sh | 2 - test-scripts/test-nodejs.sh | 2 - test-scripts/test-python.sh | 2 - 24 files changed, 12 insertions(+), 193 deletions(-) delete mode 100644 examples/c/include/snippets/document/document_classifier.h delete mode 100644 examples/c/src/snippets/document/document_classifier.c delete mode 100644 examples/java/src/main/java/io/scanbot/sdk/snippets/document/DocumentClassifierSnippet.java delete mode 100644 examples/nodejs/src/snippets/document/document-classifier.ts delete mode 100644 examples/python/snippets/document/document_classifier.py diff --git a/examples/c/README.md b/examples/c/README.md index 8ca796f..10120d9 100644 --- a/examples/c/README.md +++ b/examples/c/README.md @@ -83,11 +83,10 @@ In order to build all examples, run the following commands: ## Usage -The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. +The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. ```bash ./scanbotsdk_example scan --file [--license ] ./scanbotsdk_example analyze --file [--save ] [--license ] -./scanbotsdk_example classify --file [--license ] ./scanbotsdk_example enhance --file [--license ] ./scanbotsdk_example parse --text "" [--license ] ./scanbotsdk_example live --file [--license ] [--use_tensorrt] diff --git a/examples/c/include/snippets/document/document_classifier.h b/examples/c/include/snippets/document/document_classifier.h deleted file mode 100644 index 8dd80ef..0000000 --- a/examples/c/include/snippets/document/document_classifier.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef DOCUMENT_CLASSIFIER_H -#define DOCUMENT_CLASSIFIER_H - -#include - -scanbotsdk_error_code_t classify_document(scanbotsdk_image_t *image); - -#endif diff --git a/examples/c/src/main.c b/examples/c/src/main.c index bd0029f..865ccae 100644 --- a/examples/c/src/main.c +++ b/examples/c/src/main.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -70,15 +69,6 @@ int main(int argc, char *argv[]) { else if (strcmp(command, "vin") == 0) ec = detect_vin(image); else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; } } - else if (strcmp(category, "classify") == 0) { - if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; } - - ec = load_image_from_path(file_path, &image); - if (ec != SCANBOTSDK_OK) goto cleanup; - - if (strcmp(command, "document") == 0) ec = classify_document(image); - else { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; } - } else if (strcmp(category, "enhance") == 0) { if (!file_path) { print_usage(argv[0]); ec = SCANBOTSDK_ERROR_INVALID_ARGUMENT; goto cleanup; } diff --git a/examples/c/src/snippets/document/document_classifier.c b/examples/c/src/snippets/document/document_classifier.c deleted file mode 100644 index c93b974..0000000 --- a/examples/c/src/snippets/document/document_classifier.c +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include - -#include -#include - -scanbotsdk_error_code_t classify_document(scanbotsdk_image_t *image) { - scanbotsdk_error_code_t ec = SCANBOTSDK_OK; - - scanbotsdk_document_classifier_configuration_t *config = NULL; - scanbotsdk_document_classifier_result_t *result = NULL; - scanbotsdk_document_classifier_t *classifier = NULL; - scanbotsdk_document_detection_result_t *detection_result = NULL; - scanbotsdk_document_classifier_status_t status; - scanbotsdk_document_type_t doc_type; - - ec = scanbotsdk_document_classifier_configuration_create_with_defaults(&config); - // Configure other parameters as needed. - - ec = scanbotsdk_document_classifier_create(config, &classifier); - if (ec != SCANBOTSDK_OK) { fprintf(stderr, "classifier_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } - - ec = scanbotsdk_document_classifier_run(classifier, image, &result); - if (ec != SCANBOTSDK_OK) { fprintf(stderr, "classifier_run: %d: %s\n", ec, error_message(ec)); goto cleanup; } - - ec = scanbotsdk_document_classifier_result_get_status(result, &status); - - const char *status_str = NULL; - ec = scanbotsdk_document_classifier_status_t_to_string(status, &status_str); - printf("Classifier Status: %s\n", status_str); - - ec = scanbotsdk_document_classifier_result_get_document_type(result, &doc_type); - - const char *doc_type_str = NULL; - ec = scanbotsdk_document_type_t_to_string(doc_type, &doc_type_str); - printf("Type: %s\n", doc_type_str); - -cleanup: - scanbotsdk_document_classifier_free(classifier); - scanbotsdk_document_detection_result_free(detection_result); - scanbotsdk_document_classifier_result_free(result); - scanbotsdk_document_classifier_configuration_free(config); - return ec; -} - diff --git a/examples/c/src/utils/utils.c b/examples/c/src/utils/utils.c index 0faed5d..dd334a1 100644 --- a/examples/c/src/utils/utils.c +++ b/examples/c/src/utils/utils.c @@ -88,8 +88,6 @@ void print_usage(const char *prog) { printf("Usage:\n"); printf(" %s scan --file [--license ]\n", prog); printf("or\n"); - printf(" %s classify --file [--license ]\n", prog); - printf("or\n"); printf(" %s enhance --file [--license ]\n", prog); printf("or\n"); printf(" %s analyze --file --save [--license ]\n", prog); @@ -102,9 +100,6 @@ void print_usage(const char *prog) { printf(" barcode | document | check | credit_card | document_data_extractor |\n"); printf(" medical_certificate | mrz | ocr | text_pattern | vin\n\n"); - printf("Available classify commands:\n"); - printf(" document \n\n"); - printf("Available enhance commands:\n"); printf(" document \n\n"); diff --git a/examples/java/README.md b/examples/java/README.md index c1c3a9a..3be21ed 100644 --- a/examples/java/README.md +++ b/examples/java/README.md @@ -9,13 +9,12 @@ def SCANBOTSDK_VERSION = "" // e.g., 8.1.0 ``` ## Usage -The example supports five commands: **scan**, **analyze**, **classify**, **enhance**, and **parse**. +The example supports five commands: **scan**, **analyze**, **enhance**, and **parse**. ```bash ./gradlew run --args='scan --file [--license ]' ./gradlew run --args='scan --resource [--license ]' ./gradlew run --args='analyze --file --save [--license ]' ./gradlew run --args='analyze --resource --save [--license ]' -./gradlew run --args='classify --file|--resource [--license ]' ./gradlew run --args='enhance --file [--license ]' ./gradlew run --args='parse --text "" [--license ]' ``` diff --git a/examples/java/build.gradle b/examples/java/build.gradle index f8dd311..689828c 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -4,7 +4,7 @@ plugins { } // TODO Add your SCANBOTSDK_VERSION here. -def SCANBOTSDK_VERSION = "0.900.7" +def SCANBOTSDK_VERSION = "0.900.6" def arch = System.getProperty("os.arch") def SCANBOTSDK_ARCHITECTURE = (arch.contains("arm") || arch.contains("aarch64")) ? "aarch64" : "x86_64" diff --git a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java index f2e0d63..e05c9c6 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java +++ b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java @@ -74,16 +74,6 @@ public static void main(String[] args) throws Exception { } break; } - case "classify": { - if (file == null && resource == null) { ExampleUsage.print(); return; } - try (ImageRef image = Utils.createImageRef(file, resource)) { - switch (subcommand) { - case "document": DocumentClassifierSnippet.run(image); break; - default: ExampleUsage.print(); - } - break; - } - } case "enhance": { if (file == null && resource == null) { ExampleUsage.print(); return; } try (ImageRef image = Utils.createImageRef(file, resource)) { diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/DocumentClassifierSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/DocumentClassifierSnippet.java deleted file mode 100644 index 2b9f3d8..0000000 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/DocumentClassifierSnippet.java +++ /dev/null @@ -1,24 +0,0 @@ -package io.scanbot.sdk.snippets.document; - -import io.scanbot.sdk.documentclassifier.DocumentClassifier; -import io.scanbot.sdk.documentclassifier.DocumentClassifierConfiguration; -import io.scanbot.sdk.documentclassifier.DocumentClassifierResult; -import io.scanbot.sdk.image.ImageRef; - -public class DocumentClassifierSnippet { - public static void run(ImageRef image) throws Exception { - DocumentClassifierConfiguration config = new DocumentClassifierConfiguration(); - // Configure other parameters as needed. - - try ( - DocumentClassifier classifier = new DocumentClassifier(config); - DocumentClassifierResult result = classifier.run(image); - ) { - System.out.println("Detection status: " + result.getStatus()); - System.out.println("Type: " + result.getDocumentType()); - result.getDocumentScanningResult().getDetectionResult().getPoints().forEach(p -> - System.out.printf("x: %d, y: %d%n", p.getX(), p.getY()) - ); - } - } -} diff --git a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java index 1298a77..5581063 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java +++ b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java @@ -9,8 +9,6 @@ public static void print() { System.out.println("or"); System.out.println(" ./gradlew run --args='scan --file [--license ]'"); System.out.println("or"); - System.out.println(" ./gradlew run --args='classify --file|--resource [--license ]'"); - System.out.println(); System.out.println(" ./gradlew run --args='analyze --resource --save [--license ]'"); System.out.println("or"); System.out.println(" ./gradlew run --args='analyze --file --save [--license ]'"); @@ -23,9 +21,6 @@ public static void print() { System.out.println("Available analyze commands:"); System.out.println(" analyze_multi_page | crop_analyze"); System.out.println(); - System.out.println("Available classify commands:"); - System.out.println(" document"); - System.out.println(); System.out.println("Available parse commands:"); System.out.println(" mrz | barcode_doc"); System.out.println(); diff --git a/examples/nodejs/README.md b/examples/nodejs/README.md index ba372c3..93f41f0 100644 --- a/examples/nodejs/README.md +++ b/examples/nodejs/README.md @@ -16,11 +16,10 @@ node -e "console.log(require('scanbotsdk') ? 'Scanbot SDK loaded' : 'Error')" ``` ## Usage -The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. +The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. ```bash npx ts-node src/index.ts scan --file [--license ] npx ts-node src/index.ts analyze --file [--save ] [--license ] -npx ts-node src/index.ts classify --file [--license ] npx ts-node src/index.ts enhance --file [--license ] npx ts-node src/index.ts parse --text "" [--license ] ``` diff --git a/examples/nodejs/package-lock.json b/examples/nodejs/package-lock.json index 5edff02..3637aa3 100644 --- a/examples/nodejs/package-lock.json +++ b/examples/nodejs/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz" }, "devDependencies": { "@types/node": "^24.3.0", @@ -154,9 +154,9 @@ "license": "ISC" }, "node_modules/scanbotsdk": { - "version": "0.900.7", - "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz", - "integrity": "sha512-/pFpFk3H4eNmFpA+tmQI5A4uit5YiPFtyJhWvQJ35ukyw6KdaLrGV1GW6fMNBqyGBYyljn1CcCEP6kiVjfW2Cw==", + "version": "0.900.6", + "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz", + "integrity": "sha512-Y83QsPumkkoa8ledS1eS69FxlYF7Di0izzHAotPtcIsRah+4X1cE697IwunzGG4g1KVTe+lJq0iu5i9Kk6rRjg==", "hasInstallScript": true, "license": "Commercial", "os": [ diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index e797c5f..9ed446d 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -15,6 +15,6 @@ "typescript": "^5.9.2" }, "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.7/nodejs-scanbotsdk-0.900.7.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz" } } diff --git a/examples/nodejs/src/index.ts b/examples/nodejs/src/index.ts index c153784..62bdb6d 100644 --- a/examples/nodejs/src/index.ts +++ b/examples/nodejs/src/index.ts @@ -12,7 +12,6 @@ import { MrzScannerSnippet } from "./snippets/datacapture/mrz-scanner"; import { TextPatternScannerSnippet } from "./snippets/datacapture/text-pattern-scanner"; import { OcrSnippet } from "./snippets/datacapture/ocr"; import { VinScannerSnippet } from "./snippets/datacapture/vin-scanner"; -import { DocumentClassifierSnippet } from "./snippets/document/document-classifier"; import { MrzParserSnippet } from "./snippets/datacapture/mrz-parser"; import { ParseBarcodeDocumentSnippet } from "./snippets/barcode/parse-barcode-document"; import { AnalyzeMultiPageSnippet } from "./snippets/document/analyze-multipage"; @@ -95,18 +94,7 @@ async function main(): Promise { } break; } - - case "classify": { - if (!file) { printUsage(); return; } - const image = await ScanbotSDK.ImageRef.fromPath(file); - - switch (subcommand) { - case "document": await DocumentClassifierSnippet.run(image); break; - default: printUsage(); - } - break; - } - + case "enhance": { if (!file) { printUsage(); return; } const image = await ScanbotSDK.ImageRef.fromPath(file); diff --git a/examples/nodejs/src/snippets/document/document-classifier.ts b/examples/nodejs/src/snippets/document/document-classifier.ts deleted file mode 100644 index bf85dd9..0000000 --- a/examples/nodejs/src/snippets/document/document-classifier.ts +++ /dev/null @@ -1,19 +0,0 @@ -import * as ScanbotSDK from "scanbotsdk"; - -export class DocumentClassifierSnippet { - public static async run(image: ScanbotSDK.ImageRef): Promise { - var config = new ScanbotSDK.DocumentClassifierConfiguration(); - - // `await using` ensures both classifier and result are properly disposed - // when the scope ends, as they hold unmanaged resources. - await using classifier = await ScanbotSDK.DocumentClassifier.create(config); - await using result = await classifier.run(image); - - console.log("Detection status: " + result.status); - console.log("Type: " + result.documentType); - - result.documentScanningResult.detectionResult.points.forEach((p) => { - console.log(`x: ${p.x}, y: ${p.y}`); - }); - } -} diff --git a/examples/nodejs/src/snippets/utils/example-usage.ts b/examples/nodejs/src/snippets/utils/example-usage.ts index ec91d1d..ff94d5b 100644 --- a/examples/nodejs/src/snippets/utils/example-usage.ts +++ b/examples/nodejs/src/snippets/utils/example-usage.ts @@ -6,7 +6,6 @@ Usage: Categories & subcommands: scan analyze - classify parse Flags: diff --git a/examples/python/README.md b/examples/python/README.md index 0c2773d..1d06c76 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -132,11 +132,10 @@ Replace `` with the actual version number of the SDK you wa ``` ## Usage -The example supports five modes: **scan**, **analyze**, **classify**, **enhance**, and **parse**. +The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. ```bash python main.py scan --file [--license ] python main.py analyze --file [--save ] [--license ] -python main.py classify --file|--resource [--license ] python main.py enhance --file [--license ] python main.py parse --text "" [--license ] python main.py live --device "" [--license ] [--preview] [--use_tensorrt] diff --git a/examples/python/main.py b/examples/python/main.py index cb8ae0f..3b198a9 100644 --- a/examples/python/main.py +++ b/examples/python/main.py @@ -1,8 +1,7 @@ import sys import scanbotsdk -from examples.python.snippets.enhancer.document_enhancer import enhance_document -from snippets.document.document_classifier import classify_document +from snippets.enhancer.document_enhancer import enhance_document from snippets.document.analyze_multi_page import analyze_multi_page from snippets.document.crop_and_analyze import crop_and_analyze from snippets.barcode.barcode_document_parser import parse_barcode_document @@ -67,12 +66,6 @@ def main(): elif subcommand == "text_pattern": scan_text_pattern(image) elif subcommand == "vin": scan_vin(image) else: print_usage() - - if category == "classify": - if not file_path: print_usage(); return - with create_image_ref(file_path) as image: - if subcommand == "document": classify_document(image) - else: print_usage() elif category == "enhance": if not file_path: print_usage(); return diff --git a/examples/python/snippets/document/document_classifier.py b/examples/python/snippets/document/document_classifier.py deleted file mode 100644 index 68244dd..0000000 --- a/examples/python/snippets/document/document_classifier.py +++ /dev/null @@ -1,20 +0,0 @@ -from scanbotsdk import * - -def classify_document(image: ImageRef): - config = DocumentClassifierConfiguration( - crop=True - ) - - classifier = DocumentClassifier(configuration=config) - result: DocumentClassifierResult = classifier.run(image=image) - - print(f"Detection status: {result.status.name}") - print(f"Type: {result.document_type.name}") - - if result.document_scanning_result: - print("Detected points:") - for point in result.document_scanning_result.detection_result.points: - print(f"\tx: {point.x}, y: {point.y}") - else: - print("No document corners detected.") - diff --git a/examples/python/utils.py b/examples/python/utils.py index 41c4f31..6fa4f3d 100644 --- a/examples/python/utils.py +++ b/examples/python/utils.py @@ -54,7 +54,6 @@ def print_usage(): print("Scanbot SDK Example\n") print("Usage:") print(" python main.py scan --file [--license ]") - print(" python main.py classify --file [--license ]") print(" python main.py analyze --file --save [--license ]") print(" python main.py parse --text \"\" [--license ]") print(" python main.py live --device [--license ] --preview --use_tensorrt\n") @@ -64,8 +63,6 @@ def print_usage(): " barcode | document | check | credit_card | document_data_extractor | medical_certificate | mrz | ocr | text_pattern | vin\n") print("Available analyze commands:") print(" analyze_multi_page | crop_analyze\n") - print("Available classify commands:") - print(" document\n") print("Available parse commands:") print(" mrz | barcode_doc\n") print("Available live commands:") diff --git a/test-scripts/test-c.sh b/test-scripts/test-c.sh index 6f27080..5af70cd 100755 --- a/test-scripts/test-c.sh +++ b/test-scripts/test-c.sh @@ -46,7 +46,6 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" - "classify document --file ../../test-scripts/test-images/toll_receipt.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -65,7 +64,6 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" - "Document classify" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-java.sh b/test-scripts/test-java.sh index 15c7c41..9b403d9 100755 --- a/test-scripts/test-java.sh +++ b/test-scripts/test-java.sh @@ -33,7 +33,6 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" - "classify document --file ../../test-scripts/test-images/toll_receipt.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --save /tmp/out.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --save /tmp/crop.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -52,7 +51,6 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" - "Document classify" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-nodejs.sh b/test-scripts/test-nodejs.sh index 5d2dac2..1b36db8 100755 --- a/test-scripts/test-nodejs.sh +++ b/test-scripts/test-nodejs.sh @@ -41,7 +41,6 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" - "classify document --file ../../test-scripts/test-images/toll_receipt.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -60,7 +59,6 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" - "Document classify" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-python.sh b/test-scripts/test-python.sh index 60c0b62..cd9b8b5 100755 --- a/test-scripts/test-python.sh +++ b/test-scripts/test-python.sh @@ -33,7 +33,6 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" - "classify document --file ../../test-scripts/test-images/toll_receipt.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -52,7 +51,6 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" - "Document classify" "Multi-page analyze" "Crop analyze" "MRZ parse" From dffd403e75af850325fe362d25d3c38c9879acc3 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Fri, 19 Jun 2026 14:37:22 +0200 Subject: [PATCH 03/19] Update SDK version to 0.900.6 in CI workflow and test scripts --- .github/workflows/run-tests-ci.yml | 2 +- test-scripts/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests-ci.yml b/.github/workflows/run-tests-ci.yml index 4221460..2282246 100644 --- a/.github/workflows/run-tests-ci.yml +++ b/.github/workflows/run-tests-ci.yml @@ -41,7 +41,7 @@ on: # Global environment variables env: - SDK_VERSION: '0.810.7' + SDK_VERSION: '0.900.6' jobs: test-x86_64: diff --git a/test-scripts/README.md b/test-scripts/README.md index 3f82e35..10ae792 100644 --- a/test-scripts/README.md +++ b/test-scripts/README.md @@ -29,7 +29,7 @@ test-scripts/ ```bash export SCANBOT_LICENSE="your-license-key-here" -export SDK_VERSION=0.810.7 +export SDK_VERSION=0.900.6 ``` ### 2. Build Test Container From a7955f5840747d86a27d5ed3c1046c5861e7d75b Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Fri, 19 Jun 2026 15:10:55 +0200 Subject: [PATCH 04/19] Update examples and tests to include 'enhance' command and improve error handling --- examples/c/README.md | 2 +- .../snippets/document/analyze_multi_page.c | 23 ++++++++++++++---- .../src/snippets/document/crop_and_analyze.c | 24 +++++++++++++++---- examples/java/README.md | 4 ++-- .../document/AnalyzeMultiPageSnippet.java | 2 +- .../io/scanbot/sdk/utils/ExampleUsage.java | 8 +++++++ examples/nodejs/README.md | 2 +- .../src/snippets/utils/example-usage.ts | 2 ++ examples/python/README.md | 2 +- examples/python/utils.py | 6 +++++ test-scripts/test-c.sh | 2 ++ test-scripts/test-java.sh | 2 ++ test-scripts/test-nodejs.sh | 2 ++ test-scripts/test-python.sh | 2 ++ 14 files changed, 69 insertions(+), 14 deletions(-) diff --git a/examples/c/README.md b/examples/c/README.md index 10120d9..3a835cd 100644 --- a/examples/c/README.md +++ b/examples/c/README.md @@ -83,7 +83,7 @@ In order to build all examples, run the following commands: ## Usage -The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. +The example supports five modes: **scan**, **analyze**, **enhance**, **parse**, and **live**. ```bash ./scanbotsdk_example scan --file [--license ] ./scanbotsdk_example analyze --file [--save ] [--license ] diff --git a/examples/c/src/snippets/document/analyze_multi_page.c b/examples/c/src/snippets/document/analyze_multi_page.c index d157c65..f152425 100644 --- a/examples/c/src/snippets/document/analyze_multi_page.c +++ b/examples/c/src/snippets/document/analyze_multi_page.c @@ -5,16 +5,31 @@ #include void print_analyzer_result(scanbotsdk_document_quality_analyzer_result_t *result) { - char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN"}; + const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN" }; + const size_t quality_str_count = sizeof(quality_str) / sizeof(quality_str[0]); bool document_found; scanbotsdk_document_quality_assessment_t quality; + scanbotsdk_error_code_t ec; - scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); - scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); + ec = scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); + if (ec != SCANBOTSDK_OK) { + fprintf(stderr, "analyzer_result_get_document_found: %d: %s\n", ec, error_message(ec)); + return; + } + + ec = scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); + if (ec != SCANBOTSDK_OK) { + fprintf(stderr, "analyzer_result_get_quality: %d: %s\n", ec, error_message(ec)); + return; + } printf("Document detection: %s\n", document_found ? "Found" : "Not found"); - printf("Document quality: %s\n", quality_str[quality]); + if ((size_t)quality < quality_str_count) { + printf("Document quality: %s\n", quality_str[quality]); + } else { + printf("Document quality: UNKNOWN (%d)\n", (int)quality); + } } static scanbotsdk_error_code_t process_page(scanbotsdk_extracted_page_t *page, scanbotsdk_document_quality_analyzer_t *analyzer) diff --git a/examples/c/src/snippets/document/crop_and_analyze.c b/examples/c/src/snippets/document/crop_and_analyze.c index 7af1ba9..43f01f7 100644 --- a/examples/c/src/snippets/document/crop_and_analyze.c +++ b/examples/c/src/snippets/document/crop_and_analyze.c @@ -88,16 +88,32 @@ scanbotsdk_error_code_t save_cropped_image( } void print_result(scanbotsdk_document_quality_analyzer_result_t *result) { - const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN"}; + const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN" }; + const size_t quality_str_count = sizeof(quality_str) / sizeof(quality_str[0]); bool document_found = false; scanbotsdk_document_quality_assessment_t quality; + scanbotsdk_error_code_t ec = SCANBOTSDK_OK; + + ec = scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); + if (ec != SCANBOTSDK_OK) { + fprintf(stderr, "get_document_found: %d: %s\n", ec, error_message(ec)); + return; + } - scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); - scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); + ec = scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); + if (ec != SCANBOTSDK_OK) { + fprintf(stderr, "get_quality: %d: %s\n", ec, error_message(ec)); + return; + } printf("Document detection: %s\n", document_found ? "Found" : "Not found"); - printf("Document quality: %s (%d)\n", quality_str[quality], quality); + + if ((size_t)quality < quality_str_count) { + printf("Document quality: %s (%d)\n", quality_str[quality], quality); + } else { + printf("Document quality: UNKNOWN (%d)\n", quality); + } } static scanbotsdk_error_code_t analyze_document_quality( diff --git a/examples/java/README.md b/examples/java/README.md index 3be21ed..dca0ae6 100644 --- a/examples/java/README.md +++ b/examples/java/README.md @@ -5,11 +5,11 @@ Open `build.gradle` and replace the constant with the actual version number of the SDK you want to install. ```groovy -def SCANBOTSDK_VERSION = "" // e.g., 8.1.0 +def SCANBOTSDK_VERSION = "" // e.g., 9.0.0 ``` ## Usage -The example supports five commands: **scan**, **analyze**, **enhance**, and **parse**. +The example supports four commands: **scan**, **analyze**, **enhance**, and **parse**. ```bash ./gradlew run --args='scan --file [--license ]' ./gradlew run --args='scan --resource [--license ]' diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java index fc9539a..90816f1 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/document/AnalyzeMultiPageSnippet.java @@ -14,7 +14,7 @@ public class AnalyzeMultiPageSnippet { public static void run(String filePath, String resourcePath) throws Exception { DocumentQualityAnalyzerConfiguration analyze_config = new DocumentQualityAnalyzerConfiguration(); - analyze_config.getProcessByTileConfiguration().setTileSize(300);; + analyze_config.getProcessByTileConfiguration().setTileSize(300); analyze_config.setMinEstimatedNumberOfSymbolsForDocument(20); // Configure other parameters as needed. diff --git a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java index 5581063..f76732e 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java +++ b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java @@ -12,6 +12,10 @@ public static void print() { System.out.println(" ./gradlew run --args='analyze --resource --save [--license ]'"); System.out.println("or"); System.out.println(" ./gradlew run --args='analyze --file --save [--license ]'"); + System.out.println("or"); + System.out.println(" ./gradlew run --args='enhance --resource --save [--license ]'"); + System.out.println("or"); + System.out.println(" ./gradlew run --args='enhance --file --save [--license ]'"); System.out.println(); System.out.println(" ./gradlew run --args='parse --text \"\" [--license ]'"); System.out.println(); @@ -21,6 +25,9 @@ public static void print() { System.out.println("Available analyze commands:"); System.out.println(" analyze_multi_page | crop_analyze"); System.out.println(); + System.out.println("Available enhance commands:"); + System.out.println(" document"); + System.out.println(); System.out.println("Available parse commands:"); System.out.println(" mrz | barcode_doc"); System.out.println(); @@ -32,6 +39,7 @@ public static void print() { System.out.println(" ./gradlew run --args='scan barcode --file images/example.jpg --license '"); System.out.println(" ./gradlew run --args='analyze analyze_multi_page --resource files/doc.pdf --license '"); System.out.println(" ./gradlew run --args='analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license '"); + System.out.println(" ./gradlew run --args='enhance document --file images/doc.jpg --save out/enhanced.jpg --license '"); System.out.println(" ./gradlew run --args='parse mrz --text \"P'"); System.out.println(); } diff --git a/examples/nodejs/README.md b/examples/nodejs/README.md index 93f41f0..6d90c90 100644 --- a/examples/nodejs/README.md +++ b/examples/nodejs/README.md @@ -16,7 +16,7 @@ node -e "console.log(require('scanbotsdk') ? 'Scanbot SDK loaded' : 'Error')" ``` ## Usage -The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. +The example supports four modes: **scan**, **analyze**, **enhance**, and **parse**. ```bash npx ts-node src/index.ts scan --file [--license ] npx ts-node src/index.ts analyze --file [--save ] [--license ] diff --git a/examples/nodejs/src/snippets/utils/example-usage.ts b/examples/nodejs/src/snippets/utils/example-usage.ts index ff94d5b..a1b79e5 100644 --- a/examples/nodejs/src/snippets/utils/example-usage.ts +++ b/examples/nodejs/src/snippets/utils/example-usage.ts @@ -6,6 +6,7 @@ Usage: Categories & subcommands: scan analyze + enhance parse Flags: @@ -19,6 +20,7 @@ Examples: npx ts-node src/index.ts scan barcode --file images/example.jpg --license npx ts-node src/index.ts analyze analyze_multi_page --file files/doc.pdf --license npx ts-node src/index.ts analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license + npx ts-node src/index.ts enhance document --file images/doc.jpg --save out/enhanced.jpg --license npx ts-node src/index.ts parse mrz --text "P `); } diff --git a/examples/python/README.md b/examples/python/README.md index 1d06c76..9818024 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -132,7 +132,7 @@ Replace `` with the actual version number of the SDK you wa ``` ## Usage -The example supports five modes: **scan**, **analyze**, **enhance**, and **parse**. +The example supports five modes: **scan**, **analyze**, **enhance**, **parse**, and **live**. ```bash python main.py scan --file [--license ] python main.py analyze --file [--save ] [--license ] diff --git a/examples/python/utils.py b/examples/python/utils.py index 6fa4f3d..f33c743 100644 --- a/examples/python/utils.py +++ b/examples/python/utils.py @@ -55,14 +55,20 @@ def print_usage(): print("Usage:") print(" python main.py scan --file [--license ]") print(" python main.py analyze --file --save [--license ]") + print(" python main.py enhance --file [--license ]") print(" python main.py parse --text \"\" [--license ]") print(" python main.py live --device [--license ] --preview --use_tensorrt\n") + print("Available commands:") + print(" scan | analyze | enhance | parse | live\n") + print("Available scan commands:") print( " barcode | document | check | credit_card | document_data_extractor | medical_certificate | mrz | ocr | text_pattern | vin\n") print("Available analyze commands:") print(" analyze_multi_page | crop_analyze\n") + print("Available enhance commands:") + print(" document \n") print("Available parse commands:") print(" mrz | barcode_doc\n") print("Available live commands:") diff --git a/test-scripts/test-c.sh b/test-scripts/test-c.sh index 5af70cd..41b92ad 100755 --- a/test-scripts/test-c.sh +++ b/test-scripts/test-c.sh @@ -46,6 +46,7 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" + "enhance document --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -64,6 +65,7 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" + "Document enhance" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-java.sh b/test-scripts/test-java.sh index 9b403d9..6eea92d 100755 --- a/test-scripts/test-java.sh +++ b/test-scripts/test-java.sh @@ -33,6 +33,7 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" + "enhance document --file ../../test-scripts/test-images/Document.jpeg --save /tmp/enhanced.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --save /tmp/out.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --save /tmp/crop.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -51,6 +52,7 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" + "Document enhance" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-nodejs.sh b/test-scripts/test-nodejs.sh index 1b36db8..44f1394 100755 --- a/test-scripts/test-nodejs.sh +++ b/test-scripts/test-nodejs.sh @@ -41,6 +41,7 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" + "enhance document --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -59,6 +60,7 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" + "Document enhance" "Multi-page analyze" "Crop analyze" "MRZ parse" diff --git a/test-scripts/test-python.sh b/test-scripts/test-python.sh index cd9b8b5..f45800c 100755 --- a/test-scripts/test-python.sh +++ b/test-scripts/test-python.sh @@ -33,6 +33,7 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" + "enhance document --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests @@ -51,6 +52,7 @@ command_names=( "OCR scan" "Text pattern scan" "VIN scan" + "Document enhance" "Multi-page analyze" "Crop analyze" "MRZ parse" From 0aaa3a3afb45b7d45357cadeceb8e7ef73be4d24 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Fri, 19 Jun 2026 15:29:32 +0200 Subject: [PATCH 05/19] Update usage examples to remove '--save' option from 'enhance' command --- .../src/main/java/io/scanbot/sdk/utils/ExampleUsage.java | 6 +++--- examples/nodejs/src/snippets/utils/example-usage.ts | 2 +- test-scripts/test-java.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java index f76732e..c191403 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java +++ b/examples/java/src/main/java/io/scanbot/sdk/utils/ExampleUsage.java @@ -13,9 +13,9 @@ public static void print() { System.out.println("or"); System.out.println(" ./gradlew run --args='analyze --file --save [--license ]'"); System.out.println("or"); - System.out.println(" ./gradlew run --args='enhance --resource --save [--license ]'"); + System.out.println(" ./gradlew run --args='enhance --resource [--license ]'"); System.out.println("or"); - System.out.println(" ./gradlew run --args='enhance --file --save [--license ]'"); + System.out.println(" ./gradlew run --args='enhance --file [--license ]'"); System.out.println(); System.out.println(" ./gradlew run --args='parse --text \"\" [--license ]'"); System.out.println(); @@ -39,7 +39,7 @@ public static void print() { System.out.println(" ./gradlew run --args='scan barcode --file images/example.jpg --license '"); System.out.println(" ./gradlew run --args='analyze analyze_multi_page --resource files/doc.pdf --license '"); System.out.println(" ./gradlew run --args='analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license '"); - System.out.println(" ./gradlew run --args='enhance document --file images/doc.jpg --save out/enhanced.jpg --license '"); + System.out.println(" ./gradlew run --args='enhance document --file images/doc.jpg --license '"); System.out.println(" ./gradlew run --args='parse mrz --text \"P'"); System.out.println(); } diff --git a/examples/nodejs/src/snippets/utils/example-usage.ts b/examples/nodejs/src/snippets/utils/example-usage.ts index a1b79e5..760c1af 100644 --- a/examples/nodejs/src/snippets/utils/example-usage.ts +++ b/examples/nodejs/src/snippets/utils/example-usage.ts @@ -20,7 +20,7 @@ Examples: npx ts-node src/index.ts scan barcode --file images/example.jpg --license npx ts-node src/index.ts analyze analyze_multi_page --file files/doc.pdf --license npx ts-node src/index.ts analyze crop_analyze --file images/doc.jpg --save out/crop.jpg --license - npx ts-node src/index.ts enhance document --file images/doc.jpg --save out/enhanced.jpg --license + npx ts-node src/index.ts enhance document --file images/doc.jpg --license npx ts-node src/index.ts parse mrz --text "P `); } diff --git a/test-scripts/test-java.sh b/test-scripts/test-java.sh index 6eea92d..d4d7522 100755 --- a/test-scripts/test-java.sh +++ b/test-scripts/test-java.sh @@ -33,7 +33,7 @@ commands=( "scan ocr --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan text_pattern --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "scan vin --file ../../test-scripts/test-images/VIN.jpeg --license \"${SCANBOT_LICENSE}\"" - "enhance document --file ../../test-scripts/test-images/Document.jpeg --save /tmp/enhanced.jpeg --license \"${SCANBOT_LICENSE}\"" + "enhance document --file ../../test-scripts/test-images/Document.jpeg --license \"${SCANBOT_LICENSE}\"" "analyze analyze_multi_page --file ../../test-scripts/test-images/multi_page_document.pdf --save /tmp/out.pdf --license \"${SCANBOT_LICENSE}\"" "analyze crop_analyze --file ../../test-scripts/test-images/Document.jpeg --save /tmp/crop.jpeg --license \"${SCANBOT_LICENSE}\"" # TODO: Fix C SDK parse test,which currently returns success 0 only in tests From 117c48492a2ddcecd01ef06bce351640cb779217 Mon Sep 17 00:00:00 2001 From: Yurii <150049366+yurii-scanbot@users.noreply.github.com> Date: Fri, 19 Jun 2026 15:37:09 +0200 Subject: [PATCH 06/19] include the result in the try-with-resources heade Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../sdk/snippets/enhancer/DocumentEnhancerSnippet.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java index ae6b48a..4dbebb7 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java @@ -20,11 +20,10 @@ public static void run(ImageRef image) throws Exception { )); try ( - DocumentEnhancer enhancer = new DocumentEnhancer() + DocumentEnhancer enhancer = new DocumentEnhancer(); + DocumentStraighteningResult result = enhancer.straighten(image, params, List.of()) ) { - DocumentStraighteningResult result = enhancer.straighten(image, params, List.of()); // The straightened image can be accessed via result.getStraightenedImage() and saved or further processed as needed. - } } } From cf6a31e904b271eea94705c56cf12a7cc797dbc9 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Mon, 22 Jun 2026 11:18:59 +0200 Subject: [PATCH 07/19] removed deprecated property usage for DocumentQualityAnalyzerResult --- examples/python/snippets/document/crop_and_analyze.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/python/snippets/document/crop_and_analyze.py b/examples/python/snippets/document/crop_and_analyze.py index cb98731..154967f 100644 --- a/examples/python/snippets/document/crop_and_analyze.py +++ b/examples/python/snippets/document/crop_and_analyze.py @@ -35,5 +35,4 @@ def crop_and_analyze(image_path: str, save_path: Optional[str] = None): analyser = DocumentQualityAnalyzer(configuration=analyser_config) quality_result: DocumentQualityAnalyzerResult = analyser.run(image=cropped) - print(f"Document Found: {quality_result.document_found}") print(f"Quality: {quality_result.quality}") From 4c61051088a2fca86f86a11b6a86dcbfc5c8fdd6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 22 Jun 2026 12:31:25 +0000 Subject: [PATCH 08/19] Increase Node.js command timeout in CI tests --- test-scripts/test-nodejs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-scripts/test-nodejs.sh b/test-scripts/test-nodejs.sh index 44f1394..21dfdbf 100755 --- a/test-scripts/test-nodejs.sh +++ b/test-scripts/test-nodejs.sh @@ -71,7 +71,7 @@ for i in "${!commands[@]}"; do cmd="${commands[$i]}" name="${command_names[$i]}" - if timeout 30 npx ts-node src/index.ts $cmd; then + if timeout 60 npx ts-node src/index.ts $cmd; then echo "PASS: $name: PASSED" elif [[ $? -eq 124 ]]; then echo "FAIL: $name: TIMEOUT" From 79689903238971d6ec9eca966f275203db84ffcf Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Mon, 22 Jun 2026 16:01:55 +0200 Subject: [PATCH 09/19] Use node 22 --- Dockerfile | 2 +- test-scripts/test-nodejs.sh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0eb7268..a64b5b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ git \ ca-certificates \ # Add Node.js repository and install - && curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y nodejs \ && apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/test-scripts/test-nodejs.sh b/test-scripts/test-nodejs.sh index 21dfdbf..3c318d4 100755 --- a/test-scripts/test-nodejs.sh +++ b/test-scripts/test-nodejs.sh @@ -3,6 +3,9 @@ set -e echo "=== Node.js SDK Command Tests ===" +echo "Checking Node.js version..." +node -v + # Find the project root directory if [[ -d "/workspaces/scanbot-sdk-example-linux/examples/nodejs" ]]; then cd /workspaces/scanbot-sdk-example-linux/examples/nodejs From 5ebd3b7786a2ca04781bdd7b0d5b1090cb8ecef4 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Mon, 22 Jun 2026 16:14:00 +0200 Subject: [PATCH 10/19] Refactor document quality analysis by removing document found checks in print functions --- .vscode/settings.json | 6 ++++++ examples/c/src/snippets/document/analyze_multi_page.c | 8 -------- examples/c/src/snippets/document/crop_and_analyze.c | 9 --------- examples/python/snippets/document/analyze_multi_page.py | 3 +-- 4 files changed, 7 insertions(+), 19 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c00c037 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cmake.sourceDirectory": "/home/workspace/temp/scanbot-sdk-example-linux/examples/c", + "chat.tools.terminal.autoApprove": { + "npm install": true + } +} \ No newline at end of file diff --git a/examples/c/src/snippets/document/analyze_multi_page.c b/examples/c/src/snippets/document/analyze_multi_page.c index f152425..cb99f98 100644 --- a/examples/c/src/snippets/document/analyze_multi_page.c +++ b/examples/c/src/snippets/document/analyze_multi_page.c @@ -8,23 +8,15 @@ void print_analyzer_result(scanbotsdk_document_quality_analyzer_result_t *result const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN" }; const size_t quality_str_count = sizeof(quality_str) / sizeof(quality_str[0]); - bool document_found; scanbotsdk_document_quality_assessment_t quality; scanbotsdk_error_code_t ec; - ec = scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); - if (ec != SCANBOTSDK_OK) { - fprintf(stderr, "analyzer_result_get_document_found: %d: %s\n", ec, error_message(ec)); - return; - } - ec = scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "analyzer_result_get_quality: %d: %s\n", ec, error_message(ec)); return; } - printf("Document detection: %s\n", document_found ? "Found" : "Not found"); if ((size_t)quality < quality_str_count) { printf("Document quality: %s\n", quality_str[quality]); } else { diff --git a/examples/c/src/snippets/document/crop_and_analyze.c b/examples/c/src/snippets/document/crop_and_analyze.c index 43f01f7..84721b1 100644 --- a/examples/c/src/snippets/document/crop_and_analyze.c +++ b/examples/c/src/snippets/document/crop_and_analyze.c @@ -91,24 +91,15 @@ void print_result(scanbotsdk_document_quality_analyzer_result_t *result) { const char* quality_str[] = { "ACCEPTABLE", "UNACCEPTABLE", "UNCERTAIN" }; const size_t quality_str_count = sizeof(quality_str) / sizeof(quality_str[0]); - bool document_found = false; scanbotsdk_document_quality_assessment_t quality; scanbotsdk_error_code_t ec = SCANBOTSDK_OK; - ec = scanbotsdk_document_quality_analyzer_result_get_document_found(result, &document_found); - if (ec != SCANBOTSDK_OK) { - fprintf(stderr, "get_document_found: %d: %s\n", ec, error_message(ec)); - return; - } - ec = scanbotsdk_document_quality_analyzer_result_get_quality(result, &quality); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_quality: %d: %s\n", ec, error_message(ec)); return; } - printf("Document detection: %s\n", document_found ? "Found" : "Not found"); - if ((size_t)quality < quality_str_count) { printf("Document quality: %s (%d)\n", quality_str[quality], quality); } else { diff --git a/examples/python/snippets/document/analyze_multi_page.py b/examples/python/snippets/document/analyze_multi_page.py index 380dbfb..5c07992 100644 --- a/examples/python/snippets/document/analyze_multi_page.py +++ b/examples/python/snippets/document/analyze_multi_page.py @@ -24,6 +24,5 @@ def analyze_multi_page(file_path: str): analysis_result = analyser.run(image=extracted_image.image) print( f"Page {page_index + 1}, Image {image_index + 1} " - f"-> Found: {analysis_result.document_found}, " - f"Quality: {analysis_result.quality}" + f"-> Quality: {analysis_result.quality}" ) From ad9c549dcad02565876ec1a8a8c7acbdfc593c7b Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Mon, 22 Jun 2026 16:19:13 +0200 Subject: [PATCH 11/19] Update .gitignore to include .vscode/ and remove settings.json --- .gitignore | 3 ++- .vscode/settings.json | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 000f2a2..eea3de2 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ examples/nodejs/node_modules examples/java/libs/*.jar get-pip.py .env -.venv \ No newline at end of file +.venv +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index c00c037..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cmake.sourceDirectory": "/home/workspace/temp/scanbot-sdk-example-linux/examples/c", - "chat.tools.terminal.autoApprove": { - "npm install": true - } -} \ No newline at end of file From da094c92c2b03a7e7d75116ffad2407f376f3ab7 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Mon, 6 Jul 2026 13:56:31 +0200 Subject: [PATCH 12/19] Update Libraries.txt for SDK version 9.0.0 and update magic_enum copyright --- Libraries.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries.txt b/Libraries.txt index 0a39244..4df6739 100644 --- a/Libraries.txt +++ b/Libraries.txt @@ -1,4 +1,4 @@ -Open Source libraries used in the Scanbot Linux SDK version 8.1.0: +Open Source libraries used in the Scanbot Linux SDK version 9.0.0: +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -1784,12 +1784,12 @@ defined by AIM ITS/04-023 International Technical Standard - Extended Channel In magic-enum -Version v0.8.1 +Version v0.9.7 (https://github.com/Neargye/magic_enum) MIT License -Copyright (c) 2019 - 2022 Daniil Goncharov +Copyright (c) 2019 - 2024 Daniil Goncharov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 041faf1a120d04f9d8d2ac090077ccbeb976cd70 Mon Sep 17 00:00:00 2001 From: yurii-scanbot Date: Mon, 6 Jul 2026 16:46:41 +0200 Subject: [PATCH 13/19] Update version to 9.0.0 and documentation --- .github/workflows/run-tests-ci.yml | 2 +- examples/java/build.gradle | 2 +- examples/nodejs/package-lock.json | 8 ++++---- examples/nodejs/package.json | 2 +- test-scripts/README.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-tests-ci.yml b/.github/workflows/run-tests-ci.yml index 2282246..9ddd06a 100644 --- a/.github/workflows/run-tests-ci.yml +++ b/.github/workflows/run-tests-ci.yml @@ -41,7 +41,7 @@ on: # Global environment variables env: - SDK_VERSION: '0.900.6' + SDK_VERSION: '9.0.0' jobs: test-x86_64: diff --git a/examples/java/build.gradle b/examples/java/build.gradle index 689828c..fa7de16 100644 --- a/examples/java/build.gradle +++ b/examples/java/build.gradle @@ -4,7 +4,7 @@ plugins { } // TODO Add your SCANBOTSDK_VERSION here. -def SCANBOTSDK_VERSION = "0.900.6" +def SCANBOTSDK_VERSION = "9.0.0" def arch = System.getProperty("os.arch") def SCANBOTSDK_ARCHITECTURE = (arch.contains("arm") || arch.contains("aarch64")) ? "aarch64" : "x86_64" diff --git a/examples/nodejs/package-lock.json b/examples/nodejs/package-lock.json index 3637aa3..d48279c 100644 --- a/examples/nodejs/package-lock.json +++ b/examples/nodejs/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv9.0.0/nodejs-scanbotsdk-9.0.0.tgz" }, "devDependencies": { "@types/node": "^24.3.0", @@ -154,9 +154,9 @@ "license": "ISC" }, "node_modules/scanbotsdk": { - "version": "0.900.6", - "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz", - "integrity": "sha512-Y83QsPumkkoa8ledS1eS69FxlYF7Di0izzHAotPtcIsRah+4X1cE697IwunzGG4g1KVTe+lJq0iu5i9Kk6rRjg==", + "version": "9.0.0", + "resolved": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv9.0.0/nodejs-scanbotsdk-9.0.0.tgz", + "integrity": "sha512-aeyz2mSy7X9GY1EVoLFZnNIUTZhgRsjVuJVHsN+XLMatTa/Ifvxyf3gXUkw27SK2c32aesZnDSJfwz3NH3ruTQ==", "hasInstallScript": true, "license": "Commercial", "os": [ diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index 9ed446d..309e43d 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -15,6 +15,6 @@ "typescript": "^5.9.2" }, "dependencies": { - "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv0.900.6/nodejs-scanbotsdk-0.900.6.tgz" + "scanbotsdk": "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv9.0.0/nodejs-scanbotsdk-9.0.0.tgz" } } diff --git a/test-scripts/README.md b/test-scripts/README.md index 10ae792..dcb2569 100644 --- a/test-scripts/README.md +++ b/test-scripts/README.md @@ -29,7 +29,7 @@ test-scripts/ ```bash export SCANBOT_LICENSE="your-license-key-here" -export SDK_VERSION=0.900.6 +export SDK_VERSION=9.0.0 ``` ### 2. Build Test Container From 030c8682fe597b271de7fcd6ab836350bef8a8cf Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Wed, 29 Jul 2026 14:49:26 +0200 Subject: [PATCH 14/19] Initial Dockerfile --- Dockerfile | 149 ----------------------------------------------------- 1 file changed, 149 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a64b5b0..0000000 --- a/Dockerfile +++ /dev/null @@ -1,149 +0,0 @@ - -FROM debian:bookworm-slim AS base - -# Build Arguments -ARG ARCH -ARG SDK_VERSION -ARG JAVA_VERSION=17 -ARG SCANBOT_LICENSE - -# Environment Variables -ENV ARCH=${ARCH} \ - SDK_VERSION=${SDK_VERSION} \ - JAVA_VERSION=${JAVA_VERSION} \ - PYENV_ROOT="/opt/pyenv" \ - PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ - SDK_BASE_URL="https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv" \ - SCANBOT_LICENSE=${SCANBOT_LICENSE} \ - LANG=C.UTF-8 \ - LC_ALL=C.UTF-8 - -# Install system dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - # Build tools - build-essential \ - cmake \ - make \ - libssl-dev \ - zlib1g-dev \ - libbz2-dev \ - libreadline-dev \ - libsqlite3-dev \ - libffi-dev \ - liblzma-dev \ - # Languages - openjdk-${JAVA_VERSION}-jdk \ - # Utilities - curl \ - git \ - ca-certificates \ - # Add Node.js repository and install - && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ - && apt-get install -y nodejs \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - - # Install pyenv and Python 3.6.15 -RUN git clone --depth=1 https://github.com/pyenv/pyenv.git $PYENV_ROOT \ - && pyenv install 3.6.15 \ - && pyenv global 3.6.15 \ - && pyenv rehash - -# Set JAVA_HOME -RUN export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") && \ - echo "JAVA_HOME=$JAVA_HOME" >> /etc/environment - -ENV PATH="/opt/venv/bin:${PATH}" - -# Verify Java installation -RUN java -version && javac -version - -# Set up Python packages -RUN export PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ - && eval "$(/opt/pyenv/bin/pyenv init -)" \ - && python -m pip install --upgrade pip setuptools wheel \ - # The opencv-python version is specified to ensure compatibility with Python 3.6 and speed up docker builds - # Once the python is upgraded to 3.7+, this can be changed to just `opencv-python` - && python -m pip install opencv-python==4.5.5.64 numpy pillow - -# Install Python SDK -RUN if [ "${ARCH}" = "linux-aarch64" ]; then \ - PYTHON_ARCH="linux_aarch64"; \ - SDK_ARCH="linux-aarch64"; \ - else \ - PYTHON_ARCH="linux_x86_64"; \ - SDK_ARCH="linux-x86_64"; \ - fi && \ - python -m pip install "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-py3-none-${PYTHON_ARCH}.whl" && \ - echo "Python SDK installed successfully" - -# Set working directory and copy source code -WORKDIR /workspaces/scanbot-sdk-example-linux -COPY . . - -# Download and install all remaining SDKs in optimal locations -RUN echo "Installing Java and C SDKs for architecture: ${ARCH}" && \ - # Set the correct SDK architecture for downloads - if [ "${ARCH}" = "linux-aarch64" ]; then \ - SDK_ARCH="linux-aarch64"; \ - else \ - SDK_ARCH="linux-x86_64"; \ - fi && \ - # Download platform-dependent SDKs (Java and C only) - curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" && \ - curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" && \ - # Install Node.js SDK (platform-independent npm package) - cd examples/nodejs && \ - npm install "${SDK_BASE_URL}${SDK_VERSION}/nodejs-scanbotsdk-${SDK_VERSION}.tgz" && \ - cd /workspaces/scanbot-sdk-example-linux && \ - # Setup Java SDK - mkdir -p examples/java/build/libs && \ - cp "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" examples/java/build/libs/scanbotsdk.jar && \ - # Setup C SDK - mkdir -p examples/c/build/scanbotsdk && \ - tar -xzf "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" -C examples/c/build/scanbotsdk --strip-components=1 && \ - # Clean up downloads - rm -f *.tar.gz *.jar && \ - echo "All SDKs installed successfully" - -# Copy test scripts -COPY test-scripts/ /tests/ -RUN chmod +x /tests/*.sh - -# SDK Verification Stage -FROM base AS sdk-verification -RUN echo "=== Comprehensive SDK Verification ===" \ - && python -c "import scanbotsdk; print('Python SDK: Verified')" \ - && cd examples/nodejs && npm install && node -e "const sdk = require('scanbotsdk'); console.log(sdk ? 'OK' : 'FAIL');" \ - && cd /workspaces/scanbot-sdk-example-linux/examples/java && GRADLE_OPTS="-Dfile.encoding=UTF-8" ./gradlew check --no-daemon && echo "Java SDK: Verified" \ - && cd /workspaces/scanbot-sdk-example-linux/examples/c && mkdir -p build && cd build && cmake -DSCANBOTSDK_VERSION=${SDK_VERSION} .. && make && echo "C SDK: OK" - -# Python Tests Stage -FROM sdk-verification AS python-tests -RUN echo "=== Running Python Command Tests ===" \ - && /tests/test-python.sh - -# Java Tests Stage -FROM sdk-verification AS java-tests -RUN echo "=== Running Java Command Tests ===" \ - && /tests/test-java.sh - -# Node.js Tests Stage -FROM sdk-verification AS nodejs-tests -RUN echo "=== Running Node.js Command Tests ===" \ - && /tests/test-nodejs.sh - -# C Tests Stage -FROM sdk-verification AS c-tests -RUN echo "=== Running C Command Tests ===" \ - && /tests/test-c.sh - -# All Tests Stage -FROM sdk-verification AS all-tests -RUN echo "=== Running Complete Test Suite ===" \ - && /tests/run-all-tests.sh \ - && echo "Python import and commands verified" \ - && echo "Java compilation and commands verified" \ - && echo "Node.js compilation and commands verified" \ - && echo "C compilation and commands verified" - - \ No newline at end of file From 1d2e33dfe5c7f7a5551af6d3e4eac60d9621bfff Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Wed, 29 Jul 2026 14:50:35 +0200 Subject: [PATCH 15/19] Initial dockerfile --- test-scripts/windows/Dockerfile | 177 ++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 test-scripts/windows/Dockerfile diff --git a/test-scripts/windows/Dockerfile b/test-scripts/windows/Dockerfile new file mode 100644 index 0000000..64dcf43 --- /dev/null +++ b/test-scripts/windows/Dockerfile @@ -0,0 +1,177 @@ +FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS base + +SHELL ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"] + +# Build arguments +ARG ARCH=windows-x86_64 +ARG SDK_VERSION +ARG SCANBOT_LICENSE +ARG PYTHON_VERSION=3.10.11 +ARG PYTHON_SDK_WHL_URL +ARG VS_BUILDTOOLS_CHANNEL=17 +ARG C_SDK_ARCHIVE_URL + +# Environment +ENV ARCH=${ARCH} \ + SDK_VERSION=${SDK_VERSION} \ + C_SDK_ARCHIVE_URL=${C_SDK_ARCHIVE_URL} \ + SCANBOT_LICENSE=${SCANBOT_LICENSE} \ + PYTHON_VERSION=${PYTHON_VERSION} \ + PYTHON_SDK_WHL_URL=${PYTHON_SDK_WHL_URL} \ + VS_BUILDTOOLS_CHANNEL=${VS_BUILDTOOLS_CHANNEL} \ + SDK_BASE_URL="https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv" \ + PYTHONUTF8=1 + +# Install Visual Studio C++ Build Tools, CMake and Ninja for C tests +RUN $ErrorActionPreference = 'Stop'; \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + $vsInstaller = 'C:\vs_BuildTools.exe'; \ + $vsUri = ('https://aka.ms/vs/{0}/release/vs_BuildTools.exe' -f $env:VS_BUILDTOOLS_CHANNEL); \ + Invoke-WebRequest -Uri $vsUri -OutFile $vsInstaller; \ + $vsArgs = @( \ + '--quiet', \ + '--wait', \ + '--norestart', \ + '--installPath', 'C:\BuildTools', \ + '--add', 'Microsoft.VisualStudio.Workload.VCTools', \ + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', \ + '--add', 'Microsoft.VisualStudio.Component.Windows10SDK.19041', \ + '--includeRecommended' \ + ); \ + $proc = Start-Process -FilePath $vsInstaller -ArgumentList $vsArgs -Wait -PassThru; \ + $exitCode = $proc.ExitCode; \ + if (($exitCode -ne 0) -and ($exitCode -ne 3010)) { \ + Write-Host 'VS installer failed. Dumping VS temp logs:'; \ + Get-ChildItem -Path $env:TEMP -Filter 'dd_*' -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 20 | ForEach-Object { Write-Host $_.FullName; Get-Content $_.FullName -Tail 80 }; \ + throw ('VS Build Tools install failed with exit code ' + $exitCode) \ + }; \ + $pf86 = [Environment]::GetFolderPath('ProgramFilesX86'); \ + $vsWhere = Join-Path $pf86 'Microsoft Visual Studio\Installer\vswhere.exe'; \ + if (-not (Test-Path $vsWhere)) { throw 'vswhere.exe not found after VS installer run.' }; \ + $installPath = (& $vsWhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath).Trim(); \ + if ([string]::IsNullOrWhiteSpace($installPath)) { throw 'VC Build Tools instance not found after installation.' }; \ + Set-Content -Path C:\vs-install-path.txt -Value $installPath -NoNewline; \ + Remove-Item $vsInstaller -Force + +# Install Python +RUN $ErrorActionPreference = 'Stop'; \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + $pythonInstaller = 'C:\python-installer.exe'; \ + $pythonUrl = ('https://www.python.org/ftp/python/{0}/python-{0}-amd64.exe' -f $env:PYTHON_VERSION); \ + Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller; \ + $proc = Start-Process -FilePath $pythonInstaller -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 Include_pip=1 Include_test=0 Include_launcher=1' -Wait -PassThru; \ + if ($proc.ExitCode -ne 0) { throw ('Python installer failed with exit code ' + $proc.ExitCode) }; \ + Remove-Item $pythonInstaller -Force; \ + $env:Path = [System.Environment]::GetEnvironmentVariable('Path','Machine') + ';' + [System.Environment]::GetEnvironmentVariable('Path','User'); \ + $pythonExe = (Get-Command python -ErrorAction SilentlyContinue).Source; \ + if (-not $pythonExe) { $pythonExe = (Get-Command py -ErrorAction Stop).Source }; \ + Set-Content -Path C:\python-exe.txt -Value $pythonExe -NoNewline; \ + & $pythonExe --version; \ + & $pythonExe -m pip install --upgrade pip setuptools wheel; \ + & $pythonExe -m pip uninstall -y opencv-python opencv-python-headless numpy; \ + & $pythonExe -m pip install --no-cache-dir 'numpy==1.26.4' pillow cmake ninja; \ + & $pythonExe -m pip install --no-cache-dir --no-deps 'opencv-python-headless==4.5.5.64'; \ + & $pythonExe -c 'import numpy, cv2; print("numpy", numpy.__version__); print("cv2", cv2.__version__)'; \ + cmake --version; \ + ninja --version + +# Copy source +WORKDIR C:/workspaces/scanbot-sdk-example-linux +COPY . . + +# Install Scanbot Python SDK from either explicit URL or release URL computed from SDK_VERSION and ARCH +RUN $ErrorActionPreference = 'Stop'; \ + $pythonExe = (Get-Content C:\python-exe.txt -Raw).Trim(); \ + if ($env:ARCH -in @('windows-arm64', 'win-arm64')) { $pythonArch = 'win_arm64' } else { $pythonArch = 'win_amd64' }; \ + if ([string]::IsNullOrWhiteSpace($env:PYTHON_SDK_WHL_URL)) { \ + $wheelUrl = ('{0}{1}/scanbotsdk-{1}-py3-none-{2}.whl' -f $env:SDK_BASE_URL, $env:SDK_VERSION, $pythonArch); \ + } else { \ + $wheelUrl = $env:PYTHON_SDK_WHL_URL; \ + }; \ + Write-Host ('Installing Python SDK from: {0}' -f $wheelUrl); \ + # TODO: Uncomment the following line to install from URL instead of local wheel file + # & $pythonExe -m pip install $wheelUrl; \ + & $pythonExe -m pip install scanbotsdk-0.1000.0-py3-none-win_amd64.whl; \ + Write-Host 'Python SDK installed successfully' + +RUN $ErrorActionPreference = 'Stop'; \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + if ($env:ARCH -in @('windows-x86_64', 'windows-x64')) { $cSdkArch = 'windows-x64' } elseif ($env:ARCH -in @('windows-arm64', 'win-arm64')) { $cSdkArch = 'windows-arm64' } else { throw ('Unsupported ARCH for C SDK: ' + $env:ARCH) }; \ + if ([string]::IsNullOrWhiteSpace($env:C_SDK_ARCHIVE_URL)) { \ + $cSdkUrl = ('{0}{1}/scanbotsdk-{1}-{2}.tar.gz' -f $env:SDK_BASE_URL, $env:SDK_VERSION, $cSdkArch); \ + } else { \ + $cSdkUrl = $env:C_SDK_ARCHIVE_URL; \ + }; \ + $archiveName = ('scanbotsdk-{0}-{1}.tar.gz' -f $env:SDK_VERSION, $cSdkArch); \ + $localArchive = Join-Path 'C:\workspaces\scanbot-sdk-example-linux' $archiveName; \ + $archivePath = 'C:\scanbotsdk-c.tar.gz'; \ + $sdkRoot = 'C:\scanbotsdk-cache'; \ + if (Test-Path $sdkRoot) { Remove-Item $sdkRoot -Recurse -Force }; \ + New-Item -ItemType Directory -Path $sdkRoot | Out-Null; \ + if (Test-Path $localArchive) { \ + Write-Host ('Using local debug C SDK archive: {0}' -f $localArchive); \ + Copy-Item -Path $localArchive -Destination $archivePath -Force; \ + } else { \ + Write-Host ('Downloading C SDK from: {0}' -f $cSdkUrl); \ + Invoke-WebRequest -Uri $cSdkUrl -OutFile $archivePath; \ + }; \ + Push-Location $sdkRoot; \ + cmake -E tar -xf $archivePath; \ + Pop-Location; \ + Remove-Item $archivePath -Force; \ + if (-not (Test-Path (Join-Path $sdkRoot 'scanbotsdk\include\ScanbotSDK.h'))) { throw 'C SDK include files not found after extraction.' }; \ + if (-not (Test-Path (Join-Path $sdkRoot 'scanbotsdk\lib'))) { throw 'C SDK lib directory not found after extraction.' }; \ + Set-Content -Path C:\c-sdk-dir.txt -Value $sdkRoot -NoNewline; \ + Write-Host ('C SDK installed at: {0}' -f (Join-Path $sdkRoot 'scanbotsdk')) + +# Install CMake and Ninja for C tests +RUN $ErrorActionPreference = 'Stop'; \ + $installPath = (Get-Content C:\vs-install-path.txt -Raw).Trim(); \ + $vsDevCmd = Join-Path $installPath 'Common7\Tools\VsDevCmd.bat'; \ + $cSdkDir = (Get-Content C:\c-sdk-dir.txt -Raw).Trim(); \ + if ([string]::IsNullOrWhiteSpace($cSdkDir)) { throw 'C SDK dir is empty' }; \ + cmd /c ('"' + $vsDevCmd + '" -arch=x64 && cd /d C:\workspaces\scanbot-sdk-example-linux && cmake -S examples\c -B examples\c\build -G Ninja -DSCANBOTSDK_DIR=' + $cSdkDir + ' -DSCANBOTSDK_VERSION=' + $env:SDK_VERSION + ' && cmake --build examples\c\build --config Release -- -k 50'); \ + if ($LASTEXITCODE -ne 0) { throw ('C build failed with exit code ' + $LASTEXITCODE) }; + +# SDK verification stage +FROM base AS sdk-verification +RUN $ErrorActionPreference = 'Stop'; \ + Write-Host '=== Comprehensive SDK Verification ==='; \ + $installPath = (Get-Content C:\vs-install-path.txt -Raw).Trim(); \ + if ([string]::IsNullOrWhiteSpace($installPath)) { throw 'VS install path not found.' }; \ + $vsDevCmd = Join-Path $installPath 'Common7\Tools\VsDevCmd.bat'; \ + $vcvars64 = Join-Path $installPath 'VC\Auxiliary\Build\vcvars64.bat'; \ + if (Test-Path $vsDevCmd) { \ + cmd /c ('"' + $vsDevCmd + '" -arch=x64 && where cl && cl /? >nul'); \ + } elseif (Test-Path $vcvars64) { \ + cmd /c ('"' + $vcvars64 + '" && where cl && cl /? >nul'); \ + } else { \ + throw ('Neither VsDevCmd.bat nor vcvars64.bat found under: ' + $installPath) \ + }; \ + if ($LASTEXITCODE -ne 0) { throw ('MSVC toolchain verification failed with exit code ' + $LASTEXITCODE) }; \ + cmake --version; \ + if ($LASTEXITCODE -ne 0) { throw 'cmake not available' }; \ + ninja --version; \ + if ($LASTEXITCODE -ne 0) { throw 'ninja not available' }; \ + $pythonExe = (Get-Content C:\python-exe.txt -Raw).Trim(); \ + $pyCode = 'import scanbotsdk; print(''Python SDK: Verified'')'; \ + & $pythonExe -c $pyCode; \ + $pyExit = $LASTEXITCODE; \ + if ($pyExit -ne 0) { throw ('Python SDK verification failed with exit code ' + $pyExit) }; + +# Python tests stage (PowerShell-only, no bash) +FROM sdk-verification AS python-tests +RUN $ErrorActionPreference = 'Stop'; \ + Write-Host '=== Running Python Command Tests ==='; \ + powershell -NoProfile -ExecutionPolicy Bypass -File C:/workspaces/scanbot-sdk-example-linux/test-scripts/windows/test-python.ps1 + +# C tests stage (PowerShell-only, no bash) +FROM sdk-verification AS c-tests +RUN $ErrorActionPreference = 'Stop'; \ + Write-Host '=== Running C Command Tests ==='; \ + powershell -NoProfile -ExecutionPolicy Bypass -File C:/workspaces/scanbot-sdk-example-linux/test-scripts/windows/test-c.ps1 + +# All tests stage (kept for target compatibility with existing workflow patterns) +FROM sdk-verification AS all-tests +RUN $ErrorActionPreference = 'Stop'; \ + powershell -NoProfile -ExecutionPolicy Bypass -File C:/workspaces/scanbot-sdk-example-linux/test-scripts/windows/run-all-tests.ps1 From 0406ad5448f55cf8af9e1081c5e9d4172918146d Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Wed, 29 Jul 2026 14:51:00 +0200 Subject: [PATCH 16/19] Initial ps1 scripts --- test-scripts/windows/run-all-tests.ps1 | 69 +++++++++++++++++ test-scripts/windows/test-c.ps1 | 102 +++++++++++++++++++++++++ test-scripts/windows/test-python.ps1 | 85 +++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100755 test-scripts/windows/run-all-tests.ps1 create mode 100755 test-scripts/windows/test-c.ps1 create mode 100755 test-scripts/windows/test-python.ps1 diff --git a/test-scripts/windows/run-all-tests.ps1 b/test-scripts/windows/run-all-tests.ps1 new file mode 100755 index 0000000..d7a587b --- /dev/null +++ b/test-scripts/windows/run-all-tests.ps1 @@ -0,0 +1,69 @@ +$ErrorActionPreference = 'Stop' + +Write-Host '========================================' +Write-Host ' Scanbot SDK - Full Test Suite' +Write-Host '========================================' + +$failedTests = @() +$totalTests = 0 +$passedTests = 0 + +function Invoke-TestSuite { + param( + [Parameter(Mandatory = $true)][string]$TestName, + [Parameter(Mandatory = $true)][string]$ScriptPath + ) + + Write-Host '' + Write-Host ("Running {0} tests..." -f $TestName) + $script:totalTests += 1 + + if (-not (Test-Path -Path $ScriptPath)) { + Write-Host ("FAIL: {0} tests FAILED (script not found: {1})" -f $TestName, $ScriptPath) + $script:failedTests += $TestName + return + } + + try { + & powershell -NoProfile -ExecutionPolicy Bypass -File $ScriptPath + if ($LASTEXITCODE -eq 0) { + Write-Host ("PASS: {0} tests PASSED" -f $TestName) + $script:passedTests += 1 + } else { + Write-Host ("FAIL: {0} tests FAILED" -f $TestName) + $script:failedTests += $TestName + } + } catch { + Write-Host ("FAIL: {0} tests FAILED" -f $TestName) + Write-Host $_.Exception.Message + $script:failedTests += $TestName + } +} + +$pythonScript = Join-Path $PSScriptRoot 'test-python.ps1' +$cScript = Join-Path $PSScriptRoot 'test-c.ps1' + +Invoke-TestSuite -TestName 'Python' -ScriptPath $pythonScript +Invoke-TestSuite -TestName 'C' -ScriptPath $cScript + +Write-Host '' +Write-Host '========================================' +Write-Host ' Test Summary' +Write-Host '========================================' +Write-Host ("Total test suites: {0}" -f $totalTests) +Write-Host ("Passed: {0}" -f $passedTests) +Write-Host ("Failed: {0}" -f ($totalTests - $passedTests)) + +if ($passedTests -eq $totalTests) { + Write-Host '' + Write-Host 'ALL TESTS PASSED!' + Write-Host 'Scanbot SDK is working correctly across all platforms.' + exit 0 +} + +Write-Host '' +Write-Host 'Some tests failed:' +Write-Host ($failedTests -join ', ') +Write-Host '' +Write-Host 'Please check the logs above for details.' +exit 1 diff --git a/test-scripts/windows/test-c.ps1 b/test-scripts/windows/test-c.ps1 new file mode 100755 index 0000000..0d404dc --- /dev/null +++ b/test-scripts/windows/test-c.ps1 @@ -0,0 +1,102 @@ +$ErrorActionPreference = 'Stop' + +Write-Host '=== C SDK Command Tests ===' + +$repoCandidates = @( + 'C:/workspaces/scanbot-sdk-example-linux', + (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path +) + +$repoRoot = $null +foreach ($candidate in $repoCandidates) { + if (Test-Path (Join-Path $candidate 'examples/c/CMakeLists.txt')) { + $repoRoot = $candidate + break + } +} + +if (-not $repoRoot) { + Write-Host 'ERROR: Cannot find C examples directory' + exit 1 +} + +if ([string]::IsNullOrWhiteSpace($env:SCANBOT_LICENSE)) { + Write-Host 'ERROR: No license available' + Write-Host 'SCANBOT_LICENSE environment variable is not set' + Write-Host 'Tests cannot run without a valid license' + exit 1 +} + +Set-Location (Join-Path $repoRoot 'examples/c') + +$exePath = Join-Path (Get-Location) 'build/scanbotsdk_example.exe' +if (-not (Test-Path $exePath)) { + Write-Host 'FAIL: C executable: NOT FOUND' + Write-Host 'Looking for executable in current directory:' + Get-ChildItem -Force | Format-Table -AutoSize + Write-Host 'Looking for executable in build directory:' + if (Test-Path './build') { + Get-ChildItem './build' -Force | Format-Table -AutoSize + } else { + Write-Host 'Build directory not found' + } + exit 1 +} + +Write-Host 'PASS: C executable: EXISTS' +Get-Item $exePath | Format-List FullName, Length, LastWriteTime + +function Invoke-WithTimeout { + param( + [Parameter(Mandatory = $true)][string]$FilePath, + [Parameter(Mandatory = $true)][string[]]$ArgumentList, + [int]$TimeoutSec = 30 + ) + + $proc = Start-Process -FilePath $FilePath -ArgumentList $ArgumentList -NoNewWindow -PassThru + $null = Wait-Process -Id $proc.Id -Timeout $TimeoutSec -ErrorAction SilentlyContinue + + if (-not $proc.HasExited) { + Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue + return 124 + } + + $proc.Refresh() + return [int]$proc.ExitCode +} + +Write-Host 'Testing SCAN commands...' + +$commands = @( + @{ Name = 'Barcode scan'; Args = @('scan', 'barcode', '--file', '../../test-scripts/test-images/qrcode.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Document scan'; Args = @('scan', 'document', '--file', '../../test-scripts/test-images/Document.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Check scan'; Args = @('scan', 'check', '--file', '../../test-scripts/test-images/check.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Credit card scan'; Args = @('scan', 'credit_card', '--file', '../../test-scripts/test-images/credit_card.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Document extractor scan'; Args = @('scan', 'document_data_extractor', '--file', '../../test-scripts/test-images/EHIC.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Medical certificate scan'; Args = @('scan', 'medical_certificate', '--file', '../../test-scripts/test-images/medical_certificate.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'MRZ scan'; Args = @('scan', 'mrz', '--file', '../../test-scripts/test-images/MRZ_passport.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'OCR scan'; Args = @('scan', 'ocr', '--file', '../../test-scripts/test-images/Document.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Text pattern scan'; Args = @('scan', 'text_pattern', '--file', '../../test-scripts/test-images/Document.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'VIN scan'; Args = @('scan', 'vin', '--file', '../../test-scripts/test-images/VIN.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Document enhance'; Args = @('enhance', 'document', '--file', '../../test-scripts/test-images/Document.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Multi-page analyze'; Args = @('analyze', 'analyze_multi_page', '--file', '../../test-scripts/test-images/multi_page_document.pdf', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'Crop analyze'; Args = @('analyze', 'crop_analyze', '--file', '../../test-scripts/test-images/Document.jpeg', '--license', $env:SCANBOT_LICENSE) }, + @{ Name = 'MRZ parse'; Args = @('parse', 'mrz', '--text', 'P Date: Wed, 29 Jul 2026 14:51:43 +0200 Subject: [PATCH 17/19] Move linux scripts --- .github/workflows/run-tests-ci.yml | 3 +- test-scripts/linux/Dockerfile | 149 ++++++++++++++++++++++ test-scripts/{ => linux}/run-all-tests.sh | 0 test-scripts/{ => linux}/test-c.sh | 0 test-scripts/{ => linux}/test-java.sh | 0 test-scripts/{ => linux}/test-nodejs.sh | 0 test-scripts/{ => linux}/test-python.sh | 0 7 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 test-scripts/linux/Dockerfile rename test-scripts/{ => linux}/run-all-tests.sh (100%) rename test-scripts/{ => linux}/test-c.sh (100%) rename test-scripts/{ => linux}/test-java.sh (100%) rename test-scripts/{ => linux}/test-nodejs.sh (100%) rename test-scripts/{ => linux}/test-python.sh (100%) diff --git a/.github/workflows/run-tests-ci.yml b/.github/workflows/run-tests-ci.yml index 9ddd06a..fee73e9 100644 --- a/.github/workflows/run-tests-ci.yml +++ b/.github/workflows/run-tests-ci.yml @@ -58,10 +58,11 @@ jobs: - name: Build Docker image (x86_64) run: | docker build \ + -f test-scripts/linux/Dockerfile \ --build-arg SDK_VERSION=${{ inputs.sdk_version || env.SDK_VERSION }} \ --build-arg ARCH=linux-x86_64 \ --build-arg SCANBOT_LICENSE="${{ secrets.SCANBOT_LICENSE_KEY }}" \ - --target all-tests \ + --target sdk-verification \ -t scanbot-linux-x86_64:latest . # Run the test suite with secure stdin approach diff --git a/test-scripts/linux/Dockerfile b/test-scripts/linux/Dockerfile new file mode 100644 index 0000000..7ea0c50 --- /dev/null +++ b/test-scripts/linux/Dockerfile @@ -0,0 +1,149 @@ + +FROM debian:bookworm-slim AS base + +# Build Arguments +ARG ARCH +ARG SDK_VERSION +ARG JAVA_VERSION=17 +ARG SCANBOT_LICENSE + +# Environment Variables +ENV ARCH=${ARCH} \ + SDK_VERSION=${SDK_VERSION} \ + JAVA_VERSION=${JAVA_VERSION} \ + PYENV_ROOT="/opt/pyenv" \ + PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ + SDK_BASE_URL="https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv" \ + SCANBOT_LICENSE=${SCANBOT_LICENSE} \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + # Build tools + build-essential \ + cmake \ + make \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + libffi-dev \ + liblzma-dev \ + # Languages + openjdk-${JAVA_VERSION}-jdk \ + # Utilities + curl \ + git \ + ca-certificates \ + # Add Node.js repository and install + && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && apt-get install -y nodejs \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + + # Install pyenv and Python 3.6.15 +RUN git clone --depth=1 https://github.com/pyenv/pyenv.git $PYENV_ROOT \ + && pyenv install 3.6.15 \ + && pyenv global 3.6.15 \ + && pyenv rehash + +# Set JAVA_HOME +RUN export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") && \ + echo "JAVA_HOME=$JAVA_HOME" >> /etc/environment + +ENV PATH="/opt/venv/bin:${PATH}" + +# Verify Java installation +RUN java -version && javac -version + +# Set up Python packages +RUN export PATH="/opt/pyenv/bin:/opt/pyenv/shims:$PATH" \ + && eval "$(/opt/pyenv/bin/pyenv init -)" \ + && python -m pip install --upgrade pip setuptools wheel \ + # The opencv-python version is specified to ensure compatibility with Python 3.6 and speed up docker builds + # Once the python is upgraded to 3.7+, this can be changed to just `opencv-python` + && python -m pip install opencv-python==4.5.5.64 numpy pillow + +# Install Python SDK +RUN if [ "${ARCH}" = "linux-aarch64" ]; then \ + PYTHON_ARCH="linux_aarch64"; \ + SDK_ARCH="linux-aarch64"; \ + else \ + PYTHON_ARCH="linux_x86_64"; \ + SDK_ARCH="linux-x86_64"; \ + fi && \ + python -m pip install "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-py3-none-${PYTHON_ARCH}.whl" && \ + echo "Python SDK installed successfully" + +# Set working directory and copy source code +WORKDIR /workspaces/scanbot-sdk-example-linux +COPY . . + +# Download and install all remaining SDKs in optimal locations +RUN echo "Installing Java and C SDKs for architecture: ${ARCH}" && \ + # Set the correct SDK architecture for downloads + if [ "${ARCH}" = "linux-aarch64" ]; then \ + SDK_ARCH="linux-aarch64"; \ + else \ + SDK_ARCH="linux-x86_64"; \ + fi && \ + # Download platform-dependent SDKs (Java and C only) + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" && \ + curl -L -O "${SDK_BASE_URL}${SDK_VERSION}/scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" && \ + # Install Node.js SDK (platform-independent npm package) + cd examples/nodejs && \ + npm install "${SDK_BASE_URL}${SDK_VERSION}/nodejs-scanbotsdk-${SDK_VERSION}.tgz" && \ + cd /workspaces/scanbot-sdk-example-linux && \ + # Setup Java SDK + mkdir -p examples/java/build/libs && \ + cp "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.jar" examples/java/build/libs/scanbotsdk.jar && \ + # Setup C SDK + mkdir -p examples/c/build/scanbotsdk && \ + tar -xzf "scanbotsdk-${SDK_VERSION}-${SDK_ARCH}.tar.gz" -C examples/c/build/scanbotsdk --strip-components=1 && \ + # Clean up downloads + rm -f *.tar.gz *.jar && \ + echo "All SDKs installed successfully" + +# Copy test scripts +COPY test-scripts/linux/ /tests/ +RUN chmod +x /tests/*.sh + +# SDK Verification Stage +FROM base AS sdk-verification +RUN echo "=== Comprehensive SDK Verification ===" \ + && python -c "import scanbotsdk; print('Python SDK: Verified')" \ + && cd examples/nodejs && npm install && node -e "const sdk = require('scanbotsdk'); console.log(sdk ? 'OK' : 'FAIL');" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/java && GRADLE_OPTS="-Dfile.encoding=UTF-8" ./gradlew check --no-daemon && echo "Java SDK: Verified" \ + && cd /workspaces/scanbot-sdk-example-linux/examples/c && mkdir -p build && cd build && cmake -DSCANBOTSDK_VERSION=${SDK_VERSION} .. && make && echo "C SDK: OK" + +# Python Tests Stage +FROM sdk-verification AS python-tests +RUN echo "=== Running Python Command Tests ===" \ + && /tests/test-python.sh + +# Java Tests Stage +FROM sdk-verification AS java-tests +RUN echo "=== Running Java Command Tests ===" \ + && /tests/test-java.sh + +# Node.js Tests Stage +FROM sdk-verification AS nodejs-tests +RUN echo "=== Running Node.js Command Tests ===" \ + && /tests/test-nodejs.sh + +# C Tests Stage +FROM sdk-verification AS c-tests +RUN echo "=== Running C Command Tests ===" \ + && /tests/test-c.sh + +# All Tests Stage +FROM sdk-verification AS all-tests +RUN echo "=== Running Complete Test Suite ===" \ + && /tests/run-all-tests.sh \ + && echo "Python import and commands verified" \ + && echo "Java compilation and commands verified" \ + && echo "Node.js compilation and commands verified" \ + && echo "C compilation and commands verified" + + \ No newline at end of file diff --git a/test-scripts/run-all-tests.sh b/test-scripts/linux/run-all-tests.sh similarity index 100% rename from test-scripts/run-all-tests.sh rename to test-scripts/linux/run-all-tests.sh diff --git a/test-scripts/test-c.sh b/test-scripts/linux/test-c.sh similarity index 100% rename from test-scripts/test-c.sh rename to test-scripts/linux/test-c.sh diff --git a/test-scripts/test-java.sh b/test-scripts/linux/test-java.sh similarity index 100% rename from test-scripts/test-java.sh rename to test-scripts/linux/test-java.sh diff --git a/test-scripts/test-nodejs.sh b/test-scripts/linux/test-nodejs.sh similarity index 100% rename from test-scripts/test-nodejs.sh rename to test-scripts/linux/test-nodejs.sh diff --git a/test-scripts/test-python.sh b/test-scripts/linux/test-python.sh similarity index 100% rename from test-scripts/test-python.sh rename to test-scripts/linux/test-python.sh From 0998562e3281b4149fd42228ca3b23c18d82c507 Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Wed, 29 Jul 2026 14:52:00 +0200 Subject: [PATCH 18/19] Update c tests --- examples/c/src/snippets/barcode/detect_barcode.c | 8 ++++---- .../src/snippets/barcode/parse_barcode_document.c | 3 ++- .../datacapture/medical_certificate_scanner.c | 7 ++++--- examples/c/src/snippets/datacapture/mrz_parser.c | 3 ++- examples/c/src/snippets/datacapture/ocr.c | 5 +++-- .../snippets/datacapture/text_pattern_scanner.c | 7 ++++--- examples/c/src/snippets/datacapture/vin_scanner.c | 5 +++-- .../c/src/snippets/enhancer/document_enhancer.c | 14 +++++++------- examples/c/src/snippets/live/live_barcode.c | 8 +++++--- examples/c/src/utils/utils.c | 10 ++++++---- 10 files changed, 40 insertions(+), 30 deletions(-) diff --git a/examples/c/src/snippets/barcode/detect_barcode.c b/examples/c/src/snippets/barcode/detect_barcode.c index fd33cf6..e4f4d4c 100644 --- a/examples/c/src/snippets/barcode/detect_barcode.c +++ b/examples/c/src/snippets/barcode/detect_barcode.c @@ -21,11 +21,11 @@ scanbotsdk_error_code_t print_barcodes_result(scanbotsdk_barcode_scanner_result_ if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_barcodes: %d: %s\n", ec, error_message(ec)); goto cleanup; } for (size_t i = 0; i < count; ++i) { - const char *text = NULL; + scanbotsdk_u8string_ref_t text_ref = {0}; scanbotsdk_generic_document_t *doc = NULL; - - scanbotsdk_barcode_item_get_text(barcodes[i], &text); - fprintf(stdout, " %zu) %s\n", i + 1, text); + scanbotsdk_barcode_item_get_text(barcodes[i], &text_ref); + const char *text = scanbotsdk_u8string_ref_assume_cstring(text_ref); + fprintf(stdout, " %zu) %s\n", i + 1, text ? text : ""); scanbotsdk_barcode_item_get_extracted_document(barcodes[i], &doc); if(doc != NULL) { diff --git a/examples/c/src/snippets/barcode/parse_barcode_document.c b/examples/c/src/snippets/barcode/parse_barcode_document.c index bebab44..537f02c 100644 --- a/examples/c/src/snippets/barcode/parse_barcode_document.c +++ b/examples/c/src/snippets/barcode/parse_barcode_document.c @@ -30,7 +30,8 @@ scanbotsdk_error_code_t parse_barcode_document(const char* raw_string) { ec = scanbotsdk_barcode_document_parser_create(formats, formats_count, &parser); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "create_parser: %d: %s\n", ec, error_message(ec)); goto cleanup; } - ec = scanbotsdk_barcode_document_parser_parse(parser, raw_string, &result); + scanbotsdk_u8string_ref_t raw_ref = scanbotsdk_u8string_ref_from_cstring(raw_string); + ec = scanbotsdk_barcode_document_parser_parse(parser, raw_ref, &result); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "parser_parse: %d: %s\n", ec, error_message(ec)); goto cleanup; } ec = scanbotsdk_barcode_document_parser_result_get_parsed_document(result, &parsed_doc); diff --git a/examples/c/src/snippets/datacapture/medical_certificate_scanner.c b/examples/c/src/snippets/datacapture/medical_certificate_scanner.c index 68b1afa..c156cb7 100644 --- a/examples/c/src/snippets/datacapture/medical_certificate_scanner.c +++ b/examples/c/src/snippets/datacapture/medical_certificate_scanner.c @@ -25,12 +25,13 @@ scanbotsdk_error_code_t print_medical_certificate_result(scanbotsdk_medical_cert for (size_t i = 0; i < count; ++i) { scanbotsdk_medical_certificate_patient_info_field_type_t type; - const char* value = NULL; + scanbotsdk_u8string_ref_t value_ref = {0}; scanbotsdk_medical_certificate_patient_info_field_get_type(fields[i], &type); - scanbotsdk_medical_certificate_patient_info_field_get_value(fields[i], &value); + scanbotsdk_medical_certificate_patient_info_field_get_value(fields[i], &value_ref); - fprintf(stderr, "Type: %d Value: %s\n", type, value); + const char *value = scanbotsdk_u8string_ref_assume_cstring(value_ref); + fprintf(stderr, "Type: %d Value: %s\n", type, value ? value : ""); } cleanup: diff --git a/examples/c/src/snippets/datacapture/mrz_parser.c b/examples/c/src/snippets/datacapture/mrz_parser.c index f319645..53453ba 100644 --- a/examples/c/src/snippets/datacapture/mrz_parser.c +++ b/examples/c/src/snippets/datacapture/mrz_parser.c @@ -19,7 +19,8 @@ scanbotsdk_error_code_t parse_mrz(const char* text) { ec = scanbotsdk_mrz_parser_create(config, &parser); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "create_parser: %d: %s\n", ec, error_message(ec)); goto cleanup; } - ec = scanbotsdk_mrz_parser_parse(parser, text, &result); + scanbotsdk_u8string_ref_t text_ref = scanbotsdk_u8string_ref_from_cstring(text); + ec = scanbotsdk_mrz_parser_parse(parser, text_ref, &result); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "parse: %d: %s\n", ec, error_message(ec)); goto cleanup; } ec = scanbotsdk_mrz_scanner_result_get_document(result, &mrz); diff --git a/examples/c/src/snippets/datacapture/ocr.c b/examples/c/src/snippets/datacapture/ocr.c index 34f9056..6abafb5 100644 --- a/examples/c/src/snippets/datacapture/ocr.c +++ b/examples/c/src/snippets/datacapture/ocr.c @@ -5,8 +5,9 @@ #include static void print_ocr_element_text(scanbotsdk_ocr_element_t *el, const char *label, int indent) { - const char *text = NULL; - scanbotsdk_ocr_element_get_text(el, &text); + scanbotsdk_u8string_ref_t text_ref = {0}; + scanbotsdk_ocr_element_get_text(el, &text_ref); + const char *text = scanbotsdk_u8string_ref_assume_cstring(text_ref); for (int i = 0; i < indent; i++) printf(" "); printf("%s: \"%s\"\n", label, text ? text : ""); diff --git a/examples/c/src/snippets/datacapture/text_pattern_scanner.c b/examples/c/src/snippets/datacapture/text_pattern_scanner.c index acff3cf..f843747 100644 --- a/examples/c/src/snippets/datacapture/text_pattern_scanner.c +++ b/examples/c/src/snippets/datacapture/text_pattern_scanner.c @@ -6,11 +6,12 @@ scanbotsdk_error_code_t print_text_pattern_result(scanbotsdk_text_pattern_scanner_result_t *result) { scanbotsdk_error_code_t ec; - const char* raw_text; + scanbotsdk_u8string_ref_t raw_text_ref = {0}; + const char *raw_text = NULL; - ec = scanbotsdk_text_pattern_scanner_result_get_raw_text(result, &raw_text); + ec = scanbotsdk_text_pattern_scanner_result_get_raw_text(result, &raw_text_ref); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "get_raw_text: %d\n", ec); return ec; } - + raw_text = scanbotsdk_u8string_ref_assume_cstring(raw_text_ref); printf("Raw Text: %s\n", raw_text); return ec; } diff --git a/examples/c/src/snippets/datacapture/vin_scanner.c b/examples/c/src/snippets/datacapture/vin_scanner.c index 0b974cd..28509b3 100644 --- a/examples/c/src/snippets/datacapture/vin_scanner.c +++ b/examples/c/src/snippets/datacapture/vin_scanner.c @@ -7,10 +7,11 @@ scanbotsdk_error_code_t print_vin_result(scanbotsdk_vin_scanner_result_t *result) { scanbotsdk_error_code_t ec = SCANBOTSDK_OK; scanbotsdk_text_pattern_scanner_result_t *text_result; - const char* raw_text; + scanbotsdk_u8string_ref_t raw_text_ref = {0}; scanbotsdk_vin_scanner_result_get_text_result(result, &text_result); - scanbotsdk_text_pattern_scanner_result_get_raw_text(text_result, &raw_text); + scanbotsdk_text_pattern_scanner_result_get_raw_text(text_result, &raw_text_ref); + const char* raw_text = scanbotsdk_u8string_ref_assume_cstring(raw_text_ref); printf("Text: %s\n", raw_text); return ec; diff --git a/examples/c/src/snippets/enhancer/document_enhancer.c b/examples/c/src/snippets/enhancer/document_enhancer.c index dc637e1..4d266fe 100644 --- a/examples/c/src/snippets/enhancer/document_enhancer.c +++ b/examples/c/src/snippets/enhancer/document_enhancer.c @@ -9,7 +9,7 @@ scanbotsdk_error_code_t enhance_document(scanbotsdk_image_t *image) { scanbotsdk_document_straightening_result_t *result = NULL; scanbotsdk_document_straightening_parameters_t *straightening_params = NULL; - scanbotsdk_document_enhancer_t *enhancer = NULL; + scanbotsdk_document_straightener_t *straightener = NULL; scanbotsdk_image_t *straightened_image = NULL; scanbotsdk_aspect_ratio_t *aspect_ratios[4] = {0}; @@ -34,18 +34,18 @@ scanbotsdk_error_code_t enhance_document(scanbotsdk_image_t *image) { ); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straightening_parameters_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } - ec = scanbotsdk_document_enhancer_create(&enhancer); - if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_enhancer_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } + ec = scanbotsdk_document_straightener_create(&straightener); + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straightener_create: %d: %s\n", ec, error_message(ec)); goto cleanup; } - ec = scanbotsdk_document_enhancer_straighten( - enhancer, + ec = scanbotsdk_document_straightener_run( + straightener, image, straightening_params, NULL, 0, &result ); - if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_enhancer_straighten: %d: %s\n", ec, error_message(ec)); goto cleanup; } + if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straighten: %d: %s\n", ec, error_message(ec)); goto cleanup; } ec = scanbotsdk_document_straightening_result_get_straightened_image(result, &straightened_image); if (ec != SCANBOTSDK_OK) { fprintf(stderr, "document_straightening_result_get_straightened_image: %d: %s\n", ec, error_message(ec)); goto cleanup; } @@ -57,7 +57,7 @@ scanbotsdk_error_code_t enhance_document(scanbotsdk_image_t *image) { /* straightened_image can be saved or processed further here */ cleanup: - scanbotsdk_document_enhancer_free(enhancer); + scanbotsdk_document_straightener_free(straightener); scanbotsdk_document_straightening_result_free(result); scanbotsdk_document_straightening_parameters_free(straightening_params); diff --git a/examples/c/src/snippets/live/live_barcode.c b/examples/c/src/snippets/live/live_barcode.c index 7a755b3..3c79aa8 100644 --- a/examples/c/src/snippets/live/live_barcode.c +++ b/examples/c/src/snippets/live/live_barcode.c @@ -128,8 +128,9 @@ scanbotsdk_error_code_t process_frame(scanbotsdk_barcode_scanner_t *scanner, fra scanbotsdk_barcode_scanner_result_get_barcodes(result, barcodes, count); for (size_t i = 0; i < count; i++) { - const char *text = NULL; - scanbotsdk_barcode_item_get_text(barcodes[i], &text); + scanbotsdk_u8string_ref_t text_ref = {0}; + scanbotsdk_barcode_item_get_text(barcodes[i], &text_ref); + const char *text = scanbotsdk_u8string_ref_assume_cstring(text_ref); fprintf(stdout, " Barcode %zu: %s\n", i, text); } free(barcodes); @@ -185,7 +186,8 @@ scanbotsdk_error_code_t create_barcode_scanner(bool use_tensor_rt, scanbotsdk_ba if (use_tensor_rt) { scanbotsdk_tensor_rt_accelerator_t *trt = NULL; - ec = scanbotsdk_tensor_rt_accelerator_create("./", &trt); + scanbotsdk_u8string_ref_t trt_dir = scanbotsdk_u8string_ref_from_cstring("./"); + ec = scanbotsdk_tensor_rt_accelerator_create(trt_dir, &trt); if (ec == SCANBOTSDK_OK) { scanbotsdk_tensor_rt_accelerator_as_scanbotsdk_accelerator(trt, &accelerator); diff --git a/examples/c/src/utils/utils.c b/examples/c/src/utils/utils.c index dd334a1..7cc68b7 100644 --- a/examples/c/src/utils/utils.c +++ b/examples/c/src/utils/utils.c @@ -34,13 +34,15 @@ scanbotsdk_error_code_t print_generic_document_fields(scanbotsdk_generic_documen scanbotsdk_field_type_t *field_type = NULL; scanbotsdk_field_get_type(fields[i], &field_type); - const char *type_name = NULL; - scanbotsdk_field_type_get_name(field_type, &type_name); + scanbotsdk_u8string_ref_t type_name_ref = {0}; + scanbotsdk_field_type_get_name(field_type, &type_name_ref); + const char *type_name = scanbotsdk_u8string_ref_assume_cstring(type_name_ref); scanbotsdk_ocr_result_t *ocr_result = NULL; if (scanbotsdk_field_get_value(fields[i], &ocr_result) == SCANBOTSDK_OK && ocr_result) { - const char *text = NULL; - scanbotsdk_ocr_result_get_text(ocr_result, &text); + scanbotsdk_u8string_ref_t text_ref = {0}; + scanbotsdk_ocr_result_get_text(ocr_result, &text_ref); + const char *text = scanbotsdk_u8string_ref_assume_cstring(text_ref); printf("Field[%zu]: type=%s, value=\"%s\"\n", i, type_name, text ? text : "text value n/a"); } else { From 94382560ac25137c8856fca34c4e04f546d6aac0 Mon Sep 17 00:00:00 2001 From: Aleksei Ioffe Date: Fri, 31 Jul 2026 14:16:03 +0200 Subject: [PATCH 19/19] java related fixes --- .../java/io/scanbot/sdk/ScanbotSDKExample.java | 4 ++-- .../snippets/image/ImageProcessingSnippets.java | 2 +- .../DocumentStraightenerSnippet.java} | 10 +++++----- test-scripts/windows/Dockerfile | 14 +++----------- 4 files changed, 11 insertions(+), 19 deletions(-) rename examples/java/src/main/java/io/scanbot/sdk/snippets/{enhancer/DocumentEnhancerSnippet.java => straightener/DocumentStraightenerSnippet.java} (74%) diff --git a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java index e05c9c6..519a061 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java +++ b/examples/java/src/main/java/io/scanbot/sdk/ScanbotSDKExample.java @@ -7,7 +7,7 @@ import io.scanbot.sdk.snippets.barcode.*; import io.scanbot.sdk.snippets.datacapture.*; import io.scanbot.sdk.snippets.document.*; -import io.scanbot.sdk.snippets.enhancer.DocumentEnhancerSnippet; +import io.scanbot.sdk.snippets.straightener.DocumentStraightenerSnippet; import io.scanbot.sdk.utils.*; import java.util.Arrays; @@ -78,7 +78,7 @@ public static void main(String[] args) throws Exception { if (file == null && resource == null) { ExampleUsage.print(); return; } try (ImageRef image = Utils.createImageRef(file, resource)) { switch (subcommand) { - case "document": DocumentEnhancerSnippet.run(image); break; + case "document": DocumentStraightenerSnippet.run(image); break; default: ExampleUsage.print(); } break; diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/image/ImageProcessingSnippets.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/image/ImageProcessingSnippets.java index c22de10..58db9e5 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/image/ImageProcessingSnippets.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/image/ImageProcessingSnippets.java @@ -73,7 +73,7 @@ public static void detectAndCropDocument(ImageRef image) throws Exception { System.out.println("Detection status: " + detectionResult.getStatus()); System.out.println("Detected points: " + detectionResult.getPoints().size()); - try (ImageRef cropped = processor.crop(image, detectionResult.getPointsNormalized())) { + try (ImageRef cropped = processor.crop(image, detectionResult.getPointsNormalized(), null)) { ImageInfo croppedInfo = cropped.imageInfo(); System.out.println("Cropped WxH: " + croppedInfo.getWidth() + "x" + croppedInfo.getHeight()); } diff --git a/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java b/examples/java/src/main/java/io/scanbot/sdk/snippets/straightener/DocumentStraightenerSnippet.java similarity index 74% rename from examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java rename to examples/java/src/main/java/io/scanbot/sdk/snippets/straightener/DocumentStraightenerSnippet.java index 4dbebb7..37ea69f 100644 --- a/examples/java/src/main/java/io/scanbot/sdk/snippets/enhancer/DocumentEnhancerSnippet.java +++ b/examples/java/src/main/java/io/scanbot/sdk/snippets/straightener/DocumentStraightenerSnippet.java @@ -1,14 +1,14 @@ -package io.scanbot.sdk.snippets.enhancer; +package io.scanbot.sdk.snippets.straightener; import java.util.List; -import io.scanbot.sdk.documentscanner.DocumentEnhancer; +import io.scanbot.sdk.documentscanner.DocumentStraightener; import io.scanbot.sdk.documentscanner.DocumentStraighteningMode; import io.scanbot.sdk.documentscanner.DocumentStraighteningParameters; import io.scanbot.sdk.documentscanner.DocumentStraighteningResult; import io.scanbot.sdk.geometry.AspectRatio; import io.scanbot.sdk.image.ImageRef; -public class DocumentEnhancerSnippet { +public class DocumentStraightenerSnippet { public static void run(ImageRef image) throws Exception { DocumentStraighteningParameters params = new DocumentStraighteningParameters(); params.setStraighteningMode(DocumentStraighteningMode.STRAIGHTEN); @@ -20,8 +20,8 @@ public static void run(ImageRef image) throws Exception { )); try ( - DocumentEnhancer enhancer = new DocumentEnhancer(); - DocumentStraighteningResult result = enhancer.straighten(image, params, List.of()) + DocumentStraightener straightener = new DocumentStraightener(); + DocumentStraighteningResult result = straightener.run(image, params, List.of()) ) { // The straightened image can be accessed via result.getStraightenedImage() and saved or further processed as needed. } diff --git a/test-scripts/windows/Dockerfile b/test-scripts/windows/Dockerfile index 64dcf43..be7e5f6 100644 --- a/test-scripts/windows/Dockerfile +++ b/test-scripts/windows/Dockerfile @@ -89,9 +89,7 @@ RUN $ErrorActionPreference = 'Stop'; \ $wheelUrl = $env:PYTHON_SDK_WHL_URL; \ }; \ Write-Host ('Installing Python SDK from: {0}' -f $wheelUrl); \ - # TODO: Uncomment the following line to install from URL instead of local wheel file - # & $pythonExe -m pip install $wheelUrl; \ - & $pythonExe -m pip install scanbotsdk-0.1000.0-py3-none-win_amd64.whl; \ + & $pythonExe -m pip install $wheelUrl; \ Write-Host 'Python SDK installed successfully' RUN $ErrorActionPreference = 'Stop'; \ @@ -103,18 +101,12 @@ RUN $ErrorActionPreference = 'Stop'; \ $cSdkUrl = $env:C_SDK_ARCHIVE_URL; \ }; \ $archiveName = ('scanbotsdk-{0}-{1}.tar.gz' -f $env:SDK_VERSION, $cSdkArch); \ - $localArchive = Join-Path 'C:\workspaces\scanbot-sdk-example-linux' $archiveName; \ $archivePath = 'C:\scanbotsdk-c.tar.gz'; \ $sdkRoot = 'C:\scanbotsdk-cache'; \ if (Test-Path $sdkRoot) { Remove-Item $sdkRoot -Recurse -Force }; \ New-Item -ItemType Directory -Path $sdkRoot | Out-Null; \ - if (Test-Path $localArchive) { \ - Write-Host ('Using local debug C SDK archive: {0}' -f $localArchive); \ - Copy-Item -Path $localArchive -Destination $archivePath -Force; \ - } else { \ - Write-Host ('Downloading C SDK from: {0}' -f $cSdkUrl); \ - Invoke-WebRequest -Uri $cSdkUrl -OutFile $archivePath; \ - }; \ + Write-Host ('Downloading C SDK from: {0}' -f $cSdkUrl); \ + Invoke-WebRequest -Uri $cSdkUrl -OutFile $archivePath; \ Push-Location $sdkRoot; \ cmake -E tar -xf $archivePath; \ Pop-Location; \