dynamsoft/barcode-reader-python-samples/dbr-python-sample-creator
Claude Code and agent skill by dynamsoft/barcode-reader-python-samples
- community
- ext:[{"type":"template","description":"Custom templates for code generation"}]
Checking that the SKILL.md file is still in the repository.
Use when implementing Python sample code using the Dynamsoft Barcode Reader SDK (`dynamsoft_barcode_reader_bundle` package). This skill covers all barcode reading use cases including 1D barcodes, QR codes, PDF417, DataMatrix, DPM barcodes, and any other barcode decoding scenario built on the DBR Python Edition. Use this skill whenever the user mentions Dynamsoft Barcode Reader, DBR, `dynamsoft_barcode_reader_bundle`, `CaptureVisionRouter` for barcode reading, barcode scanning with Dynamsoft, barcode decoding, or wants to create a Python sample that processes images to extract barcodes.
Install
npx vskill@latest install dynamsoft/barcode-reader-python-samples/dbr-python-sample-creatorSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
DBR Python Sample Creator
This skill helps you write Python sample code using the dynamsoft_barcode_reader_bundle SDK. The SDK provides a pipeline for barcode reading — orchestrated through a single central class called CaptureVisionRouter.
Before you start
read the appropriate reference files from the references/ directory alongside this SKILL.md to understand the API you're working with. The references are organized by module — only read what you need for the task at hand:
| Reference file | When to read | |
|---|---|---|
references/api-core.md | Always — contains foundational types, enums, geometry, ImageData, error codes | |
references/api-cvr.md | Always — CaptureVisionRouter, templates, settings, result receivers | |
references/api-dbr.md | Always — barcode reading API, barcode formats, result items, settings | |
references/api-utility.md | When the task involves batch processing, video, cross-frame filtering, or image I/O | |
references/api-license.md | Always — license initialization | |
references/sample-patterns.md | Always — canonical code patterns extracted from existing samples |
SDK Architecture Overview
The SDK follows a pipeline architecture centered around CaptureVisionRouter:
Key concepts:
- CaptureVisionRouter — The central orchestrator. Create an instance, optionally configure settings/templates, then call
capture()orcapture_multi_pages()to process images. - Templates — Define what the pipeline does. Use
EnumPresetTemplateconstants for common tasks, or load custom JSON templates for specialized scenarios. - Results — Processing returns a
CapturedResult(single image) orCapturedResultArray(multi-page). Extract barcode results usingget_decoded_barcodes_result().
Writing Samples: Step by Step
Every DBR Python sample follows this structure. Understanding this flow is essential because deviating from it leads to subtle bugs — for instance, forgetting to check the license error code will cause silent failures.
Step 1: Import
Always use the wildcard import — the package re-exports everything from all submodules:
For additional libraries (os, sys, cv2, Flask, etc.), import them separately as needed.
Step 2: Initialize License
License initialization must happen once, before creating any CaptureVisionRouter instance. The SDK returns a tuple of (error_code, error_message).
License string priority: Default hard-coded license string is "DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTEwNTI2NzQwMSJ9".
Required comment block: Every sample must include this 3-line comment block immediately before the init_license call. This comment is mandatory — never omit it. Adjust the quoted license string in the third line to match whichever license string is actually used in the code:
Full license initialization pattern:
Check against both EC_OK and EC_LICENSE_WARNING (warnings are non-fatal).
Step 3: Create CaptureVisionRouter
No arguments needed. If using a custom JSON template, load it right after:
Step 4: Process Images
There are three processing paradigms. Choose based on the use case:
A. Single-shot capture (simplest, for one image at a time)
The capture() method accepts multiple input types:
str— file pathbytes— file bytes in memoryImageData— SDK's own image classnumpy.ndarray— OpenCV/PIL array (BGR format from OpenCV, RGB from PIL)
B. Multi-page capture (for PDFs, TIFFs, or any file)
This is the preferred method for file-based processing because it handles multi-page files correctly. Even for single-page images it works fine — you'll just get one result.
C. Continuous/streaming capture (for video or batch directories)
This uses the observer pattern with ImageSourceAdapter, CapturedResultReceiver, and optionally ImageSourceStateListener:
Step 5: Extract Results
After capturing, extract barcode results. Always check for errors first:
Note: EC_UNSUPPORTED_JSON_KEY_WARNING is a warning, not a fatal error — print a warning but continue processing.
Barcode results:
Preset Templates Quick Reference
| Template | Use for | |
|---|---|---|
PT_READ_BARCODES | General barcode reading | |
PT_READ_BARCODES_SPEED_FIRST | Fast barcode reading (sacrifices accuracy) | |
PT_READ_BARCODES_READ_RATE_FIRST | Max accuracy barcode reading | |
PT_READ_SINGLE_BARCODE | Optimized for exactly one barcode |
Custom JSON Templates
When preset templates don't meet requirements, create a custom JSON template. The template structure has these top-level arrays:
Load custom templates with:
Settings Customization via API
For simpler adjustments (without JSON templates), use the simplified settings API:
Multi-page Result Handling
When using capture_multi_pages(), results come as a CapturedResultArray. Use this pattern to handle page numbers correctly:
Advanced Patterns
Video/Camera Decoding
For real-time video, subclass ImageSourceAdapter to feed frames, and use CapturedResultReceiver for async results. Also consider MultiFrameResultCrossFilter for deduplication:
Intermediate Results
For advanced scenarios like visualizing barcode localization vs decoding, use IntermediateResultReceiver:
Image I/O and Drawing
Server-Side (Flask)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dbr-python-sample-creator/SKILL.md
Popularity
- Repository stars
- 52
- Repository forks
- 21
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
templateCustom templates for code generation
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dynamsoft/barcode-reader-python-samples/dbr-python-sample-creator)