010-68421378
sales@cogitosoft.com
产品分类
AddFlow  AmCharts JavaScript Stock Chart AmCharts 4: Charts Aspose.Total for Java Altova SchemaAgent Altova DatabaseSpy Altova MobileTogether Altova UModel  Altova MapForce Altova StyleVision Server Altova MapForce Server Altova Authentic Aspose.Total for .NET Altova RaptorXML Server ComponentOne Ultimate Chart FX for SharePoint Chart FX CodeCharge Studio ComponentOne Enterprise combit Report Server Combit List & Label 22 Controls for Visual C++ MFC Chart Pro for Visual C ++ MFC DbVisualizer version 12.1 DemoCharge DXperience Subscription .NET DevExpress Universal Subscription Essential Studio for ASP.NET MVC FusionCharts Suite XT FusionCharts for Flex  FusionExport V2.0 GrapeCity TX Text Control .NET for WPF GrapeCity Spread Studio Highcharts Gantt Highcharts 10.0 版 HelpNDoc Infragistics Ultimate  ImageKit9 ActiveX ImageKit.NET JetBrains--Fleet JetBrains-DataSpell JetBrains--DataGrip jQuery EasyUI jChart FX Plus Nevron Vision for .NET OPC DA .NET Server Toolkit  OSS ASN.1/C Oxygen XML Author  OSS 4G NAS/C, C++ Encoder Decoder Library OSS ASN.1 Tools for C with 4G S1/X2 OSS ASN.1/C# OSS ASN.1/JAVA OSS ASN.1/C++ OPC HDA .NET Server Toolkit OPC DA .Net Client Development Component PowerBuilder redgate NET Developer Bundle Report Control for Visual C++ MFC  Altova StyleVision Sencha Test Stimulsoft Reports.PHP Stimulsoft Reports.JS Stimulsoft Reports.Java Stimulsoft Reports. Ultimate Stimulsoft Reports.Wpf Stimulsoft Reports.Silverlight SPC Control Chart Tools for .Net SlickEdit Source Insight Software Verify .Net Coverage Validator Toolkit Pro for VisualC++MFC TeeChart .NET Telerik DevCraft Complete Altova XMLSpy Zend Server

Dynamsoft Barcode Reader C C++ API

在Windows里使用Dynamsoft Barcode Reader C++ API

在Windows桌面应用程序Dynamsoft的C ++条形码阅读器库为Windows允许你几乎立即嵌入一维和二维条码阅读功能。我将演示如何使用C ++条形码阅读API的Windows构建一个Win32控制台应用程序条形码识别。

开始一个新文件

新的控制台应用程序

首先,让我们打开Visual Studio。

通过Visual C ++> Win32创建一个空的Win32控制台应用程序项目。

让我们把它命名为BarcodeReaderC ++ API

添加引用

按照本指南,首先,引用.H和.LIB文件。 为了更容易,让我们从包含文件夹和lib文件夹从安装目录复制到项目。

在此处更改相对路径。

#include

#include "/If_DBRP.h"

#ifdef _WIN64

#pragma comment ( lib, "/x64/DBRx64.lib" )

#else

#pragma comment ( lib, "/x86/DBRx86.lib" )

#endif

复制主函数

接下来,将以下代码插入主函数。

 

//Define variables

const char * pszImageFile = "";

int iIndex = 0;

int iRet = -1;

       

//Initialize license prior to any decoding

CBarcodeReader reader;

reader.InitLicense("");

 

//Initialize ReaderOptions

ReaderOptions ro = {0};          

ro.llBarcodeFormat = OneD;   //Expected barcode types to read.

ro.iMaxBarcodesNumPerPage = 100;     //Expected barcode numbers to read.

reader.SetReaderOptions(ro);

 

//Start decoding

iRet = reader.DecodeFile(pszImageFile);

 

//If not DBR_OK

if (iRet != DBR_OK)

{

  printf("Failed to read barcode: %d\r\n%s\r\n",iRet, GetErrorString(iRet));

  return iRet;

}

 

//If DBR_OK

pBarcodeResultArray paryResult = NULL;

reader.GetBarcodes(&paryResult);

printf("%d total barcodes found. \r\n", paryResult->iBarcodeCount);

for (iIndex = 0; iIndex < paryResult->iBarcodeCount; iIndex++)

{

  printf("Result %d\r\n", iIndex + 1);

  printf("PageNum: %d\r\n", paryResult->ppBarcodes[iIndex]->iPageNum);

  printf("BarcodeFormat: %lld\r\n", paryResult->ppBarcodes[iIndex]->llFormat);

  printf("Text read: %s\r\n", paryResult->ppBarcodes[iIndex]->pBarcodeData);

}

 

//Finally release BarcodeResultArray

CBarcodeReader::FreeBarcodeResults(&paryResult);

升级源图片

改变图片路径。我将会用一个例子图片Change the image path. I am going to use a sample image from the installation folder. Copy the file path, add the escape character, and then the file name. Change the path to "C:\\Program Files (x86)\\Dynamsoft\\Barcode Reader 4.1\\Images\\AllSupportedBarcodeTypes.tif".

 

const char * pszImageFile = "C:\\Program Files (x86)\\Dynamsoft\\Barcode

 Reader 4.1\\Images\\AllSupportedBarcodeTypes.tif";

             

Build the project. Build Succeeded.

复制条码DLL

转到安装目录,在Components \ C_C ++ \ Redist文件夹下,复制这两个DLL - DynamsoftBarcodeReaderx86.dll和DynamsoftBarcodeReaderx64.dll。 将其粘贴到与BarcodeReaderC ++ API.exe相同的文件夹中,默认情况下,该文件位于解决方案的Debug文件夹下。

按Ctrl + F5运行项目。 好。 我们已经识别所有的条形码。

查看代码

现在,让我们快速浏览代码。 首先,我们定义包括图像路径的变量。 然后我们配置许可证信息。 使用此片段,我们初始化条形码阅读选项,如条形码类型,以及每页读取多少条形码。 调用DecodeFile方法来解码条形码。 如果找到多个条形码,我们使用循环逐个打印出结果。

//Start decoding

iRet = reader.DecodeFile(pszImageFile);

 

//If not DBR_OK

if (iRet != DBR_OK)

{

  printf("Failed to read barcode: %d\r\n%s\r\n",iRet, GetErrorString(iRet));

  return iRet;

}

 

//If DBR_OK

pBarcodeResultArray paryResult = NULL;

reader.GetBarcodes(&paryResult);

printf("%d total barcodes found. \r\n", paryResult->iBarcodeCount);

for (iIndex = 0; iIndex < paryResult->iBarcodeCount; iIndex++)

{

  printf("Result %d\r\n", iIndex + 1);

  printf("PageNum: %d\r\n", paryResult->ppBarcodes[iIndex]->iPageNum);

  printf("BarcodeFormat: %lld\r\n", paryResult->ppBarcodes[iIndex]->llFormat);

  printf("Text read: %s\r\n", paryResult->ppBarcodes[iIndex]->pBarcodeData);

}

记住要释放BarcodeResultArray

最后但也同样重要,我们需要释放BarcodeResultArray。 请注意这一步很重要。

//Finally release BarcodeResultArray

CBarcodeReader::FreeBarcodeResults(&paryResult);

其他条形码阅读功能

最后,如果要从图像的特定区域解码条形码,则有一个DecodeFileRect方法。 Dynamsoft的条形码读取器SDK还支持从设备无关位图(也称为DIB),缓冲区和base64字符串读取条形码。

快速导航

                               

 京ICP备09015132号-996网络文化经营许可证京网文[2017]4225-497号 | 违法和不良信息举报电话:4006561155

                                   © Copyright 2000-2023 北京哲想软件有限公司版权所有 | 地址:北京市海淀区西三环北路50号豪柏大厦C2座11层1105室

                         北京哲想软件集团旗下网站:哲想软件 | 哲想动画

                            华滋生物