### Installation Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/python/user-guide-v9.6 Install the Dynamsoft Barcode Reader SDK using pip. ```APIDOC ## Installation Start terminal or command prompt to run the following command: ``` pip install dbr ``` ``` -------------------------------- ### Getting Started with C Language Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide This section details the requirements, installation process, and steps to build your first barcode reading application using C language with the Dynamsoft Barcode Reader SDK. ```APIDOC ## Getting Started with C Language This guide will walk you through building a barcode reading application with Dynamsoft Barcode Reader SDK using C language. ### Requirements * **Operating System**: * Windows 7, 8, 10, 11, 2003, 2008, 2008 R2, 2012, 2016, 2019, 2022 * Linux x64: Ubuntu 14.04.4+ LTS, Debian 8+, etc. * Linux arm 32bit * Linux arm 64bit * MacOS 64bit: 10.12+ (contact for SDK) * **Developing Tool**: * Visual Studio 2008 or above * GCC 5.4+ ### Installation 1. Download the `C/C++ Package` from the Dynamsoft website. 2. Unpack the package into a directory of your choice (e.g., `[INSTALLATION FOLDER]`). ### Build Your First Application Create a console application to read barcodes from an image file. #### Create a New Project * **For Windows**: 1. Open Visual Studio. 2. Go to File > New > Project. 3. Create a new Empty Project named `DBRCSample`. 4. Add a source file named `DBRCSample.c`. * **For Linux/ARM/Mac**: 1. Create a source file named `DBRCSample.c`. 2. Place it in the `[INSTALLATION FOLDER]/Samples` directory. ### Include the Library Add the following to your `DBRCSample.c` file: ```c #include #include "[INSTALLATION FOLDER]/Include/DynamsoftBarcodeReader.h" #if defined(_WIN64) || defined(_WIN32) #ifdef _WIN64 #pragma comment(lib, "[INSTALLATION FOLDER]/Lib/Windows/x64/DBRx64.lib") #else #pragma comment(lib, "[INSTALLATION FOLDER]/Lib/Windows/x86/DBRx86.lib") #endif #endif ``` ### Initialize a Barcode Reader Instance 1. **Initialize the license key**: ```c int errorCode = 0; char szErrorMsg[512]; errorCode = DBR_InitLicense("", szErrorMsg, 512); if (errorCode != DBR_OK) { // Handle license error printf("%s\n", szErrorMsg); } ``` * Replace `` with your actual DBR license key. * Obtain a license key from `[INSTALLATION FOLDER]/Samples/BarcodeReaderDemo/BarcodeReaderDemo.cpp` or request a trial license from the Customer Portal. 2. **Create an instance of Dynamsoft Barcode Reader**: ```c void* dbr = DBR_GetInstance(); if(dbr != NULL) { // Perform barcode decoding and result processing // ... DBR_RecycleInstance(dbr); } ``` ### Configure the Barcode Scanning Behavior 1. **Set barcode format and count**: ```c char szErrorMsg[512]; PublicRuntimeSettings settings; DBR_GetRuntimeSettings(dbr, &settings); settings.barcodeFormatIds = BF_PDF417; settings.barcodeFormatIds_2 = BF2_DOTCODE; settings.expectedBarcodesCount = 2; DBR_UpdateRuntimeSettings(dbr, &settings, szErrorMsg, 512); ``` * Specify `barcodeFormatIds` and `barcodeFormatIds_2` for the formats you need to scan. * Set `expectedBarcodesCount` to optimize performance and accuracy if the count is known. * Refer to the Barcode Format Enumeration for a full list of supported formats. * Explore the RuntimeSettings API and Explore Features pages for detailed configuration options. ``` -------------------------------- ### Installation Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/python/user-guide-v9.0 Install the Dynamsoft Barcode Reader SDK using pip. ```APIDOC ## Installation Start terminal or command prompt to run the following command: ```python pip install dbr ``` ``` -------------------------------- ### Getting Started with DBR Java Edition Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/java Details the system requirements and guides users on how to get started with the Dynamsoft Barcode Reader Java Edition by following the User Guide. ```APIDOC ## Getting Started with DBR Java Edition The best way to start with the Dynamsoft Barcode Reader Java Edition is by following the `User Guide` to build your first barcode reading application. ### System Requirements * **Operating Systems:** * Windows: Windows 8 and higher, or Windows Server 2012 and higher * Linux x64 (Ubuntu 14.04.4+ LTS, Debian 8+, CentOS 7+, etc.) * Linux arm 64bit * macOS universal 10.15+ * **JDK:** 1.8 and above * **Embedded Devices:** Recommended performance equivalent to or better than a Raspberry Pi 4 Model B (4GB RAM). Minimum recommended specs: Quad-core ARM Cortex-A72 processor (or equivalent), 4 GB RAM, Linux-based OS. ``` -------------------------------- ### Install Dynamsoft Barcode Reader SDK for Python Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide Installs the Dynamsoft Barcode Reader SDK bundle for Python using pip. This is the first step to start using the SDK in your Python project. ```bash pip install dynamsoft-barcode-reader-bundle ``` -------------------------------- ### Build Sample Project on Linux (g++) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/cplusplus/user-guide-v7.6 Compiles the C++ barcode reader sample project on Linux using g++. This command links the Dynamsoft Barcode Reader library and sets the runtime library path. Ensure the library paths (`../Lib/Linux`) are correct for your setup. ```cpp g++ -o DBRCPPSample DBRCPPSample.cpp -lDynamsoftBarcodeReader -L ../Lib/Linux -Wl,-rpath=../Lib/Linux -std=c++11 ``` -------------------------------- ### Initialize Dynamsoft Barcode Reader License in C++ Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/cplusplus/user-guide-v7.6 Demonstrates the process of initializing the Dynamsoft Barcode Reader SDK with a license key. Includes error handling for failed license initialization. ```cpp int errorCode = 0; char errorBuf[512]; errorCode = CBarcodeReader::InitLicense("", errorBuf, 512); if (errorCode != DBR_OK) { // Add your code for license error processing; cout << errorBuf << endl; } ``` -------------------------------- ### Hello World Example - Barcode Reader in Electron Source: https://www.dynamsoft.com/barcode-reader/docs/v10/web/programming/javascript/samples-demos This 'Hello World' example shows how to implement Dynamsoft Barcode Reader within an Electron application. It covers the basic setup for decoding an image file in a desktop environment. Ensure you have Electron and the SDK installed. ```javascript const Dynamsoft = require('dynamsoft-javascript-barcode'); Dynamsoft.DBR.BarcodeReader.createInstance().then(reader => { reader.decodeFile("path/to/your/image.png").then(results => { console.log("Detected barcodes:", results); }); }); ``` -------------------------------- ### Example Output of Barcode Detection in Python Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide Example console output demonstrating the detection of two barcodes, showing their format and text content after running the Python script. ```text Decoded 2 barcodes Result 1 Barcode Format: XXX Barcode Text: XXX Result 2 Barcode Format: XXX Barcode Text: XXX ``` -------------------------------- ### Host SDK Yourself Source: https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/user-guide/index-v9.3 Guides on downloading the SDK and hosting its files locally or on a commercial CDN, with examples for different inclusion methods. ```APIDOC ## Host SDK Yourself ### Description Download the SDK and host its files on your own server or a commercial CDN. You can also install it via npm or yarn. ### Installation #### npm ```bash npm i dynamsoft-javascript-barcode -E ``` #### yarn ```bash yarn add dynamsoft-javascript-barcode -E ``` ### Inclusion Examples #### Local Hosting ```html ``` #### ES Modules Import ```javascript import { BarcodeScanner } from 'dynamsoft-javascript-barcode'; ``` ### Important Notes - Ensure your web server correctly handles the `.wasm` mimetype as `application/wasm`. - Set a long `Cache-Control: max-age=31536000` for engine files to improve performance. ``` -------------------------------- ### Dynamsoft Barcode Reader - Hello World Example Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide This section details the 'Hello World' example for Dynamsoft Barcode Reader, showcasing how to initialize the SDK, set up a camera view, and decode barcodes in real-time. ```APIDOC ## GET /websites/dynamsoft-barcode-reader/hello-world ### Description Provides a complete HTML and JavaScript example for setting up and running the Dynamsoft Barcode Reader to scan barcodes from a live camera feed. ### Method GET ### Endpoint /websites/dynamsoft-barcode-reader/hello-world ### Parameters None ### Request Example None ### Response #### Success Response (200) - **HTML Content** (string) - The full HTML structure and JavaScript code for the 'Hello World' example. #### Response Example ```html
``` ``` -------------------------------- ### Run Python Barcode Reader Sample Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/python/user-guide-v9.0 Executes the Dynamsoft Barcode Reader Python sample script from the terminal. Ensure you have Python installed and have navigated to the directory containing DBRPythonSample.py. ```python python DBRPythonSample.py ``` -------------------------------- ### Getting Started with DBR Python Edition Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python Follow the User Guide to build your first barcode reading application with the Dynamsoft Barcode Reader Python Edition. ```APIDOC ## Getting Started with DBR Python Edition The best way to start with the Dynamsoft Barcode Reader Python Edition, is following the `User Guide` to build your first barcode reading application. ### System Requirements * **Operating Systems:** * Windows x64 * Linux x64, ARM 64-bit, ARM 32-bit (for versions below DBR 9.6.40.2) * macOS (10.15+) * **Python Versions:** * Python 3.13 * Python 3.12 * Python 3.11 * Python 3.10 * Python 3.9 * Python 3.8 * Python 3.7 (for versions below DBR 9.6.40.2) * Python 3.6 (for versions below DBR 9.6.40.2) * Python 2.7 (for versions below DBR 7.2.2.3) * **For Embedded Devices:** For embedded or ARM-based platforms, we recommend using a device with performance equivalent to or better than a Raspberry Pi 4 Model B (4GB RAM). Minimum recommended specs: * Quad-core ARM Cortex-A72 processor (or equivalent) * 4 GB RAM * Linux-based OS (e.g., Raspberry Pi OS, Ubuntu Server) ``` -------------------------------- ### Install Dynamsoft Barcode Reader Python SDK Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/python/user-guide Installs the Dynamsoft Barcode Reader SDK for Python using pip. This is the initial step to integrate barcode reading capabilities into your Python application. ```bash pip install dbr ``` -------------------------------- ### Initializing Dynamsoft Barcode Reader License in Java Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/java/user-guide-v9.6 This code demonstrates the initialization of the Dynamsoft Barcode Reader SDK with a license key. Replace the placeholder with your actual license key. Proper license initialization is crucial for SDK functionality. ```java BarcodeReader.initLicense(""); ``` -------------------------------- ### Include Dynamsoft Barcode Reader SDK via CDN (jsDelivr) Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner This snippet shows how to include the Dynamsoft Barcode Reader SDK in your HTML file using a precompiled script from the jsDelivr CDN. This is a simple way to get started without managing local files. ```html ``` -------------------------------- ### Initialize Dynamsoft Barcode Reader License (C) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v8.6 This code demonstrates how to initialize the Dynamsoft Barcode Reader SDK with a license key. It includes error handling for invalid license keys and provides guidance on obtaining a license. ```c int errorCode = 0; char szErrorMsg[512]; errorCode = DBR_InitLicense("", szErrorMsg, 512); if (errorCode != DBR_OK) { // Add your code for license error processing; printf("%s\n", szErrorMsg); } ``` -------------------------------- ### Build Sample Project on Linux/ARM/Mac (C) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v8.6 Compiles the sample project using GCC on Linux, ARM, or Mac systems. It links the `DynamsoftBarcodeReader` library and specifies the library path using `-L` and runtime path using `-Wl,-rpath`. ```c gcc -o DBRCSample DBRCSample.c -lDynamsoftBarcodeReader -L ../Lib/Linux -Wl,-rpath=../Lib/Linux ``` -------------------------------- ### Create and Recycle Barcode Reader Instance (C) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v8.6 This snippet shows the process of creating an instance of the Dynamsoft Barcode Reader and the subsequent step of recycling it to release resources. It's a fundamental part of using the SDK. ```c void* dbr = DBR_GetInstance(); if(dbr != NULL) { // Add your code here to call decoding method, process barcode results and so on // ... DBR_RecycleInstance(dbr); } ``` -------------------------------- ### Install Dependencies for Vue 3 Project Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/helloworld-vuejsv3_ver=9.6 Installs the necessary project dependencies and the Dynamsoft Barcode Reader JavaScript library. These commands ensure the project has all required packages to run and integrate the SDK. ```bash npm install npm install dynamsoft-javascript-barcode ``` -------------------------------- ### Start Barcode Capturing Process Source: https://www.dynamsoft.com/barcode-reader/docs/v10/server/programming/python/user-guide Initiates the barcode capturing process for all images in the configured input source. Handles potential errors during startup. ```python errorCode, errorMsg = cvr_instance.start_capturing("", True) if errorCode != EnumErrorCode.EC_OK: print("error:", errorMsg) ``` -------------------------------- ### Include Dynamsoft Barcode Reader SDK C++ Libraries Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/user-guide This code snippet demonstrates how to include the necessary header files and link the required libraries for the Dynamsoft Barcode Reader SDK in a C++ project. It handles both 32-bit and 64-bit Windows environments by using conditional compilation and pragma directives for library linking. Ensure the `[INSTALLATION FOLDER]` is replaced with the actual path to your SDK installation. ```cpp #include #include #include "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Include/DynamsoftCaptureVisionRouter.h" using namespace std; using namespace dynamsoft::license; using namespace dynamsoft::cvr; using namespace dynamsoft::dbr; #if defined(_WIN64) || defined(_WIN32) #ifdef _WIN64 #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x64/DynamsoftCorex64.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x64/DynamsoftLicensex64.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x64/DynamsoftCaptureVisionRouterx64.lib") #else #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x86/DynamsoftCorex86.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x86/DynamsoftLicensex86.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Dist/Lib/Windows/x86/DynamsoftCaptureVisionRouterx86.lib") #endif #endif ``` -------------------------------- ### Hello World - C++ Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index_ver=latest A basic 'Hello World' example demonstrating the use of the Dynamsoft Barcode Reader C++ SDK. This sample is intended for desktop or server-side applications. It covers the fundamental steps for initializing the reader and decoding an image. ```cpp #include #include "dbr.h" // Assuming dbr.h is the header file for the SDK int main() { // Initialize the BarcodeReader Dynamsoft::DBR::Reader* reader = Dynamsoft::DBR::Reader::CreateInstance(); if (!reader) { std::cerr << "Failed to create reader instance." << std::endl; return -1; } // Load image (replace with actual image loading) // Assume 'imageData' is a pointer to image data and 'width', 'height', 'stride' are dimensions // Example: Dynamsoft::DBR::ImageData* imgData = Dynamsoft::DBR::ImageData::Create(imageData, width, height, stride, EnumImagePixelFormat_IPF_BGR888); // Decode barcodes // Dynamsoft::DBR::TextReadableVector results; // int ret = reader->Decode(imgData, "default", &results); // if (ret == 0 && !results.empty()) { // std::cout << "Barcode found: " << results[0]->text << std::endl; // } else { // std::cout << "No barcode found." << std::endl; // } // Clean up // imgData->Destroy(); // If created with Create reader->Destroy(); std::cout << "Hello World from Dynamsoft Barcode Reader C++!" << std::endl; return 0; } ``` -------------------------------- ### Compile and Run Java Project with Maven Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/java/user-guide This command demonstrates how to compile and run a Java project using Maven. It specifies the main class to execute, which is useful for packaging and deploying Java applications that use the Dynamsoft Barcode Reader. Ensure Maven is installed and configured in your environment. ```bash mvn compile exec:java -Dexec.mainClass="ReadAnImage" ``` -------------------------------- ### Configuring Barcode Formats and Count in Java Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/java/user-guide-v9.6 This code example shows how to configure runtime settings for the Dynamsoft Barcode Reader, specifically setting the barcode formats to be detected and the expected number of barcodes. This optimization can improve scanning performance and accuracy. ```java PublicRuntimeSettings runtimeSettings = reader.getRuntimeSettings(); runtimeSettings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE; runtimeSettings.barcodeFormatIds_2 = EnumBarcodeFormat_2.BF2_POSTALCODE | EnumBarcodeFormat_2.BF2_DOTCODE; runtimeSettings.expectedBarcodesCount = 10; reader.updateRuntimeSettings(runtimeSettings); ``` -------------------------------- ### Initialize License and Barcode Reader Instance Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v9.6 This section covers initializing the license key and creating an instance of the Dynamsoft Barcode Reader. ```APIDOC ## Initialize License and Barcode Reader Instance ### Description Initialize the license key and create an instance of Dynamsoft Barcode Reader. Ensure you have a valid license key. ### Method N/A (Code Example) ### Endpoint N/A ### Parameters None ### Request Example ```c int errorCode = 0; char szErrorMsg[512]; errorCode = DBR_InitLicense("", szErrorMsg, 512); if (errorCode != DBR_OK) { // Add your code for license error processing; printf("%s\n", szErrorMsg); } void* dbr = DBR_GetInstance(); if(dbr != NULL) { // Add your code here to call decoding method, process barcode results and so on // ... DBR_RecycleInstance(dbr); } ``` ### Response #### Success Response (0) - **errorCode** (int) - Indicates success (DBR_OK). - **dbr** (void*) - Pointer to the initialized Barcode Reader instance. #### Response Example ```json { "errorCode": 0, "dbr": "" } ``` ``` -------------------------------- ### Start Barcode Capturing Process Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/user-guide Initiates the barcode capturing process for all images in the configured input source. It includes basic error handling for the start operation. ```python errorCode, errorMsg = cvr_instance.start_capturing("", True) if errorCode != EnumErrorCode.EC_OK: print("error:", errorMsg) ``` -------------------------------- ### Hello World - Python Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index_ver=latest A 'Hello World' example for the Dynamsoft Barcode Reader Python SDK. This sample is suitable for server-side applications or scripts. It covers the essential steps for initializing the reader and decoding an image. ```python from dbr import BarcodeReader, EnumImagePixelFormat def main(): try: # Initialize the BarcodeReader with your license key reader = BarcodeReader("your_license_key") # Load image (replace with actual image loading) # Example: results = reader.decode_file("path/to/your/image.png") # Decode barcodes # if results: # print(f"Barcode found: {results[0].barcode_format_string} - {results[0].text}") # else: # print("No barcode found.") print("Hello World from Dynamsoft Barcode Reader Python!") except Exception as e: print(f"An error occurred: {e}") if __name__ == "__main__": main() ``` -------------------------------- ### Hello World - .NET Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index_ver=latest A 'Hello World' example for using the Dynamsoft Barcode Reader .NET SDK. This sample is suitable for Windows desktop or server applications. It covers the basic initialization and barcode decoding process. ```csharp using System; using Dynamsoft.Barcode; public class BarcodeReaderExample { public static void Main(string[] args) { // Initialize the BarcodeReader using (BarcodeReader reader = new BarcodeReader()) { // Load image (replace with actual image loading) // Example: reader.LoadImage("path/to/your/image.png"); // Decode barcodes // BarcodeResult[] results = reader.Decode(); // if (results.Length > 0) // { // Console.WriteLine($"Barcode found: {results[0].BarcodeFormatString} - {results[0].Text}"); // } // else // { // Console.WriteLine("No barcode found."); // } } Console.WriteLine("Hello World from Dynamsoft Barcode Reader .NET!"); } } ``` -------------------------------- ### Install Dynamsoft Barcode Reader Bundle (Python) Source: https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/upgrade-instruction This command installs the Dynamsoft Barcode Reader bundle, which has been renamed from `dbr` starting from version 10.0. This is recommended for upgrading from version 9.x or earlier. ```bash pip install dynamsoft-barcode-reader-bundle ``` -------------------------------- ### Build Your First Application - HelloWorld Example Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/objectivec-swift/user-guide-v9.6 Guidance on creating a 'HelloWorld' application for scanning barcodes from camera video input using the iOS SDK. ```APIDOC ## Build Your First Application In this section, let’s create a **HelloWorld** app for reading barcodes from camera video input. > Note: > * XCode 13.0 is used here in this guide. > * You can download the complete Objective-C source code from Objective-C HelloWorld Sample > * You can download the complete Swift source code from Swift HelloWorld Sample > * DCE is used for camera capture in this guide below. If you use the iOS AVFoundation framework for camera capture, check DecodeWithAVCaptureSession sample on how to add barcode scanning to your app. > ``` -------------------------------- ### Hello World - Java Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index_ver=latest A 'Hello World' example for the Dynamsoft Barcode Reader Java SDK. This sample is intended for Java applications on desktop or server environments. It demonstrates basic SDK initialization and image decoding. ```java import com.dynamsoft.dbr.*; public class BarcodeReaderHelloWorld { public static void main(String[] args) { try { // Initialize the BarcodeReader BarcodeReader reader = new BarcodeReader("your_license_key"); // Replace with your license key // Load image (replace with actual image loading) // Example: reader.loadImage("path/to/your/image.png"); // Decode barcodes // TextResult[] results = reader.decode(); // if (results.length > 0) { // System.out.println("Barcode found: " + results[0].getFormatString() + " - " + results[0].getText()); // } else { // System.out.println("No barcode found."); // } reader.destroy(); System.out.println("Hello World from Dynamsoft Barcode Reader Java!"); } catch (Exception e) { e.printStackTrace(); } } } ``` -------------------------------- ### Get and Output Barcode Results (C) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v8.6 Retrieves all detected barcode results from an image. It uses `DBR_GetAllTextResults` to get an array of `TextResult` structures, which contain information like barcode format, text, and location. The code iterates through the results and prints key details. ```c TextResultArray* barcodeResults = NULL; DBR_GetAllTextResults(dbr, &barcodeResults); if (barcodeResults != NULL && barcodeResults->resultsCount > 0) { printf("%d total barcode(s) found. \n", barcodeResults->resultsCount); for (int index = 0; index < barcodeResults->resultsCount; index++) { printf("Result %d\n", index + 1); printf(" Barcode Format: %s\n", barcodeResults->results[index] ->barcodeFormatString); printf(" Barcode Text: %s \n", barcodeResults->results[index] ->barcodeText); } } ``` -------------------------------- ### Build UI from Scratch and Connect to SDK (JavaScript) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/user-guide/index-v7.5 This example illustrates building a UI element from scratch and connecting it to the Dynamsoft Barcode Scanner SDK using the `setUIElement` API. It includes setting up the video container, event handlers for frame reads and unique reads, and showing the scanner. ```javascript
``` -------------------------------- ### Install Dynamsoft Barcode Reader using npm or yarn Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner This shows the commands to install the Dynamsoft Barcode Reader bundle as a project dependency using either npm or yarn. This is recommended when working with frameworks like React, Vue, or Angular. ```bash npm i dynamsoft-barcode-reader-bundle@11.0.6000 # or yarn add dynamsoft-barcode-reader-bundle@11.0.6000 ``` -------------------------------- ### Initialize Barcode Reader and Camera Enhancer (Java) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/android/user-guide-v7.6 Initializes the Dynamsoft Barcode Reader and binds it to a Camera Enhancer instance. This is a prerequisite for starting barcode scanning. Ensure necessary exceptions are handled. ```Java import com.dynamsoft.dbr.BarcodeReaderException; public class MainActivity extends AppCompatActivity { BarcodeReader mReader; @Override protected void onCreate(Bundle savedInstanceState) { ... try { mReader = new BarcodeReader(); } catch (BarcodeReaderException e) { e.printStackTrace(); } mReader.setCameraEnhancer(mCameraEnhancer); } } ``` -------------------------------- ### Include Dynamsoft Barcode Reader SDK from local path Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner This snippet illustrates how to include the Dynamsoft Barcode Reader SDK when it's hosted locally, either on your own server or a preferred CDN. This provides more control over versioning and availability. ```html ``` -------------------------------- ### Manage Video Scanning with onResume/onPause (Java) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/android/user-guide-v7.6 Controls the video barcode scanning process by starting and stopping the reader and camera enhancer in the `onResume` and `onPause` lifecycle methods. This ensures efficient resource usage. ```Java public class MainActivity extends AppCompatActivity { ... @Override public void onResume() { // Start video barcode reading mReader.startScanning(); try { mCameraEnhancer.open(); } catch (CameraEnhancerException e) { e.printStackTrace(); } super.onResume(); } @Override public void onPause() { // Stop video barcode reading mReader.stopScanning(); try { mCameraEnhancer.close(); } catch (CameraEnhancerException e) { e.printStackTrace(); } super.onPause(); } } ``` -------------------------------- ### Hello World in Blazor Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index A 'Hello World' example for integrating Dynamsoft Barcode Reader within a Blazor application. This demonstrates web SDK usage in a .NET environment. ```csharp // Placeholder for Blazor Hello World code example // Example: @using Dynamsoft.BarcodeReader // ``` -------------------------------- ### Dynamsoft Barcode Reader - Core Concepts Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide Explains key methods and concepts used within the Dynamsoft Barcode Reader SDK, such as license initialization, WASM loading, and Capture Vision Router. ```APIDOC ## API Reference - Dynamsoft Barcode Reader SDK ### `Dynamsoft.License.LicenseManager.initLicense()` #### Description Initializes the license for using the Dynamsoft SDK. An online license requires a network connection. #### Parameters - **licenseKey** (string) - The license string provided by Dynamsoft. #### Example ```javascript Dynamsoft.License.LicenseManager.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"); ``` ### `Dynamsoft.Core.CoreModule.loadWasm()` #### Description An optional method to load WebAssembly resources in advance, which can reduce latency during barcode decoding. #### Example ```javascript Dynamsoft.Core.CoreModule.loadWasm(); ``` ### `Dynamsoft.CVR.CaptureVisionRouter.createInstance()` #### Description Creates an instance of `CaptureVisionRouter`, which orchestrates the barcode decoding process. #### Returns - `Promise` - A promise that resolves with a `CaptureVisionRouter` object. #### Example ```javascript let cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance(); ``` #### `cvRouter.setInput(imageSourceAdapter)` ##### Description Connects the `CaptureVisionRouter` to an image source (e.g., camera, image file). ##### Parameters - **imageSourceAdapter** (ImageSourceAdapter) - An object implementing the `ImageSourceAdapter` interface. ##### Example ```javascript // Assuming cameraEnhancer is an instance of Dynamsoft.DCE.CameraEnhancer cvRouter.setInput(cameraEnhancer); ``` #### `cvRouter.startCapturing(presetTemplate)` ##### Description Starts the image capturing and processing. A preset template can be specified to define the decoding task. ##### Parameters - **presetTemplate** (string) - The name of the preset template (e.g., "ReadSingleBarcode"). ##### Example ```javascript await cvRouter.startCapturing("ReadSingleBarcode"); ``` #### `cvRouter.addResultReceiver(capturedResultReceiver)` ##### Description Registers an object that will receive the decoding results. ##### Parameters - **capturedResultReceiver** (CapturedResultReceiver) - An object that implements the `CapturedResultReceiver` interface, typically with methods like `onDecodedBarcodesReceived`. ##### Example ```javascript cvRouter.addResultReceiver({ onDecodedBarcodesReceived: (result) => { /* handle results */ } }); ``` #### `cvRouter.addResultFilter(filter)` ##### Description Adds a filter to process or deduplicate results. Useful for managing frequent or duplicate barcode detections. ##### Parameters - **filter** (MultiFrameResultCrossFilter) - An instance of `MultiFrameResultCrossFilter` or a similar filter object. ##### Example ```javascript let filter = new Dynamsoft.Utility.MultiFrameResultCrossFilter(); filter.enableResultCrossVerification("barcode", true); filter.enableResultDeduplication("barcode", true); await cvRouter.addResultFilter(filter); ``` ``` -------------------------------- ### Initialize Dynamsoft Barcode Scanner (Basic) Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide/barcode-scanner This JavaScript code initializes the Dynamsoft Barcode Scanner with a required license key. Ensure you replace 'YOUR_LICENSE_KEY_HERE' with your actual license. ```javascript // Initialize the Dynamsoft Barcode Scanner const barcodescanner = new Dynamsoft.BarcodeScanner({ // Please don't forget to replace YOUR_LICENSE_KEY_HERE license: "YOUR_LICENSE_KEY_HERE", }); ``` -------------------------------- ### Display Barcode Results in Android TextView Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/android/user-guide-v7.6 This snippet shows how to define a TextView in XML to display barcode results and how to update it with the scanned data in both Java and Kotlin. ```xml ``` ```java public class MainActivity extends AppCompatActivity { ... TextView tvRes; @Override protected void onCreate(Bundle savedInstanceState) { ... // Add TextView to display recognized barcode results. tvRes = findViewById(R.id.tv_res); } private void showResult(TextResult[] results) { if (results != null && results.length > 0) { String strRes = ""; for (int i = 0; i < results.length; i++) strRes += results[i].barcodeText + "\n\n"; tvRes.setText(strRes); } else { tvRes.setText(""); } } } ``` ```kotlin class MainActivityKt : AppCompatActivity() { private fun showDialog( title: String, message: String, listener: DialogInterface.OnClickListener? ) { val dialog = AlertDialog.Builder(this) alertDialog = dialog.setTitle(title).setPositiveButton("OK", listener) .setMessage(message) .setCancelable(false) .show() } private fun showResult(results: Array?){ var strRes = ""; if(results != null && results.isNotEmpty()){ DCEFeedback.vibrate(this) mReader.stopScanning() for(i in results.indices){ strRes += results[i].barcodeText } if (alertDialog != null && alertDialog!!.isShowing) { return } showDialog("Result", strRes){ _, _ -> mReader.startScanning()} } } } ``` -------------------------------- ### Hello World Example - Barcode Reader JavaScript Edition Source: https://www.dynamsoft.com/barcode-reader/docs/v10/web/programming/javascript/samples-demos A basic 'Hello World' example demonstrating the initialization and usage of the Dynamsoft Barcode Reader JavaScript Edition. This snippet is intended for quick integration and understanding of core functionalities. No external libraries are strictly required beyond the SDK itself. ```javascript Dynamsoft.DBR.BarcodeReader.createInstance().then(reader => { reader.updateRuntimeSettings("{"version":"3.0","knownQRCodeConfigurations":[],"customQRCodeConfigurations":[]}").then(() => { reader.decodeFile("YOUR_IMAGE_PATH_OR_URL").then(results => { console.log("Found barcodes:", results); }); }); }); ``` -------------------------------- ### Include Dynamsoft Barcode Reader SDK Headers and Libraries (C++) Source: https://www.dynamsoft.com/barcode-reader/docs/v10/server/programming/cplusplus/user-guide This snippet demonstrates how to include the necessary header files and link the required libraries for the Dynamsoft Barcode Reader SDK in a C++ project. It handles different architectures for Windows. Ensure the '[INSTALLATION FOLDER]' is replaced with the actual path to your SDK installation. ```cpp #include #include #include "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Include/DynamsoftCaptureVisionRouter.h" using namespace std; using namespace dynamsoft::license; using namespace dynamsoft::cvr; using namespace dynamsoft::dbr; #if defined(_WIN64) || defined(_WIN32) #ifdef _WIN64 #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Distributables/Lib/Windows/x64/DynamsoftLicensex64.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Distributables/Lib/Windows/x64/DynamsoftCaptureVisionRouterx64.lib") #else #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Distributables/Lib/Windows/x86/DynamsoftLicensex86.lib") #pragma comment(lib, "[INSTALLATION FOLDER]/DynamsoftBarcodeReader/Distributables/Lib/Windows/x86/DynamsoftCaptureVisionRouterx86.lib") #endif #endif ``` -------------------------------- ### Install Dynamsoft SDK components from npm for self-hosting Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/user-guide_ver=latest This command installs multiple Dynamsoft SDK components (Barcode Reader, Capture Vision, Image Processing) from npm for self-hosting. This approach requires additional setup, including copying packages and specifying engineResourcePaths, to ensure the SDK can locate its necessary engine files. ```bash npm i dynamsoft-barcode-reader-bundle@11.0.6000 -E # Compared with using CDN, you need to set up more resources. npm i dynamsoft-capture-vision-std@1.4.21 -E npm i dynamsoft-image-processing@2.4.31 -E ``` -------------------------------- ### Hello World - JavaScript Web SDK Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos/index_ver=latest A basic 'Hello World' example demonstrating the use of the Dynamsoft Barcode Reader JavaScript Web SDK. This sample is intended for web applications and showcases the fundamental initialization and decoding process. It requires the JavaScript SDK to be included in the project. ```javascript Barcode Reader JS Hello World

Dynamsoft Barcode Reader JS Hello World

Image with Barcode
``` -------------------------------- ### Release Barcode Results Memory (C) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/server/programming/c/user-guide-v8.6 Frees the memory allocated for the barcode results array. This function `DBR_FreeTextResults` should be called after the barcode results are no longer needed to prevent memory leaks. ```c if(barcodeResults != NULL) DBR_FreeTextResults(&barcodeResults); ``` -------------------------------- ### Register Barcode Result Listener (Java) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/android/user-guide-v7.6 Registers a listener to receive recognized barcode results. The callback provides decoded barcode information, which can then be displayed to the user. This is crucial for user feedback. ```Java import com.dynamsoft.dbr.ImageData; import com.dynamsoft.dbr.TextResult; import com.dynamsoft.dbr.TextResultListener; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { ... mReader.setTextResultListener(new TextResultListener() { // Obtain the recognized barcode results and display. @Override public void textResultCallback(int id, ImageData imageData, TextResult[] textResults) { (MainActivity.this).runOnUiThread(new Runnable() { @Override public void run() { showResult(textResults); } }); } }); } } ``` -------------------------------- ### Initialize Dynamsoft Barcode Reader Instance (Swift) Source: https://www.dynamsoft.com/barcode-reader/docs/v9/mobile/programming/objectivec-swift/user-guide-v7.6 Initializes an instance of DynamsoftBarcodeReader in Swift. This code snippet demonstrates the basic setup for the barcode reader. Ensure the DynamsoftBarcodeReader class is available in your project. ```swift var barcodeReader:DynamsoftBarcodeReader! = nil override func viewDidLoad() { super.viewDidLoad() configurationDBR() } func configurationDBR(){ /* Create the instance */ barcodeReader = DynamsoftBarcodeReader.init() /* You can add your barcode reader configurations here. */ } ``` -------------------------------- ### Hello World - JavaScript Source: https://www.dynamsoft.com/barcode-reader/docs/web/programming/javascript/samples-demos A basic 'Hello World' example for scanning barcodes using the JavaScript Web SDK. This demonstrates the fundamental setup and usage for web applications. ```javascript import { BarcodeScanner } from "@dynamsoft/dynamsoft-barcode-reader"; async function initScanner() { const scanner = await BarcodeScanner.createInstance(); await scanner.loadWasm(); console.log("BarcodeScanner initialized."); // Further operations like starting the camera or reading an image can be done here. // For example: scanner.updateRuntimeSettings({"barcodeFormatIds": ["BF_ALL"]}); // For example: const results = await scanner.decode(imageElement); // Remember to destroy the scanner when done: scanner.destroySTenInstance(); } ``` -------------------------------- ### Host SDK Yourself Source: https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/user-guide/index-v8.2 Instructions on downloading and hosting the Dynamsoft Barcode Reader SDK files on your own server or a commercial CDN. ```APIDOC ## Host SDK Yourself ### Description Download the SDK and host its files on your server or a commercial CDN. ### Installation Options #### npm ```bash npm i dynamsoft-javascript-barcode -E ``` #### yarn ```bash yarn add dynamsoft-javascript-barcode -E ``` ### Including the SDK Depending on your setup, you can include the SDK using script tags or ES module imports: #### Script Tag (Self-hosted) ```html ``` #### Script Tag (npm package) ```html ``` #### ES Module Import ```javascript import { BarcodeScanner } from 'dynamsoft-javascript-barcode'; ``` ### Engine File MIME Type Ensure your web server is configured to serve `.wasm` files with the `application/wasm` MIME type. For example, in Apache or Nginx, you might need to add or modify configurations. ```