派生自 development/c++

pansen
2019-03-07 979bc003bce710bf300bc2bd87a8278585678763
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//
// Created by pans on 5/2/18.
//
#include <iostream>
#include <thread>
 
//#include <basic/util/app/AppPreference.hpp>
#include <zconf.h>
#include <basic/debug/Debug.h>
//#include <QtCore/QString>
//#include "SqliteFaceEncap.h"
//#include "SqliteToolkit.hpp"
#include "GetUUId.h"
 
using namespace std;
 
/***
 * 初始化创建表 :
 * 1.底库管理表
 * uuid, tableName, tableDesc, tableType, bwType, create_time, update_time, create_by, del_flag, startTime, endTime
 * sql ok
 *
 * 2.中文和uuid对应表
 * uuid, name, tableName(uuid)
 * sql ok code not ok
 *
 *
 * 底库特征表 id是uuid
 * uuid, feature, img_url, create_time, update_time, create_by
 * sql ok
 *
 * 人员信息表
 * uuid, personName, age, sex, idCard, phoneNum,  create_time, update_time, create_by
 * sql ok
 *
 * car #todo
 *
 *
 *
 */
 
/***
 
  drop table "main"."sys_o_tables";
  CREATE TABLE "main"."sys_o_tables" (
  uuid        varchar(255) PRIMARY KEY,
  ClusterName varchar(255) DEFAULT NULL,
  tableName   varchar(255) DEFAULT NULL,
  tableDesc   varchar(255) DEFAULT NULL,
  tableType   varchar(255) DEFAULT NULL,
  bwType      varchar(255) DEFAULT NULL,
  startTime   varchar(255) DEFAULT NULL,
  endTime     varchar(255) DEFAULT NULL,
  create_time BLOB         DEFAULT (datetime('now', 'localtime')),
  update_time varchar(255) DEFAULT NULL,
  create_by   varchar(255) DEFAULT NULL,
  del_flag    varchar(255) DEFAULT 0
);
 
drop table "main"."TN2TID";
CREATE TABLE "main"."TN2TID" (
  uuid        varchar(255) PRIMARY KEY,
  TableName   varchar(255) NOT NULL,
  tableID     varchar(255) NOT NULL,
  create_time BLOB         DEFAULT (datetime('now', 'localtime')),
  update_time varchar(255) DEFAULT NULL,
  del_flag    INTEGER      DEFAULT 0
);
 
drop table "main"."person_info";
CREATE TABLE "main"."person_info" (
  uuid        varchar(255) PRIMARY KEY,
  personName  varchar(255) DEFAULT NULL,
  age         varchar(255) DEFAULT NULL,
  sex         varchar(255) DEFAULT NULL,
  idCard      varchar(255) DEFAULT NULL,
  phoneNum    varchar(255) DEFAULT NULL,
  create_time BLOB         DEFAULT (datetime('now', 'localtime')),
  update_time DATETIME     DEFAULT NULL,
  create_by   varchar(255) DEFAULT NULL,
  del_flag    INTEGER      DEFAULT 0
);
 
drop table "main"."person_info_feature";
CREATE TABLE "main"."person_info_feature" (
  uuid        varchar(255) PRIMARY KEY,
  feature     BLOB NOT NULL,
  faceUrl     BLOB NOT NULL,
  create_time BLOB         DEFAULT (datetime('now', 'localtime')),
  update_time varchar(255) DEFAULT NULL,
  create_by   varchar(255) DEFAULT NULL,
  del_flag    INTEGER      DEFAULT 0
);
 
 */
 
 
//struct FaceFeaWithScore {
//    int left;
//    int top;
//    int width;
//    int height;
//    std::vector<unsigned char> feature;
//    float score;
//};
//typedef std::vector<FaceFeaWithScore> Features;
 
 
/***
 *
 * @param argc
 * @param argv
 * @return
 */
/*
int main2(int argc, char **argv) {
 
   SAVE_APP_ARGS;
 
//    cout << getInitDBSql();
 
   SqliteFaceEncap sqliteFaceEncap("testRR");
 
   {
       //#删除底库
//        sqliteFaceEncap.deleteTable("test1");
   }
 
   {
       FieldValues fieldValues;
       fieldValues.insert(std::make_pair("uuid", GetUUId::getUUID()));
       fieldValues.insert(std::make_pair("tableName", "test2"));
       fieldValues.insert(std::make_pair("tableDesc", "ceshi"));
       fieldValues.insert(std::make_pair("tableType", "person"));
       fieldValues.insert(std::make_pair("bwType", "1"));
       fieldValues.insert(std::make_pair("startTime", "2018-01-01 02:02:02"));
       fieldValues.insert(std::make_pair("endTime", "2018-12-01 02:02:02"));
       fieldValues.insert(std::make_pair("create_by", "who"));
 
       //#创建底库
//        sqliteFaceEncap.createTable("test2", fieldValues);
   }
 
   {
       //#查询人脸底库列表
       auto res = sqliteFaceEncap.getTableNameList("person");
       for (auto &item : res) {
           std::cout << "tableName is  " << item << std::endl;
       }
   }
 
   {
       //#更新底库管理表
       FieldValues fieldValues;
       fieldValues.insert(std::make_pair("uuid", "c4e27077-59a3-458e-aedf-4b5d4def649b"));
       fieldValues.insert(std::make_pair("tableName", "test4"));
       fieldValues.insert(std::make_pair("tableDesc", "ceshi2"));
       fieldValues.insert(std::make_pair("tableType", "car"));
       fieldValues.insert(std::make_pair("bwType", "0"));
       fieldValues.insert(std::make_pair("startTime", "2018-01-01 02:02:02"));
       fieldValues.insert(std::make_pair("endTime", "2018-12-01 02:02:02"));
       fieldValues.insert(std::make_pair("create_by", "who"));
//        sqliteFaceEncap.updateTable("sys_o_tables", fieldValues);
   }
 
   {
       Features faceResults;
       for (int i = 0; i < 10; i++) {
           FaceFeaWithScore faceFeaWithScore;
           faceFeaWithScore.feature.resize(100);
           memset(faceFeaWithScore.feature.data(), 1, faceFeaWithScore.feature.size());
 
           faceResults.push_back(faceFeaWithScore);
       }
       //#添加人脸数据 TODO test
       //#两张表
       int lpp = 0;
       FieldValues fieldValues;
       for (auto item : faceResults) {
           AddFaceData addFaceData;
           addFaceData.feature.resize(item.feature.size());
           memcpy(addFaceData.feature.data(), item.feature.data(), item.feature.size());
           addFaceData.uuid = GetUUId::getUUID();
           addFaceData.faceUrl = "null";
           auto t_id = sqliteFaceEncap.addFace("test1", addFaceData, fieldValues);
       }
   }
 
   {
       //#更新人脸数据
       //#todo 两张表
       FieldValues fieldValues;
       FaceFeaWithScore faceFeaWithScore;
       faceFeaWithScore.feature.resize(100);
       memset(faceFeaWithScore.feature.data(), 1, faceFeaWithScore.feature.size());
 
 
       AddFaceData addFaceData;
       addFaceData.feature.resize(faceFeaWithScore.feature.size());
       memcpy(addFaceData.feature.data(), faceFeaWithScore.feature.data(), faceFeaWithScore.feature.size());
//        addFaceData.uuid = "ac8b30cf-8476-4dcf-a476-96907bb9a01f";
       addFaceData.faceUrl = "ttttttttt";
//        auto ret = sqliteFaceEncap.updateFace("test1", addFaceData, fieldValues);
//        if (ret) {
//            DBG("true");
//        } else {
//            DBG("false");
//        }
   }
 
   {
       //#删除人脸数据
       sqliteFaceEncap.deleteFace("test1", "e04ad3bc-5126-4fe5-b01f-f461dd30e104");
   }
 
 
   {
       //#查询人脸数据
       auto res = sqliteFaceEncap.getFacesFromTable("test1");
       auto &res_t = *res;
       for (auto &item : res_t) {
//            std::cout << item.first << std::endl;
           std::cout << item.second.uuid << std::endl;
           std::cout << item.second.faceurl << std::endl;
           std::cout << item.second.faceFeature.size() << std::endl;
       }
   }
 
   {
       auto res = sqliteFaceEncap.getTableInfos();
       for (auto &item : res) {
           std::cout << item.uuid << std::endl;
       }
   }
 
   return 0;
}
*/
//#define STRIP_LOG 0
#include <AppConfig.h>
 
int main(int argc, char **argv) {
    ENABLEGLOG(GET_STR_CONFIG("logPath").c_str());
    std::cout<<__DATE__<<" "<<__TIME__<<std::endl;
    std::string m = "test";
    DBG(m << " DBG");
    DBG(m << " DBG");
    LOG(INFO) << "hello glog";     // 打印log:“hello glog.  类似于C++ stream。
    SYSLOG(INFO) << "test log";
//    DLOG(INFO, m);
//    RAW_DLOG(WARNING, "test");
 
 
    CHKMSG(1, 1, m << " CHKMSG");
    CHKMSG(1, 2, m << " CHKMSG");
    MSG(m << " MSG");
 
    CHKERR(1, 1, m << " CHKERR");
    CHKERR(1, 2, m << " CHKERR");
 
    ERR(m << " ERR");
 
    CHKINFO(1, 1, m << " CHKINFO");
    CHKINFO(1, 2, m << " CHKINFO");
    INFO(m << " INFO");
 
    CHKDBG(1, 1, m << " CHKDBG");
    CHKDBG(1, 2, m << " CHKDBG");
 
    DBG(m << " DBG");
 
    getchar();
}