simple-dynamsoft-mcp 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/README.md +272 -269
  2. package/code-snippet/dynamsoft-barcode-reader/python/Samples/camera.py +96 -0
  3. package/code-snippet/dynamsoft-barcode-reader/python/Samples/file.py +82 -0
  4. package/code-snippet/dynamsoft-barcode-reader/python/Samples/utils.py +60 -0
  5. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/BlazorApp.csproj.nuget.dgspec.json +108 -0
  6. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/BlazorApp.csproj.nuget.g.props +26 -0
  7. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/BlazorApp.csproj.nuget.g.targets +12 -0
  8. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  9. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/Debug/net8.0/BlazorApp.AssemblyInfo.cs +22 -0
  10. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/Debug/net8.0/BlazorApp.GeneratedMSBuildEditorConfig.editorconfig +53 -0
  11. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/Debug/net8.0/BlazorApp.GlobalUsings.g.cs +11 -0
  12. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-foundational-api/hello-world-blazor/BlazorApp/obj/project.assets.json +2137 -0
  13. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/BlazorApp.csproj.nuget.dgspec.json +108 -0
  14. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/BlazorApp.csproj.nuget.g.props +26 -0
  15. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/BlazorApp.csproj.nuget.g.targets +12 -0
  16. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs +4 -0
  17. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/Debug/net8.0/BlazorApp.AssemblyInfo.cs +22 -0
  18. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/Debug/net8.0/BlazorApp.GeneratedMSBuildEditorConfig.editorconfig +41 -0
  19. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/Debug/net8.0/BlazorApp.GlobalUsings.g.cs +11 -0
  20. package/code-snippet/dynamsoft-barcode-reader/web/frameworks/blazor/scan-using-rtu-api/obj/project.assets.json +2137 -0
  21. package/package.json +8 -2
  22. package/src/index.js +89 -1
  23. package/test/server.test.js +420 -0
package/README.md CHANGED
@@ -1,269 +1,272 @@
1
- # Dynamsoft MCP Server
2
-
3
- MCP (Model Context Protocol) server that enables AI assistants to write correct code with Dynamsoft SDKs. It provides actual working code snippets, documentation links, and API guidance for:
4
-
5
- - **Dynamsoft Barcode Reader Mobile** - Android (Java/Kotlin) and iOS (Swift)
6
- - **Dynamsoft Barcode Reader Python** - Desktop/server barcode scanning
7
- - **Dynamsoft Barcode Reader Web** - JavaScript/TypeScript barcode scanning
8
- - **Dynamic Web TWAIN** - Document scanning from TWAIN/WIA/ICA/SANE scanners
9
-
10
- ## Features
11
-
12
- - **Code Snippets**: Real, working source code from official Dynamsoft samples
13
- - **Trial License Included**: Ready-to-use trial license for quick testing
14
- - **Multiple SDKs**: Barcode Reader (Mobile/Python/Web) + Dynamic Web TWAIN
15
- - **Multiple API Levels**: High-level (simple) and low-level (advanced) options
16
-
17
- ## Available Tools
18
-
19
- | Tool | Description |
20
- |------|-------------|
21
- | `list_sdks` | List all SDKs with versions and platforms |
22
- | `get_sdk_info` | Get detailed SDK info for a specific platform |
23
- | `list_samples` | List mobile code samples |
24
- | `list_python_samples` | List Python SDK samples |
25
- | `list_dwt_categories` | List Dynamic Web TWAIN sample categories |
26
- | `get_code_snippet` | Get mobile sample source code |
27
- | `get_python_sample` | Get Python sample code |
28
- | `get_dwt_sample` | Get Dynamic Web TWAIN sample |
29
- | `get_quick_start` | Complete quick start guide with dependencies |
30
- | `get_gradle_config` | Android Gradle configuration |
31
- | `get_license_info` | License initialization code |
32
- | `get_api_usage` | Usage examples for specific APIs |
33
- | `search_samples` | Search samples by keyword |
34
-
35
-
36
- ## MCP Client Configuration
37
-
38
- ### Claude Desktop
39
-
40
- Add to your `claude_desktop_config.json`:
41
-
42
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
43
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
44
-
45
- ```json
46
- {
47
- "mcpServers": {
48
- "dynamsoft": {
49
- "command": "npx",
50
- "args": ["-y", "simple-dynamsoft-mcp"]
51
- }
52
- }
53
- }
54
- ```
55
-
56
- ### VS Code (GitHub Copilot)
57
-
58
- Add to your VS Code `settings.json` (Ctrl+Shift+P → "Preferences: Open User Settings (JSON)"):
59
-
60
- ```json
61
- {
62
- "mcp": {
63
- "servers": {
64
- "dynamsoft": {
65
- "command": "npx",
66
- "args": ["-y", "simple-dynamsoft-mcp"]
67
- }
68
- }
69
- }
70
- }
71
- ```
72
-
73
- Or use the workspace `.vscode/mcp.json`:
74
-
75
- ```json
76
- {
77
- "servers": {
78
- "dynamsoft": {
79
- "command": "npx",
80
- "args": ["-y", "simple-dynamsoft-mcp"]
81
- }
82
- }
83
- }
84
- ```
85
-
86
- ### OpenCode
87
-
88
- Add to your `~/.config/opencode/opencode.json` (or `%USERPROFILE%\.config\opencode\opencode.json` on Windows):
89
-
90
- ```json
91
- {
92
- "mcp": {
93
- "servers": {
94
- "dynamsoft": {
95
- "command": "npx",
96
- "args": ["-y", "simple-dynamsoft-mcp"]
97
- }
98
- }
99
- }
100
- }
101
- ```
102
-
103
- ### Cursor
104
-
105
- Add to your Cursor settings (`~/.cursor/mcp.json`):
106
-
107
- ```json
108
- {
109
- "mcpServers": {
110
- "dynamsoft": {
111
- "command": "npx",
112
- "args": ["-y", "simple-dynamsoft-mcp"]
113
- }
114
- }
115
- }
116
- ```
117
-
118
- ### Windsurf
119
-
120
- Add to your Windsurf MCP config (`~/.codeium/windsurf/mcp_config.json`):
121
-
122
- ```json
123
- {
124
- "mcpServers": {
125
- "dynamsoft": {
126
- "command": "npx",
127
- "args": ["-y", "simple-dynamsoft-mcp"]
128
- }
129
- }
130
- }
131
- ```
132
-
133
- ### Cline (VS Code Extension)
134
-
135
- Add via Cline settings in VS Code or edit `~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json`:
136
-
137
- ```json
138
- {
139
- "mcpServers": {
140
- "dynamsoft": {
141
- "command": "npx",
142
- "args": ["-y", "simple-dynamsoft-mcp"]
143
- }
144
- }
145
- }
146
- ```
147
-
148
- ### Alternative: Run from Local Clone
149
-
150
- If you prefer running from source:
151
-
152
- ```json
153
- {
154
- "command": "node",
155
- "args": ["/absolute/path/to/simple-dynamsoft-mcp/src/index.js"]
156
- }
157
- ```
158
-
159
- ## Supported SDKs
160
-
161
- ### Dynamsoft Barcode Reader Mobile (v11.2.5000)
162
-
163
- **Platforms:** Android, iOS, Flutter, React Native, .NET MAUI
164
-
165
- **API Levels:**
166
- - **High-Level (BarcodeScanner)**: Simple ready-to-use barcode scanning UI
167
- - **Low-Level (CaptureVisionRouter)**: Full control over the scanning pipeline
168
-
169
- **Android Samples:**
170
- - ScanSingleBarcode, ScanMultipleBarcodes, ScenarioOrientedSamples
171
- - DecodeWithCameraEnhancer, DecodeWithCameraX, DecodeFromAnImage
172
- - GeneralSettings, DriversLicenseScanner, TinyBarcodeDecoding, ReadGS1AI
173
-
174
- **iOS Samples:**
175
- - ScanSingleBarcode, ScanMultipleBarcodes, ScanSingleBarcodeSwiftUI
176
- - DecodeWithCameraEnhancer, DecodeWithAVCaptureSession, DecodeFromAnImage
177
-
178
- ### Dynamsoft Barcode Reader Python (v11.2.5000)
179
-
180
- **Installation:** `pip install dynamsoft-barcode-reader-bundle`
181
-
182
- **Samples:**
183
- - `read_an_image` - Decode barcodes from image files
184
- - `video_decoding` - Real-time video decoding
185
-
186
- ### Dynamsoft Barcode Reader Web (v11.2.4000)
187
-
188
- **Installation:** `npm install dynamsoft-barcode-reader-bundle`
189
-
190
- **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.min.js`
191
-
192
- ### Dynamic Web TWAIN (v19.3)
193
-
194
- **Installation:** `npm install dwt`
195
-
196
- **CDN:** `https://cdn.jsdelivr.net/npm/dwt@latest/dist/dynamsoft.webtwain.min.js`
197
-
198
- **Sample Categories:**
199
- - **scan** - Basic document scanning (basic-scan, read-barcode, etc.)
200
- - **input-options** - Load from files, URLs, local drive
201
- - **output-options** - Save, upload, convert to PDF/Base64/Blob
202
- - **classification** - Document classification and tagging
203
- - **UI-customization** - Customize viewer and scan UI
204
-
205
- ## Trial License
206
- https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform
207
-
208
- ## Example AI Prompts
209
-
210
- After connecting the MCP server, you can ask your AI assistant:
211
-
212
- ### Mobile Barcode Scanner
213
- - "Create an Android app that scans a single barcode"
214
- - "Show me how to use CaptureVisionRouter in iOS Swift"
215
- - "Get the Gradle configuration for Dynamsoft Barcode Reader"
216
- - "How do I initialize the Dynamsoft license in Kotlin?"
217
-
218
- ### Python Barcode Reader
219
- - "Show me how to read barcodes from an image in Python"
220
- - "Get the Python sample for video decoding"
221
-
222
- ### Dynamic Web TWAIN
223
- - "Create a web page that scans documents from a TWAIN scanner"
224
- - "Show me how to save scanned documents as PDF"
225
- - "Get the DWT sample for reading barcodes from scanned documents"
226
-
227
- ## SDK Documentation
228
-
229
- - **Mobile Android**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/android/user-guide.html
230
- - **Mobile iOS**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/objectivec-swift/user-guide.html
231
- - **Python**: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide.html
232
- - **Web JavaScript**: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html
233
- - **Dynamic Web TWAIN**: https://www.dynamsoft.com/web-twain/docs/introduction/index.html
234
-
235
- ## Code Snippet Structure
236
-
237
- ```
238
- code-snippet/
239
- ├── dynamsoft-barcode-reader/
240
- │ ├── android/
241
- │ │ ├── BarcodeScannerAPISamples/ # High-level API
242
- │ │ └── FoundationalAPISamples/ # Low-level API
243
- │ ├── ios/
244
- │ │ ├── BarcodeScannerAPISamples/
245
- │ │ └── FoundationalAPISamples/
246
- │ ├── python/
247
- │ │ └── Samples/
248
- │ └── web/
249
- └── dynamic-web-twain/
250
- ├── scan/
251
- ├── input-options/
252
- ├── output-options/
253
- ├── classification/
254
- └── UI-customization/
255
- ```
256
-
257
- ## Extending the Server
258
-
259
- ### Add New Samples
260
-
261
- Place new sample projects in the appropriate folder under `code-snippet/`.
262
-
263
- ### Update SDK Info
264
-
265
- Edit `data/dynamsoft_sdks.json` to update versions, docs URLs, or add new platforms.
266
-
267
- ## License
268
-
269
- MIT
1
+ # Dynamsoft MCP Server
2
+
3
+ MCP (Model Context Protocol) server that enables AI assistants to write correct code with Dynamsoft SDKs. It provides actual working code snippets, documentation links, and API guidance for:
4
+
5
+ - **Dynamsoft Barcode Reader Mobile** - Android (Java/Kotlin) and iOS (Swift)
6
+ - **Dynamsoft Barcode Reader Python** - Desktop/server barcode scanning
7
+ - **Dynamsoft Barcode Reader Web** - JavaScript/TypeScript barcode scanning
8
+ - **Dynamic Web TWAIN** - Document scanning from TWAIN/WIA/ICA/SANE scanners
9
+
10
+ ## Demo Video
11
+ https://github.com/user-attachments/assets/cc1c5f4b-1461-4462-897a-75abc20d62a6
12
+
13
+
14
+ ## Features
15
+
16
+ - **Code Snippets**: Real, working source code from official Dynamsoft samples
17
+ - **Trial License Included**: Ready-to-use trial license for quick testing
18
+ - **Multiple SDKs**: Barcode Reader (Mobile/Python/Web) + Dynamic Web TWAIN
19
+ - **Multiple API Levels**: High-level (simple) and low-level (advanced) options
20
+
21
+ ## Available Tools
22
+
23
+ | Tool | Description |
24
+ |------|-------------|
25
+ | `list_sdks` | List all SDKs with versions and platforms |
26
+ | `get_sdk_info` | Get detailed SDK info for a specific platform |
27
+ | `list_samples` | List mobile code samples |
28
+ | `list_python_samples` | List Python SDK samples |
29
+ | `list_dwt_categories` | List Dynamic Web TWAIN sample categories |
30
+ | `get_code_snippet` | Get mobile sample source code |
31
+ | `get_python_sample` | Get Python sample code |
32
+ | `get_dwt_sample` | Get Dynamic Web TWAIN sample |
33
+ | `get_quick_start` | Complete quick start guide with dependencies |
34
+ | `get_gradle_config` | Android Gradle configuration |
35
+ | `get_license_info` | License initialization code |
36
+ | `get_api_usage` | Usage examples for specific APIs |
37
+ | `search_samples` | Search samples by keyword |
38
+ | `generate_project` | Generate a complete project structure based on a sample |
39
+
40
+
41
+ ## MCP Client Configuration
42
+
43
+ ### OpenCode
44
+ Location:
45
+ - **macOS**: `~/.config/opencode/opencode.json`
46
+ - **Windows**: `%USERPROFILE%\.config\opencode\opencode.json`
47
+
48
+ Configuration:
49
+ ```json
50
+ {
51
+ "$schema": "https://opencode.ai/config.json",
52
+ "mcp": {
53
+ "dynamsoft": {
54
+ "type": "local",
55
+ "command": [
56
+ "npx",
57
+ "simple-dynamsoft-mcp"
58
+ ]
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### Claude Desktop
65
+
66
+ Location:
67
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
68
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
69
+
70
+ Configuration:
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "dynamsoft": {
75
+ "command": "npx",
76
+ "args": ["-y", "simple-dynamsoft-mcp"]
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### VS Code with GitHub Copilot
83
+
84
+ Global Location:
85
+
86
+ - **macOS**: `~/.mcp.json`
87
+ - **Windows**: `%USERPROFILE%\.mcp.json`
88
+
89
+ ```json
90
+ {
91
+ "servers": {
92
+ "dynamsoft": {
93
+ "command": "npx",
94
+ "args": ["-y", "simple-dynamsoft-mcp"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ Or create workspace-specific `.vscode/mcp.json`:
101
+
102
+ ```json
103
+ {
104
+ "servers": {
105
+ "dynamsoft": {
106
+ "command": "npx",
107
+ "args": ["-y", "simple-dynamsoft-mcp"]
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ ### Cursor
114
+
115
+ Location:
116
+ - **macOS**: `~/.cursor/mcp.json`
117
+ - **Windows**: `%USERPROFILE%\.cursor\mcp.json`
118
+
119
+ Configuration:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "dynamsoft": {
125
+ "command": "npx",
126
+ "args": ["-y", "simple-dynamsoft-mcp"]
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### Windsurf
133
+
134
+ Location:
135
+
136
+ - **macOS**: `~/.codeium/windsurf/mcp_config.json`
137
+ - **Windows**: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "dynamsoft": {
143
+ "command": "npx",
144
+ "args": ["-y", "simple-dynamsoft-mcp"]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+
151
+ ### Alternative: Run from Local Clone
152
+
153
+ If you prefer running from source:
154
+
155
+ ```json
156
+ {
157
+ "command": "node",
158
+ "args": ["/absolute/path/to/simple-dynamsoft-mcp/src/index.js"]
159
+ }
160
+ ```
161
+
162
+ ## Supported SDKs
163
+
164
+ ### Dynamsoft Barcode Reader Mobile (v11.2.5000)
165
+
166
+ **Platforms:** Android, iOS, Flutter, React Native, .NET MAUI
167
+
168
+ **API Levels:**
169
+ - **High-Level (BarcodeScanner)**: Simple ready-to-use barcode scanning UI
170
+ - **Low-Level (CaptureVisionRouter)**: Full control over the scanning pipeline
171
+
172
+ **Android Samples:**
173
+ - ScanSingleBarcode, ScanMultipleBarcodes, ScenarioOrientedSamples
174
+ - DecodeWithCameraEnhancer, DecodeWithCameraX, DecodeFromAnImage
175
+ - GeneralSettings, DriversLicenseScanner, TinyBarcodeDecoding, ReadGS1AI
176
+
177
+ **iOS Samples:**
178
+ - ScanSingleBarcode, ScanMultipleBarcodes, ScanSingleBarcodeSwiftUI
179
+ - DecodeWithCameraEnhancer, DecodeWithAVCaptureSession, DecodeFromAnImage
180
+
181
+ ### Dynamsoft Barcode Reader Python (v11.2.5000)
182
+
183
+ **Installation:** `pip install dynamsoft-barcode-reader-bundle`
184
+
185
+ **Samples:**
186
+ - `read_an_image` - Decode barcodes from image files
187
+ - `video_decoding` - Real-time video decoding
188
+
189
+ ### Dynamsoft Barcode Reader Web (v11.2.4000)
190
+
191
+ **Installation:** `npm install dynamsoft-barcode-reader-bundle`
192
+
193
+ **CDN:** `https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.2.4000/dist/dbr.bundle.min.js`
194
+
195
+ ### Dynamic Web TWAIN (v19.3)
196
+
197
+ **Installation:** `npm install dwt`
198
+
199
+ **CDN:** `https://cdn.jsdelivr.net/npm/dwt@latest/dist/dynamsoft.webtwain.min.js`
200
+
201
+ **Sample Categories:**
202
+ - **scan** - Basic document scanning (basic-scan, read-barcode, etc.)
203
+ - **input-options** - Load from files, URLs, local drive
204
+ - **output-options** - Save, upload, convert to PDF/Base64/Blob
205
+ - **classification** - Document classification and tagging
206
+ - **UI-customization** - Customize viewer and scan UI
207
+
208
+ ## Trial License
209
+ https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform
210
+
211
+ ## Example AI Prompts
212
+
213
+ After connecting the MCP server, you can ask your AI assistant:
214
+
215
+ ### Mobile Barcode Scanner
216
+ - "Create an Android app that scans a single barcode"
217
+ - "Show me how to use CaptureVisionRouter in iOS Swift"
218
+ - "Get the Gradle configuration for Dynamsoft Barcode Reader"
219
+ - "How do I initialize the Dynamsoft license in Kotlin?"
220
+
221
+ ### Python Barcode Reader
222
+ - "Show me how to read barcodes from an image in Python"
223
+ - "Get the Python sample for video decoding"
224
+
225
+ ### Dynamic Web TWAIN
226
+ - "Create a web page that scans documents from a TWAIN scanner"
227
+ - "Show me how to save scanned documents as PDF"
228
+ - "Get the DWT sample for reading barcodes from scanned documents"
229
+
230
+ ## SDK Documentation
231
+
232
+ - **Mobile Android**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/android/user-guide.html
233
+ - **Mobile iOS**: https://www.dynamsoft.com/barcode-reader/docs/mobile/programming/objectivec-swift/user-guide.html
234
+ - **Python**: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide.html
235
+ - **Web JavaScript**: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/index.html
236
+ - **Dynamic Web TWAIN**: https://www.dynamsoft.com/web-twain/docs/introduction/index.html
237
+
238
+ ## Code Snippet Structure
239
+
240
+ ```
241
+ code-snippet/
242
+ ├── dynamsoft-barcode-reader/
243
+ │ ├── android/
244
+ │ │ ├── BarcodeScannerAPISamples/ # High-level API
245
+ │ │ └── FoundationalAPISamples/ # Low-level API
246
+ │ ├── ios/
247
+ │ │ ├── BarcodeScannerAPISamples/
248
+ └── FoundationalAPISamples/
249
+ │ ├── python/
250
+ │ │ └── Samples/
251
+ │ └── web/
252
+ └── dynamic-web-twain/
253
+ ├── scan/
254
+ ├── input-options/
255
+ ├── output-options/
256
+ ├── classification/
257
+ └── UI-customization/
258
+ ```
259
+
260
+ ## Extending the Server
261
+
262
+ ### Add New Samples
263
+
264
+ Place new sample projects in the appropriate folder under `code-snippet/`.
265
+
266
+ ### Update SDK Info
267
+
268
+ Edit `data/dynamsoft_sdks.json` to update versions, docs URLs, or add new platforms.
269
+
270
+ ## License
271
+
272
+ MIT
@@ -0,0 +1,96 @@
1
+ from dynamsoft_barcode_reader_bundle import *
2
+ import cv2
3
+ import numpy as np
4
+ import queue
5
+ from utils import *
6
+
7
+
8
+ class FrameFetcher(ImageSourceAdapter):
9
+ def has_next_image_to_fetch(self) -> bool:
10
+ return True
11
+
12
+ def add_frame(self, imageData):
13
+ self.add_image_to_buffer(imageData)
14
+
15
+
16
+ class MyCapturedResultReceiver(CapturedResultReceiver):
17
+ def __init__(self, result_queue):
18
+ super().__init__()
19
+ self.result_queue = result_queue
20
+
21
+ def on_captured_result_received(self, captured_result):
22
+ self.result_queue.put(captured_result)
23
+
24
+
25
+ if __name__ == '__main__':
26
+ errorCode, errorMsg = LicenseManager.init_license(
27
+ "DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
28
+ if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_CACHE_USED:
29
+ print("License initialization failed: ErrorCode:",
30
+ errorCode, ", ErrorString:", errorMsg)
31
+ else:
32
+ vc = cv2.VideoCapture(0)
33
+ if not vc.isOpened():
34
+ print("Error: Camera is not opened!")
35
+ exit(1)
36
+
37
+ cvr = CaptureVisionRouter()
38
+ fetcher = FrameFetcher()
39
+ cvr.set_input(fetcher)
40
+
41
+ # Create a thread-safe queue to store captured items
42
+ result_queue = queue.Queue()
43
+
44
+ receiver = MyCapturedResultReceiver(result_queue)
45
+ cvr.add_result_receiver(receiver)
46
+
47
+ errorCode, errorMsg = cvr.start_capturing(
48
+ EnumPresetTemplate.PT_READ_BARCODES.value)
49
+
50
+ if errorCode != EnumErrorCode.EC_OK:
51
+ print("error:", errorMsg)
52
+
53
+ while True:
54
+ ret, frame = vc.read()
55
+ if not ret:
56
+ print("Error: Cannot read frame!")
57
+ break
58
+
59
+ fetcher.add_frame(convertMat2ImageData(frame))
60
+
61
+ if not result_queue.empty():
62
+ captured_result = result_queue.get_nowait()
63
+
64
+ items = captured_result.get_items()
65
+ for item in items:
66
+
67
+ if item.get_type() == EnumCapturedResultItemType.CRIT_BARCODE:
68
+ text = item.get_text()
69
+ location = item.get_location()
70
+ x1 = location.points[0].x
71
+ y1 = location.points[0].y
72
+ x2 = location.points[1].x
73
+ y2 = location.points[1].y
74
+ x3 = location.points[2].x
75
+ y3 = location.points[2].y
76
+ x4 = location.points[3].x
77
+ y4 = location.points[3].y
78
+ pts = np.array([(x1, y1), (x2, y2), (x3, y3), (x4, y4)], np.int32).reshape((-1, 1, 2))
79
+ cv2.drawContours(
80
+ frame, [pts], 0, (0, 255, 0), 2)
81
+
82
+ cv2.putText(frame, text, (x1, y1),
83
+ cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
84
+
85
+ del location
86
+
87
+ if cv2.waitKey(1) & 0xFF == ord('q'):
88
+ break
89
+ elif cv2.waitKey(1) & 0xFF == ord('c'):
90
+ cv2.imshow('Captured Image', frame)
91
+
92
+ cv2.imshow('frame', frame)
93
+
94
+ cvr.stop_capturing()
95
+ vc.release()
96
+ cv2.destroyAllWindows()