From a70cb67e7abe891be1b1ea85beafb7925928c73c Mon Sep 17 00:00:00 2001 From: Stefan Dragnev Date: Wed, 10 Jun 2026 11:13:19 +0000 Subject: [PATCH 1/5] update C wrapper for windows --- examples/c/CMakeLists.txt | 19 +++-- examples/c/cmake/Download.cmake | 17 ++++ examples/c/cmake/FindScanbotSDK.cmake | 114 ++++++++++++++++++++------ 3 files changed, 117 insertions(+), 33 deletions(-) create mode 100644 examples/c/cmake/Download.cmake diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 19a8676..50307f3 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -1,17 +1,24 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.20) project(scanbotsdk_c_example C) set(CMAKE_C_STANDARD 99) # Find or download Scanbot SDK if(NOT SCANBOTSDK_VERSION) - message(FATAL_ERROR "SCANBOTSDK_VERSION is not set.") + set(SCANBOTSDK_VERSION "9.0.0") endif() -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") -set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}/scanbotsdk") +list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(ScanbotSDK REQUIRED) -file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c) +file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") add_executable(scanbotsdk_example ${SOURCE_FILES}) target_include_directories(scanbotsdk_example PRIVATE include) -target_link_libraries(scanbotsdk_example PRIVATE scanbotsdk) +target_link_libraries(scanbotsdk_example PRIVATE ScanbotSDK::ScanbotSDK) + +if(WIN32) + add_custom_command(TARGET scanbotsdk_example POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different + "$" + "$" + ) +endif() diff --git a/examples/c/cmake/Download.cmake b/examples/c/cmake/Download.cmake new file mode 100644 index 0000000..396312b --- /dev/null +++ b/examples/c/cmake/Download.cmake @@ -0,0 +1,17 @@ +# Download.cmake +if(NOT URL OR NOT DEST) + message(FATAL_ERROR "Both URL and DEST variables must be defined.") +endif() + +file(DOWNLOAD "${URL}" "${DEST}" + STATUS status + TLS_VERIFY ON +) + +list(GET status 0 status_code) +list(GET status 1 status_string) + +if(NOT status_code EQUAL 0) + file(REMOVE "${DEST}") + message(FATAL_ERROR "Download failed (${status_code}): ${status_string}") +endif() diff --git a/examples/c/cmake/FindScanbotSDK.cmake b/examples/c/cmake/FindScanbotSDK.cmake index d6fabb8..816d27b 100644 --- a/examples/c/cmake/FindScanbotSDK.cmake +++ b/examples/c/cmake/FindScanbotSDK.cmake @@ -1,47 +1,107 @@ -include(ExternalProject) include(FindPackageHandleStandardArgs) -if(NOT SCANBOTSDK_DIR) -message(FATAL_ERROR "SCANBOTSDK_DIR not set") +if(TARGET ScanbotSDK::ScanbotSDK) + return() endif() -if (NOT EXISTS ${SCANBOTSDK_DIR}) +if(NOT DEFINED SCANBOTSDK_VERSION) + message(FATAL_ERROR "SCANBOTSDK_VERSION is not set.") +endif() + +if(NOT DEFINED SCANBOTSDK_DIR) + set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}") +endif() + +if(NOT EXISTS "${SCANBOTSDK_DIR}/scanbotsdk") + if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(SCANBOTSDK_TARGET "windows-x86") + else() + set(SCANBOTSDK_TARGET "windows-x64") + endif() + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(CMAKE_SYSTEM_PROCESSOR MATCHES ".*arm.*" OR CMAKE_SYSTEM_PROCESSOR MATCHES ".*aarch64.*") + set(SCANBOTSDK_TARGET "linux-aarch64") + else() + set(SCANBOTSDK_TARGET "linux-x86_64") + endif() + else() + message(FATAL_ERROR "System ${CMAKE_SYSTEM_NAME} not supported") + endif() - find_program(WGET_PATH wget REQUIRED) + set(_archive "${SCANBOTSDK_DIR}/scanbotsdk-${SCANBOTSDK_VERSION}-${SCANBOTSDK_TARGET}.tar.gz") + set(_url "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOTSDK_VERSION}/scanbotsdk-${SCANBOTSDK_VERSION}-${SCANBOTSDK_TARGET}.tar.gz") - message(STATUS "Downloading ScanbotSDK ${SCANBOTSDK_VERSION} to ${SCANBOTSDK_DIR}") + file(MAKE_DIRECTORY "${SCANBOTSDK_DIR}") - if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES ".*arm.*" OR "${CMAKE_HOST_SYSTEM_PROCESSOR}" MATCHES ".*aarch64.*") - set(SCANBOTSDK_ARCHITECTURE "aarch64") - else () - set(SCANBOTSDK_ARCHITECTURE "x86_64") - endif () - string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}-${SCANBOTSDK_ARCHITECTURE}" PLATFORM_ID) - set(URL "https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOTSDK_VERSION}/scanbotsdk-${SCANBOTSDK_VERSION}-linux-${SCANBOTSDK_ARCHITECTURE}.tar.gz") execute_process( - COMMAND ${WGET_PATH} "${URL}" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND "${CMAKE_COMMAND}" + "-DURL=${_url}" + "-DDEST=${_archive}" + -P "${CMAKE_CURRENT_LIST_DIR}/Download.cmake" + RESULT_VARIABLE _rc ) + if(NOT _rc EQUAL 0) + file(REMOVE "${_archive}") + message(FATAL_ERROR "Failed to download Scanbot SDK from ${_url}") + endif() + execute_process( - COMMAND tar -xf scanbotsdk-${SCANBOTSDK_VERSION}-${PLATFORM_ID}.tar.gz - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND "${CMAKE_COMMAND}" -E tar -xf "${_archive}" + WORKING_DIRECTORY "${SCANBOTSDK_DIR}" + RESULT_VARIABLE _rc ) + if(NOT _rc EQUAL 0) + file(REMOVE "${_archive}") + file(REMOVE_RECURSE "${SCANBOTSDK_DIR}/scanbotsdk") + message(FATAL_ERROR "Failed to extract Scanbot SDK archive ${_archive}") + endif() + + file(REMOVE "${_archive}") endif() find_library(ScanbotSDK_LIBS - NAMES libscanbotsdk.so - HINTS ${SCANBOTSDK_DIR}/lib/ - ) + NAMES scanbotsdk + PATHS "${SCANBOTSDK_DIR}/scanbotsdk/lib" + NO_DEFAULT_PATH +) find_path(ScanbotSDK_INCLUDE_DIRS NAMES ScanbotSDK.h - HINTS ${SCANBOTSDK_DIR}/include/) + PATHS "${SCANBOTSDK_DIR}/scanbotsdk/include" + NO_DEFAULT_PATH +) + +set(SCANBOTSDK_REQUIRED_VARS ScanbotSDK_LIBS ScanbotSDK_INCLUDE_DIRS) + +if(WIN32) + find_file(ScanbotSDK_DLL + NAMES scanbotsdk.dll + PATHS "${SCANBOTSDK_DIR}/scanbotsdk/lib" + NO_DEFAULT_PATH + ) + list(APPEND SCANBOTSDK_REQUIRED_VARS ScanbotSDK_DLL) +endif() find_package_handle_standard_args(ScanbotSDK - REQUIRED_VARS ScanbotSDK_LIBS ScanbotSDK_INCLUDE_DIRS) + REQUIRED_VARS ${SCANBOTSDK_REQUIRED_VARS} + VERSION_VAR SCANBOTSDK_VERSION +) + +message(STATUS "Scanbot SDK third-party licenses are located at: ${SCANBOTSDK_DIR}/scanbotsdk/licenses/Libraries.txt") -add_library(scanbotsdk SHARED IMPORTED) -set_target_properties(scanbotsdk PROPERTIES - IMPORTED_LOCATION "${ScanbotSDK_LIBS}" - INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}" -) \ No newline at end of file +add_library(ScanbotSDK::ScanbotSDK SHARED IMPORTED) +set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}" +) + +if(WIN32) + set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES + IMPORTED_LOCATION "${ScanbotSDK_DLL}" + IMPORTED_IMPLIB "${ScanbotSDK_LIBS}" + ) +else() + set_target_properties(ScanbotSDK::ScanbotSDK PROPERTIES + IMPORTED_LOCATION "${ScanbotSDK_LIBS}" + ) +endif() From 8660b091746d21182ebd9d67976068cae811a4c9 Mon Sep 17 00:00:00 2001 From: Stefan Dragnev Date: Wed, 10 Jun 2026 11:37:35 +0000 Subject: [PATCH 2/5] update readme --- examples/python/README.md | 119 +++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 41 deletions(-) diff --git a/examples/python/README.md b/examples/python/README.md index 21cba6a..c3daf1b 100644 --- a/examples/python/README.md +++ b/examples/python/README.md @@ -1,33 +1,33 @@ -# Scanbot SDK – Python on Linux +# Scanbot SDK – Python on Linux/Windows ## NVidia Jetson > Requires **Jetpack 6.1**, **CUDA 12.6**, and **TensorRT 10.3** for GPU acceleration. ### 1. Install Python and OpenCV -```bash -sudo apt install -y python3-venv nvidia-opencv -``` + ```bash + sudo apt install -y python3-venv nvidia-opencv + ``` ### 2. (Optional) Install CUDA + TensorRT Make sure you are running a supported Jetpack version: -```bash -sudo apt install -y nvidia-l4t-cuda libnvinfer10 libnvinfer-plugin10 libnvonnxparsers10 -``` + ```bash + sudo apt install -y nvidia-l4t-cuda libnvinfer10 libnvinfer-plugin10 libnvonnxparsers10 + ``` ### 3. Create and activate a virtual environment -```bash -python3 -m venv .env --system-site-packages -source .env/bin/activate -pip install --upgrade pip setuptools wheel -``` + ```bash + python3 -m venv .env --system-site-packages + source .env/bin/activate + pip install --upgrade pip setuptools wheel + ``` ### 3. Install the Scanbot SDK Replace `` with the actual version number of the SDK you want to install. -```bash -export SCANBOT_SDK_VERSION= -``` + ```bash + export SCANBOT_SDK_VERSION= + ``` * **On ARM64 (Raspberry Pi, Jetson Nano, etc.):** ```bash @@ -40,42 +40,42 @@ export SCANBOT_SDK_VERSION= ``` ### 5. Verify installation -```bash -python -c "import scanbotsdk" -``` + ```bash + python -c "import scanbotsdk" + ``` ### ⚡ Performance notes (Jetson) To avoid throttling, set max GPU/CPU/memory clocks: -```bash -sudo jetson_clocks --store -sudo jetson_clocks -``` + ```bash + sudo jetson_clocks --store + sudo jetson_clocks + ``` Restore defaults later: -```bash -sudo jetson_clocks --restore -``` + ```bash + sudo jetson_clocks --restore + ``` ## Raspberry Pi OS, Ubuntu, Debian ### 1. Install Python and OpenCV -```bash -sudo apt install -y python3-venv python3-opencv -``` + ```bash + sudo apt install -y python3-venv python3-opencv + ``` ### 2. Create and activate a virtual environment -```bash -python3 -m venv .env --system-site-packages -source .env/bin/activate -pip install --upgrade pip setuptools wheel -``` + ```bash + python3 -m venv .env --system-site-packages + source .env/bin/activate + pip install --upgrade pip setuptools wheel + ``` ### 3. Install the Scanbot SDK Replace `` with the actual version number of the SDK you want to install. -```bash -export SCANBOT_SDK_VERSION= -``` + ```bash + export SCANBOT_SDK_VERSION= + ``` * **On ARM64 (Raspberry Pi, Jetson Nano, etc.):** ```bash @@ -88,16 +88,53 @@ export SCANBOT_SDK_VERSION= ``` ### 4. Verify installation -```bash -python -c "import scanbotsdk" -``` + ```bash + python -c "import scanbotsdk" + ``` + +## Windows + +### 1. Prerequisites +* x86/x86_64 CPU +* Python 3.6+ (32/64-bit) +* PowerShell +* OpenCV (only for examples) + +The snippets below are written for PowerShell, not cmd. + +### 2. Create and activate a virtual environment: + ```powershell + python -m venv .env --system-site-packages + . .\.env\Scripts\Activate.ps1 + python -m pip install --upgrade pip setuptools wheel + python -m pip install opencv-python + ``` + +### 3. Install the Scanbot SDK +Replace `` with the actual version number of the SDK you want to install. + ```powershell + $SCANBOT_SDK_VERSION = "" + ``` + +* **Python x86_64 (64-bit):** + ```powershell + pip install https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOT_SDK_VERSION}/scanbotsdk-${SCANBOT_SDK_VERSION}-py3-none-win_amd64.whl + ``` + +* **Python x86 (32-bit):** + ```powershell + pip install https://github.com/doo/scanbot-sdk-example-linux/releases/download/standalone-sdk%2Fv${SCANBOT_SDK_VERSION}/scanbotsdk-${SCANBOT_SDK_VERSION}-py3-none-win32.whl + ``` + +### 4. Verify installation + ```powershell + python -c "import scanbotsdk" + ``` ## Usage The example supports four modes: **scan**, **analyze**, **classify**, and **parse**. ```bash python main.py scan --file [--license ] -python main.py scan --file [--license ] -python main.py analyze --file [--save ] [--license ] python main.py analyze --file [--save ] [--license ] python main.py classify --file|--resource [--license ] python main.py parse --text "" [--license ] From 7b12de4d41b15fee001f8ee563d6cc876a0d3745 Mon Sep 17 00:00:00 2001 From: Stefan Dragnev Date: Wed, 10 Jun 2026 11:49:59 +0000 Subject: [PATCH 3/5] downgrade to cmake 3.10 --- examples/c/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/c/CMakeLists.txt b/examples/c/CMakeLists.txt index 50307f3..8392d97 100644 --- a/examples/c/CMakeLists.txt +++ b/examples/c/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.20) +# 3.10 is the version shipped with Ubuntu 18.04, which is the base of NVIDIA JetPack 4.6. +cmake_minimum_required(VERSION 3.10) project(scanbotsdk_c_example C) set(CMAKE_C_STANDARD 99) @@ -6,10 +7,10 @@ set(CMAKE_C_STANDARD 99) if(NOT SCANBOTSDK_VERSION) set(SCANBOTSDK_VERSION "9.0.0") endif() -list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) find_package(ScanbotSDK REQUIRED) -file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") +file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") add_executable(scanbotsdk_example ${SOURCE_FILES}) target_include_directories(scanbotsdk_example PRIVATE include) target_link_libraries(scanbotsdk_example PRIVATE ScanbotSDK::ScanbotSDK) From 93c8b656da9d723878ad3261ea7c2e4f60e6c068 Mon Sep 17 00:00:00 2001 From: Stefan Dragnev Date: Thu, 11 Jun 2026 16:46:46 +0000 Subject: [PATCH 4/5] C project readme updated for Windows --- examples/c/README.md | 47 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/examples/c/README.md b/examples/c/README.md index 9663b36..39c689b 100644 --- a/examples/c/README.md +++ b/examples/c/README.md @@ -29,8 +29,6 @@ sudo jetson_clocks --restore * You're now ready to run the examples. ----- - ### Raspberry Pi OS, Ubuntu, Debian * Install a C compiler, CMake and wget: @@ -41,17 +39,48 @@ sudo apt install -y cmake build-essential wget * You're now ready to build the examples. +### Windows + +Requirements: + +* Visual Studio C++ Build Tools +* CMake 3.10+ +* Recommended: ninja + ## Building the Examples In order to build all examples, run the following commands: -```bash -mkdir build -cd build -# Replace `` with the actual version number of the SDK you want to install. -cmake -DSCANBOTSDK_VERSION= .. -make -``` +* With ninja (recommended): + ```bash + mkdir build + cd build + # Replace `` with the actual version number of the SDK you want to install. + cmake -GNinja -DSCANBOTSDK_VERSION= .. + ninja + ``` + +* With make: + + ```bash + mkdir build + cd build + # Replace `` with the actual version number of the SDK you want to install. + cmake -DSCANBOTSDK_VERSION= .. + make + ``` + +* With MS Visual Studio (Windows-only): + + ```powershell + mkdir build + cd build + # Replace `` with the actual version number of the SDK you want to install. + cmake "-DSCANBOTSDK_VERSION=" .. + msbuild scanbotsdk_c_example.sln + # scanbotsdk_example.exe will be created under Debug\ + ``` + ## Usage The example supports four modes: **scan**, **analyze**, **classify**, and **parse**. From 3b9640c28fc457347a11ca41cb3bdcd2be72aa87 Mon Sep 17 00:00:00 2001 From: Stefan Dragnev Date: Thu, 11 Jun 2026 21:49:39 +0000 Subject: [PATCH 5/5] remove mentions of wget --- examples/c/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/c/README.md b/examples/c/README.md index 39c689b..1051ffd 100644 --- a/examples/c/README.md +++ b/examples/c/README.md @@ -4,10 +4,10 @@ > Scanbot SDK requires Jetpack 6.1, CUDA 12.6 and TensorRT 10.3 to run with GPU acceleration. -* Install a C compiler, CMake and wget: +* Install a C compiler and CMake: ```bash -sudo apt install -y cmake build-essential wget +sudo apt install -y cmake build-essential ``` * Optionally, install CUDA and TensorRT for GPU acceleration. Make sure that you're running a supported Jetpack version. @@ -31,10 +31,10 @@ sudo jetson_clocks --restore ### Raspberry Pi OS, Ubuntu, Debian -* Install a C compiler, CMake and wget: +* Install a C compiler and CMake: ```bash -sudo apt install -y cmake build-essential wget +sudo apt install -y cmake build-essential ``` * You're now ready to build the examples.