Commit dd731eff3115a6b3875c53e674cb84b9dfb88762
1 parent
e0b055a2
增加产品id 授权
Showing
2 changed files
with
65 additions
and
19 deletions
src/left_over/RegionSurveillanceProcess.h
... | ... | @@ -54,8 +54,10 @@ public: |
54 | 54 | double scale; |
55 | 55 | //int long_side; |
56 | 56 | //int short_side; |
57 | + rs_auth_type type; | |
57 | 58 | std::atomic<bool> thrd_run; |
58 | - //boost::thread thrd; | |
59 | + int licence_status = -1; | |
60 | + int thrd_status = -1; | |
59 | 61 | long frame_num = 0; |
60 | 62 | bool init_flag = false; |
61 | 63 | sy_rect rect[MAXVERTEXNUM]; //ÓÐÐ§ÇøÓò | ... | ... |
src/left_over/ms_region_surveilance.cpp
... | ... | @@ -6,9 +6,44 @@ |
6 | 6 | #include <chrono> |
7 | 7 | #include "sy_errorinfo.h" |
8 | 8 | #include <opencv2/opencv.hpp> |
9 | +#include "authority.h" | |
9 | 10 | //#define productSN "D92CBC0CFBA54BD3846DEBD4A9D36FC1" |
10 | 11 | #define productSN "B5895C36B5304C9A9FE665A372BFFDA2" |
11 | 12 | |
13 | + | |
14 | +//void check_thread(RegionSurveillanceProcess* &handle, char* productsn) | |
15 | +//{ | |
16 | +// int res = -1; | |
17 | +//#ifndef _MSC_VER | |
18 | +// char wtime[15]; | |
19 | +// memset(wtime, 0, 15); | |
20 | +// char * time = wtime; | |
21 | +//#endif | |
22 | +// while (1) | |
23 | +// { | |
24 | +// //printf("xxx check status on process...\n"); | |
25 | +//#ifdef _MSC_VER | |
26 | +// res = sy_licence(productsn); | |
27 | +//#else | |
28 | +// res = sy_licence(productsn, &time); | |
29 | +// //printf("--------------wtime in thread: %s, status: %d\n", wtime, licence_status); | |
30 | +//#endif | |
31 | +// if (res < 0) | |
32 | +// { | |
33 | +// handle->licence_status = handle->licence_status - 1; | |
34 | +// } | |
35 | +// else | |
36 | +// { | |
37 | +// if (handle->licence_status < 0) | |
38 | +// { | |
39 | +// handle->licence_status = 0; | |
40 | +// } | |
41 | +// } | |
42 | +// boost::this_thread::sleep(boost::posix_time::seconds(300)); //5min | |
43 | +// } | |
44 | +//} | |
45 | + | |
46 | + | |
12 | 47 | //void check_thread(RegionSurveillanceProcess* handle) |
13 | 48 | //{ |
14 | 49 | // int res = -1; |
... | ... | @@ -82,32 +117,42 @@ inline bool timecheck() |
82 | 117 | |
83 | 118 | int rs_init(void **handle, rs_param param) |
84 | 119 | { |
85 | - int ret = SUCCESS; | |
120 | + | |
86 | 121 | RegionSurveillanceProcess* regin = new IRegionSurveillanceCpu; |
122 | + regin->type = param.type; | |
123 | + int ret = SUCCESS; | |
87 | 124 | bool auth_type = false; |
88 | - if (param.type == TIME) | |
89 | - { | |
90 | - auth_type = timecheck(); | |
91 | - } | |
92 | - else | |
125 | + if(param.type == PRODUCT_ID) | |
93 | 126 | { |
94 | 127 | char uuid[36] = {}; |
95 | 128 | FILE *Uuid = fopen("/proc/sys/kernel/random/uuid", "r"); |
96 | 129 | fgets(uuid, 36, Uuid); |
97 | - //strcpy(uuid,"059bebb1-fca2-42e6-8cbd-6b3195641819"); | |
98 | 130 | fclose(Uuid); |
99 | 131 | regin->auth = new CheckAuthor; |
100 | 132 | regin->auth->Init(param.auth.url, param.auth.port, uuid, productSN, 1); |
101 | 133 | auth_type = regin->auth->GetAuthorStatus(); |
102 | 134 | } |
135 | + if (param.type == TIME) | |
136 | + { | |
137 | + | |
138 | +#ifdef _MSC_VER | |
139 | + ret = sy_licence(productSN); | |
140 | +#else | |
141 | + char wtime[15]; | |
142 | + memset(wtime, 0, 15); | |
143 | + char * time = wtime; | |
144 | + ret = sy_licence(productSN, &time) | |
145 | +#endif | |
146 | + if (ret == SUCCESS) | |
147 | + auth_type = true; | |
148 | + else | |
149 | + auth_type = false; | |
150 | + | |
151 | + } | |
103 | 152 | if (auth_type) |
104 | 153 | { |
105 | 154 | regin->frame_num = param.frame_num; |
106 | - if (!regin) | |
107 | - { | |
108 | - printf("model initial failed \n"); | |
109 | - return -1; | |
110 | - } | |
155 | + | |
111 | 156 | |
112 | 157 | regin->scale = param.scale; |
113 | 158 | regin->rect_num = param.rect_num; //ÓÐÐ§ÇøÓòÊýÁ¿ |
... | ... | @@ -186,18 +231,17 @@ int rs_init(void **handle, rs_param param) |
186 | 231 | |
187 | 232 | int rs_process(void *handle, sy_img img_data, rs_result *result) |
188 | 233 | { |
189 | - RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; | |
190 | - if (!regin) | |
234 | + if (!handle) | |
191 | 235 | { |
192 | 236 | printf("handle is NULL \n"); |
193 | 237 | return -1; |
194 | 238 | } |
195 | - if (regin->auth && 0 == regin->auth->GetAuthorStatus()) | |
239 | + RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; | |
240 | + if (regin->type == PRODUCT_ID && (regin->auth && 0 == regin->auth->GetAuthorStatus())) | |
196 | 241 | { |
197 | 242 | printf("auth error \n"); |
198 | 243 | return -1; |
199 | 244 | } |
200 | - | |
201 | 245 | region_info pRegionInfo; |
202 | 246 | pRegionInfo.alarm_info = 6; |
203 | 247 | pRegionInfo.frame_num = regin->frame_num; |
... | ... | @@ -339,7 +383,7 @@ void rs_release(void **handle) |
339 | 383 | printf("handle is NULL \n"); |
340 | 384 | return; |
341 | 385 | } |
342 | - if (regin->auth) | |
386 | + if (regin->type == PRODUCT_ID && regin->auth) | |
343 | 387 | { |
344 | 388 | regin->auth->Uninit(); |
345 | 389 | delete regin->auth; |
... | ... | @@ -350,6 +394,6 @@ void rs_release(void **handle) |
350 | 394 | |
351 | 395 | const char * rs_get_version() |
352 | 396 | { |
353 | - return "left_over_det_version: v0.0.2.200402,5A72239196F54B678D311E7FC11849DC"; | |
397 | + return "left_over_det_version: v0.0.3.201117,B5895C36B5304C9A9FE665A372BFFDA2"; | |
354 | 398 | } |
355 | 399 | ... | ... |