Skip to content

Commit 6519411

Browse files
Kyrylocyrillicw
authored andcommitted
Readme files c wrapper
1 parent 02e2764 commit 6519411

File tree

12 files changed

+233
-7
lines changed

12 files changed

+233
-7
lines changed

examples/c/CMakeLists.txt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
cmake_minimum_required(VERSION 3.10)
22
project(scanbotsdk_c_example C)
3-
43
set(CMAKE_C_STANDARD 99)
54

5+
# Find or download Scanbot SDK
6+
if(NOT SCANBOTSDK_VERSION)
7+
message(FATAL_ERROR "SCANBOTSDK_VERSION is not set.")
8+
endif()
9+
if(NOT SCANBOTSDK_API_TOKEN)
10+
message(FATAL_ERROR "SCANBOTSDK_API_TOKEN is not set.")
11+
endif()
12+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
613
set(SCANBOTSDK_DIR "${CMAKE_CURRENT_BINARY_DIR}/scanbotsdk")
7-
set(SCANBOTSDK_API_TOKEN "<SCANBOTSDK_API_KEY>") # Replace with your actual API key
8-
set(SCANBOTSDK_VERSION "<SCANBOTSDK_VERSION>") # Replace with the desired version, e.g., "1.0.0"
9-
include(FindScanbotSDK.cmake)
14+
find_package(ScanbotSDK REQUIRED)
15+
16+
add_library(scanbotsdk SHARED IMPORTED)
17+
set_target_properties(scanbotsdk PROPERTIES
18+
IMPORTED_LOCATION "${ScanbotSDK_LIBS}"
19+
INTERFACE_INCLUDE_DIRECTORIES "${ScanbotSDK_INCLUDE_DIRS}"
20+
)
1021

11-
add_executable(scanbotsdk_c_example main.c)
12-
target_link_libraries(scanbotsdk_c_example PRIVATE ${ScanbotSDK_LIBS})
13-
target_include_directories(scanbotsdk_c_example PRIVATE ${ScanbotSDK_INCLUDE_DIRS})
22+
add_subdirectory(barcode)

examples/c/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# API Documentation
2+
The API documentation is accessible here:
3+
* [Scanbot SDK - C API](https://api-docs.scanbot.io/document-scanner-sdk/linux/c-api/index.html)
4+
5+
# Installation
6+
7+
## NVidia Jetson
8+
9+
> Scanbot SDK requires Jetpack 6.1, CUDA 12.6 and TensorRT 10.3 to run with GPU acceleration.
10+
11+
* Install a C compiler, CMake and wget:
12+
13+
```bash
14+
sudo apt install -y cmake build-essential wget
15+
```
16+
17+
* Optionally, install CUDA and TensorRT for GPU acceleration. Make sure that you're running a supported Jetpack version.
18+
19+
```bash
20+
sudo apt install -y nvidia-l4t-cuda libnvinfer10 libnvinfer-plugin10 libnvonnxparsers10
21+
```
22+
23+
* You're now ready to run the examples.
24+
25+
----
26+
27+
## Raspberry Pi OS, Ubuntu, Debian
28+
29+
* Install a C compiler, CMake and wget:
30+
31+
```bash
32+
sudo apt install -y cmake build-essential wget
33+
```
34+
35+
* You're now ready to build the examples.
36+
37+
# Building the Examples
38+
In order to build all examples, run the following commands:
39+
40+
```bash
41+
mkdir build
42+
cd build
43+
cmake -DSCANBOTSDK_VERSION=<SCANBOTSDK_VERSION> -DSCANBOTSDK_API_TOKEN=<SCANBOTSDK_API_TOKEN> ..
44+
make
45+
```
46+
47+
Replace `SCANBOTSDK_VERSION` and `SCANBOTSDK_API_TOKEN` with the avlues you received from us.
48+
49+
# Running the Examples
50+
See the `README.md` files in the individual example directories for instructions on how to run them.

examples/c/barcode/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_subdirectory(live)
2+
add_subdirectory(minimal)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(barcode_live C)
3+
4+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/example.png" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
5+
6+
add_executable(${PROJECT_NAME} main.c)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE scanbotsdk)

examples/c/barcode/live/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Barcode Scanner Live Mode Example
2+
3+
This example demonstrates how to use barcode scanner functionality in live mode.
4+
It uses mock camera to simulate frames coming from a camera device.
5+
6+
You should provide it with the image you want to be used as a camera frame.
7+
8+
## Usage
9+
```bash
10+
<build_directory>/barcode/live/barcode_live <license_key> <image_path>
11+
```
File renamed without changes.

examples/c/main.c renamed to examples/c/barcode/live/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,13 @@ int main(int argc, char *argv[]) {
217217
}
218218
// endregion
219219

220+
// region create barcode scanner
220221
ec = create_barcode_scanner(&barcode_scanner);
221222
if (ec != SCANBOTSDK_OK) {
222223
fprintf(stderr, "Failed to create barcode scanner: %d: %s\n", ec, error_message(ec));
223224
goto exit;
224225
}
226+
// endregion
225227

226228
// region create mock camera that always returns the same frame
227229
ec = init_camera(mock_frame_path, &camera);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
project(barcode_minimal C)
3+
4+
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/example.png" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
5+
6+
add_executable(${PROJECT_NAME} main.c)
7+
target_link_libraries(${PROJECT_NAME} PRIVATE scanbotsdk)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Barcode Scanner Minimal Example
2+
3+
This example demonstrates the simplest way to use barcode scanner to process a single image.
4+
5+
## Usage
6+
```bash
7+
<build_directory>/barcode/minimal/barcode_minimal <license_key> <image_path>
8+
```
114 KB
Loading

0 commit comments

Comments
 (0)