010-68421378
sales@cogitosoft.com
Categories
AddFlow  AmCharts JavaScript Stock Chart AmCharts 4: Charts Aspose.Total for Java Altova SchemaAgent Altova DatabaseSpy Altova MobileTogether Altova UModel  Altova MapForce 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 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  Sencha Test SPC Control Chart Tools for .Net Stimulsoft Reports.PHP Stimulsoft Reports.JS Stimulsoft Reports.Java Stimulsoft Reports. Ultimate Stimulsoft Reports.Wpf Stimulsoft Reports.Silverlight 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 for Mac

Dynamsoft Barcode Reader C/C++ API for Mac

Using Dynamsoft Barcode Reader C++ API for Mac

Dynamsoft's Barcode Reader SDK provides C++ and C APIs for Mac. You can use the barcode APIs to easily create a barcode reading software for Mac.In this article, I am going to demonstrate how to use the C++ barcode reading API for Mac to build a Command Line Application for 1D and 2D barcode recognition on Mac OS X.

START A NEW FILE

New a Command Line Tool

First, let's open Xcode.

Choose Command Line Tool as the project template, and under Type select C++ stdc++. Let's name the project BarcodeReaderDemo.

Add references

In the main.cpp, please include the .H files.

In our case, if you have Barcode Reader installed under Applications, the path will be"/Applications/Dynamsoft/Barcode Reader 4.1/Include/If_DBRP.h."

#include

#include "/Applications/Dynamsoft/Barcode Reader 4.1/Include/If_DBRP.h"

Copy the main function

Next, insert the following code to the main function.

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;

}

Select linked library

Select Targets -> BarcodeReaderDemo, click Info button, in the popped dialog, addlibDynamsoftBarcodeReader.dylib dependency.

Update license and source image

Please update the  and  with valid values respectively in the code.

For image path, you can use AllSupportedBarcodeTypes.tif in Images folder.
For license key, please find it in BarcodeReaderTrialLic.txt.

const char * pszImageFile = "/Applications/Dynamsoft/Barcode Reader 4.1/

Images/AllSupportedBarcodeTypes.tif";

               

Now you can build the project and have a run.

Barcode result

To verify if it is working, please open Terminal.app, and execute the application.

Quick Navigation;

© Copyright 2000-2023  COGITO SOFTWARE CO.,LTD. All rights reserved