Dynamsoft Barcode Reader C/C ++ API for Mac
使用Dynamsoft Barcode Reader C/C ++ API for Mac
Dynamsoft Barcode Reader SDK為Mac提供C ++和C API。 您可以使用條形碼API輕松創(chuàng)建Mac的條形碼讀取軟件。在本文中,我將演示如何使用Mac的C ++條形碼讀取API在Mac OS上構(gòu)建一維和二維條形碼識(shí)別的命令行應(yīng)用程序 X。
開始一個(gè)新文件
新建命令行工具
首先,讓我們打開Xcode。
選擇命令行工具作為項(xiàng)目模板,并在類型下選擇C ++ stdc ++。 讓我們將項(xiàng)目命名為BarcodeReaderDemo。

添加引用
在main.cpp中,請(qǐng)包括.H文件。
在我們的示例中,如果您在應(yīng)用程序下安裝了條形碼閱讀器,則路徑將為“/ Applications / Dynamsoft / Barcode Reader 4.1 / Include / If_DBRP.h”。
#include
#include“/ Applications / Dynamsoft / Barcode Reader 4.1 / Include / If_DBRP.h”

復(fù)制主功能
接下來,插入下列代碼到主功能
int main ( int argc, const char * argv[ ] )
{
//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);
return 0;
}

選擇鏈接庫
選擇Targets - > BarcodeReaderDemo,單擊信息按鈕,在彈出的對(duì)話框中,addlibDynamsoftBarcodeReader.dylib依賴。

更新許可證和源映像
請(qǐng)?jiān)诖a中分別使用有效值更新<您的映像文件完整路徑>和<您的許可證密鑰>。
對(duì)于圖像路徑,您可以在Images文件夾中使用AllSupportedBarcodeTypes.tif。
對(duì)于許可證密鑰,請(qǐng)?jiān)贐arcodeReaderTrialLic.txt中找到它。
const char * pszImageFile =“/ Applications / Dynamsoft / Barcode Reader 4.1 /
Images / AllSupportedBarcodeTypes.tif“;
現(xiàn)在你可以構(gòu)建項(xiàng)目并運(yùn)行。

條形碼結(jié)果
請(qǐng)打開Terminal.app 并運(yùn)行該app并確認(rèn)是否可行

京ICP備09015132號(hào)-996 | 違法和不良信息舉報(bào)電話:4006561155
© Copyright 2000-2026 北京哲想軟件有限公司版權(quán)所有 | 地址:北京市海淀區(qū)西三環(huán)北路50號(hào)豪柏大廈C2座11層1105室
北京哲想軟件集團(tuán)旗下網(wǎng)站:哲想軟件 | 哲想動(dòng)畫