-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
95 lines (81 loc) · 2.19 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <string>
#include "include/config.h"
#include "include/DynamsoftBarcodeReader.h"
#include "include/Persona.h"
bool parse(unsigned char* raw, int length);
using namespace std;
int iFormat = BF_All;
int iMaxCount = 0x7FFFFFFF;
const char * pszImageFile = NULL;
int iIndex = 0;
STextResultArray *paryResult = NULL;
int iRet = -1;
PublicParameterSettings parSettings;
char cErrorMsgBuffer[1024];
void* hBarcode;
unsigned char keysArray[] = { 0x27,
0x30,
0x04,
0xA0,
0x00,
0x0F,
0x93,
0x12,
0xA0,
0xD1,
0x33,
0xE0,
0x03,
0xD0,
0x00,
0xDf,
0x00
};
int main(int argc, const char* argv[])
{
if(argc==2){
hBarcode = DBR_CreateInstance();
// pVersion = DBR_GetVersion();
DBR_InitLicense(hBarcode,KEY);
// Set Reader Options
//DBR_SetBarcodeFormats(hBarcode, iFormat);
//DBR_SetMaxBarcodesNumPerPage(hBarcode, iMaxCount);
DBR_GetTemplateSettings(hBarcode,"", &parSettings);
parSettings.mAntiDamageLevel = 3;
parSettings.mMaxAlgorithmThreadCount = 1;
DBR_SetTemplateSettings(hBarcode,"",&parSettings,cErrorMsgBuffer,1024);
//iRet = DBR_DecodeFileEx(hBarcode, pszImageFile, &paryResult);
iRet = DBR_DecodeFile(hBarcode,argv[1],"");
// Output barcode result
if (iRet != DBR_OK){
printf("Failed to read barcode: %s\n", DBR_GetErrorString(iRet));
}
DBR_GetAllTextResults(hBarcode,&paryResult);
if (paryResult != NULL && paryResult->nResultsCount != 0){
for (iIndex = 0; iIndex < paryResult->nResultsCount; iIndex++){
if(parse(paryResult->ppResults[iIndex]->pBarcodeBytes,paryResult->ppResults[iIndex]->nBarcodeBytesLength)){
Persona a(paryResult->ppResults[iIndex]->pBarcodeBytes);
a.print();
}
}
}
DBR_FreeTextResults(&paryResult);
DBR_DestroyInstance(hBarcode);
return 0;
}
return 1;
}
bool parse(unsigned char* raw, int length){
if(length!=700) return false;
int j = 0;
for (int i = 0; i < length; i++) {
if (j == 17) {
j = 0;
}
char c = (char) (keysArray[j] ^ ((char) (raw[i])));
raw[i] = c;
j ++;
}
return true;
}