Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readdpmbarcode #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ option(BUILD_CPP_VIDEODECODING "Build the sample VideoDecoding under ./samples/C
option(BUILD_CPP_SPEEDFIRSTSETTINGS "Build the sample SpeedFirstSettings under ./sample/C++/Performance/SpeedFirstSettings" ON)
option(BUILD_CPP_ACCURACYFIRSTSETTINGS "Build the sample AccuracyFirstSettings under ./sample/C++/Performance/AccuracyFirstSettings" ON)
option(BUILD_CPP_READRATEFIRSTSETTINGS "Build the sample ReadRateFirstSettings under ./sample/C++/Performance/ReadRateFirstSettings" ON)
option(BUILD_CPP_READDPMBARCODE "Build the sample ReadDPMBarcode under ./sample/C++/UseCases/ReadDPMBarcode" ON)

if(BUILD_LINUX)
set(DBRLIB ${CMAKE_CURRENT_SOURCE_DIR}/lib/Linux)
Expand Down Expand Up @@ -63,7 +64,13 @@ endif()
if(BUILD_CPP_READRATEFIRSTSETTINGS)
add_subdirectory(samples/C++/Performance/ReadRateFirstSettings)
endif()
if(BUILD_CPP_READDPMBARCODE)
add_subdirectory(samples/C++/UseCases/ReadDPMBarcode)
endif()

if(BUILD_C_HELLOWORLD OR BUILD_C_GENERALSETTINGS OR BUILD_CPP_HELLOWORLD OR BUILD_CPP_GENERALSETTINGS OR BUILD_CPP_SPEEDFIRSTSETTINGS OR BUILD_CPP_ACCURACYFIRSTSETTINGS OR BUILD_CPP_READRATEFIRSTSETTINGS)
File(COPY ./images/AllSupportedBarcodeTypes.png DESTINATION images)
endif()
if(BUILD_CPP_READDPMBARCODE)
File(COPY ./images/dpm.jpg DESTINATION images)
endif()
Binary file added images/dpm.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions samples/C++/BarcodeReaderSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AccuracyFirstSettings", "Pe
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadRateFirstSettings", "Performance\ReadRateFirstSettings\ReadRateFirstSettings.vcxproj", "{AEFC9596-D16D-4790-9C56-E9F58D7B66EA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReadDPMBarcode", "UseCases\ReadDPMBarcode\ReadDPMBarcode.vcxproj", "{24006433-CE29-468A-A29D-DEE568FC9B9D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -80,6 +82,14 @@ Global
{AEFC9596-D16D-4790-9C56-E9F58D7B66EA}.Release|x64.Build.0 = Release|x64
{AEFC9596-D16D-4790-9C56-E9F58D7B66EA}.Release|x86.ActiveCfg = Release|Win32
{AEFC9596-D16D-4790-9C56-E9F58D7B66EA}.Release|x86.Build.0 = Release|Win32
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Debug|x64.ActiveCfg = Debug|x64
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Debug|x64.Build.0 = Debug|x64
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Debug|x86.ActiveCfg = Debug|Win32
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Debug|x86.Build.0 = Debug|Win32
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Release|x64.ActiveCfg = Release|x64
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Release|x64.Build.0 = Release|x64
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Release|x86.ActiveCfg = Release|Win32
{24006433-CE29-468A-A29D-DEE568FC9B9D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <time.h>
#include <cstring>
#include <iostream>
#include "../../../../include/DynamsoftBarcodeReader.h"
#include "../../../../include/DynamsoftCommon.h"
using namespace std;
Expand All @@ -12,7 +13,6 @@ using namespace dynamsoft::dbr;
#if defined(_WIN64) || defined(_WIN32)
#include <windows.h>
#include <conio.h>
#include <iostream>
#ifdef _WIN64
#pragma comment(lib, "../../../../lib/Windows/x64/DBRx64.lib")
#else
Expand Down
34 changes: 34 additions & 0 deletions samples/C++/UseCases/ReadDPMBarcode/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
cmake_minimum_required(VERSION 3.6)
# set the platform
option(BUILD_LINUX "Build samples for running on Linux x86_64" ON)
option(BUILD_ARM "Build samples for running on ARM x86" OFF)
option(BUILD_ARM64 "Build samples for running on ARM x64" OFF)

if(BUILD_LINUX)
set(DBRLIB ../../../../lib/Linux)
elseif(BUILD_ARM)
set(DBRLIB ../../../../lib/ARM32)
add_compile_options(-DDM_ARM -D__ARM_NEON__ -mfpu=neon)
elseif(BUILD_ARM64)
set(DBRLIB ../../../../lib/ARM64)
add_compile_options(-DDM_ARM -D__ARM_NEON__)
else()
message(FATAL_ERROR "Please specify a supported platform")
endif()

set (CMAKE_CXX_STANDARD 11)
add_compile_options(-O2 -fPIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -fvisibility=hidden -fvisibility-inlines-hidden -L ${DBRLIB} -Wl,-rpath,${DBRLIB} -Wl,-rpath,'$ORIGIN' -static-libgcc -static-libstdc++ -s")
endif()

project(ReadDPMBarcode)

file(GLOB FILE_SRCS
ReadDPMBarcode.cpp
)

add_executable(ReadDPMBarcode ${FILE_SRCS})
set_target_properties(ReadDPMBarcode PROPERTIES SKIP_BUILD_RPATH TRUE)
target_link_libraries(ReadDPMBarcode DynamsoftBarcodeReader)

124 changes: 124 additions & 0 deletions samples/C++/UseCases/ReadDPMBarcode/ReadDPMBarcode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include <string>
#include <iostream>

#include "../../../../include/DynamsoftBarcodeReader.h"
#include "../../../../include/DynamsoftCommon.h"

using namespace std;
using namespace dynamsoft::dbr;

// Link libraries of DynamsoftBarcodeReader SDK for Windows.
#if defined(_WIN64) || defined(_WIN32)
#ifdef _WIN64
#pragma comment(lib, "../../../../lib/Windows/x64/DBRx64.lib")
#else
#pragma comment(lib, "../../../../lib/Windows/x86/DBRx86.lib")
#endif
#endif

class ReadDPMBarcode
{
public:
void configReadDPMBarcode(CBarcodeReader *reader)
{
// Obtain current runtime settings of instance.
PublicRuntimeSettings settings;
reader->GetRuntimeSettings(&settings);

// Set expected barcode formats.
// Generally, the most common dpm barcode is datamatrix or qrcode
settings.barcodeFormatIds = BF_DATAMATRIX | BF_QR_CODE;

// Set grayscale transformation modes.
// DPM barcodes may be dark and printed on the light background, or it may be light and printed on the dark background.
// By default, the library can only locate the dark barcodes that stand on a light background. "GTM_INVERTED":The image will be transformed into inverted grayscale.
settings.furtherModes.grayscaleTransformationModes[0] = GTM_ORIGINAL;
settings.furtherModes.grayscaleTransformationModes[1] = GTM_INVERTED;

// Enable dpm modes.
// It is a parameter to control how to read direct part mark(DPM) barcodes.
settings.furtherModes.dpmCodeReadingModes[0] = DPMCRM_GENERAL;

// Apply the new settings to the instance
reader->UpdateRuntimeSettings(&settings);

}


void outputResults(TextResultArray* barcodeResults, CBarcodeReader& reader)
{
if (barcodeResults != NULL && barcodeResults->resultsCount > 0)
{
// Process each result in a loop
for (int i = 0; i < barcodeResults->resultsCount; ++i)
{
cout << "Result " << (i + 1) << ":" << endl;

//Get format of each barcode
if (barcodeResults->results[i]->barcodeFormat != BF_NULL)
cout << " Barcode Format: " << barcodeResults->results[i]->barcodeFormatString << endl;
else
cout << " Barcode Format: " << barcodeResults->results[i]->barcodeFormatString_2 << endl;

//Get text result of each barcode
cout << " Barcode Text: " << barcodeResults->results[i]->barcodeText << endl;
}
}
else
{
cout << "No barcode detected." << endl;
}

//Free the memory allocated for text results
if (barcodeResults != NULL)
CBarcodeReader::FreeTextResults(&barcodeResults);
}
};

int main()
{
int errorCode = 0;
char szErrorMsg[256];
TextResultArray* barcodeResults = NULL;

// Initialize license
/*
// By setting organization ID as "200001", a 7-day trial license will be used for license verification.
// Note that network connection is required for this license to work.
//
// When using your own license, locate the following line and specify your Organization ID.
// organizationID = "200001";
//
// If you don't have a license yet, you can request a trial from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=c_cpp
*/
DM_DLSConnectionParameters paramters;
CBarcodeReader::InitDLSConnectionParameters(&paramters);
paramters.organizationID = const_cast<char*>("200001"); // replace it with your organization ID
errorCode = CBarcodeReader::InitLicenseFromDLS(&paramters, szErrorMsg, 256);
if (errorCode != DBR_OK)
{
cout << szErrorMsg << endl;
}

// Create an instance of Barcode Reader
CBarcodeReader reader;
ReadDPMBarcode rb;

string fileName = "../../../../images/dpm.jpg";

// config through ReadDPM
rb.configReadDPMBarcode(&reader);

// Decode barcodes from an image file by current runtime settings. The second parameter value "" means to decode through the current PublicRuntimeSettings.
reader.DecodeFile(fileName.c_str(), "");

// Get all barcode results
reader.GetAllTextResults(&barcodeResults);

// Output the barcode format and barcode text.
rb.outputResults(barcodeResults, reader);

cout << "Press any key to quit..." << endl;
cin.ignore();
return 0;
}
131 changes: 131 additions & 0 deletions samples/C++/UseCases/ReadDPMBarcode/ReadDPMBarcode.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{24006433-CE29-468A-A29D-DEE568FC9B9D}</ProjectGuid>
<RootNamespace>ReadDPMBarcode</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ReadDPMBarcode.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>