VehicleRecognition.cpp
3.21 KB
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
#include "vehicle_recognition.h"
#include <iostream>
#include "sy_errorinfo.h"
#include "vehicle_features.h"
using namespace std;
int VehicleRecognition_Init(void *&handle, char*dbpath, int gpuid, char* auth_license)
{
vr_param params;
params.gpuid = gpuid;
params.mode = DEVICE_GPU;
params.db_path = dbpath;//"../../db/mvpt.bin";
params.engine = ENGINE_TENSORRT;
params.max_batch = 20;
params.serialize_file = "./serialize_file/VR";
params.auth_license = auth_license;
//#ifdef _MSC_VER
// params.dbPath = "../../../../vehicleRecognition_MCaffeTmpBody/db/CarBodyFeature.db";
//#else
// params.dbPath = "/home/mliu/project/Project_MultiVPT/Video-Platform/video_structure_20190131/VehicleRecognition_body/db/CarBodyFeature.db";
//#endif
int ret = vr_init(&handle, params);
if (ret != 0)
{
cout << "VR Init Failed!" << endl;
system("pause");
return FAILED;
}
return SUCCESS;
}
int VehicleRecognition_Process(void * handle, sy_img * batch_img, int batchsize, vr_result *&vrresult)
{
//VR_Result *vr_result = new VR_Result[batchsize];
/*vrresult = new vr_result[batchsize];
for (int i = 0; i < batchsize; i++)
{
vrresult[i].vehicle_brand = new char[260];
vrresult[i].vehicle_subbrand = new char[260];
vrresult[i].vehicle_issue_year = new char[260];
vrresult[i].vehicle_type = new char[260];
vrresult[i].freight_ton = new char[260];
}*/
for (int i = 0; i < batchsize; i++)
{
if (batch_img[i].data_ == NULL)
cout << i << " data null" << endl;
}
//cout << "begin vr_batch" << endl;
vr_batch(handle, batch_img, batchsize, vrresult);
//cout << "end vr_batch" << endl;
/* for (int i = 0; i < batchsize; i++)
{
cout << i << ".ʶ������" << endl;
cout << " ʶ�����Ŷ�: " << vr_result[i].name_score << endl;
cout << " ����Ʒ�� - " << vr_result[i].vehicleBrand << endl;
cout << " ������Ʒ�� - " << vr_result[i].vehicleSubBrand << endl;
cout << " ������� - " << vr_result[i].vehicleIssueYear << endl;
cout << " �������� - " << vr_result[i].vehicleType << endl;
cout << " �����ּ� - " << vr_result[i].freightTon << endl;
cout << endl;
if (vr_result[i].vehicleBrand != NULL)
{
delete[] vr_result[i].vehicleBrand;
vr_result[i].vehicleBrand = NULL;
}
if (vr_result[i].vehicleSubBrand != NULL)
{
delete[] vr_result[i].vehicleSubBrand;
vr_result[i].vehicleSubBrand = NULL;
}
if (vr_result[i].vehicleIssueYear != NULL)
{
delete[] vr_result[i].vehicleIssueYear;
vr_result[i].vehicleIssueYear = NULL;
}
if (vr_result[i].vehicleType != NULL)
{
delete[] vr_result[i].vehicleType;
vr_result[i].vehicleType = NULL;
}
if (vr_result[i].freightTon != NULL)
{
delete[] vr_result[i].freightTon;
vr_result[i].freightTon = NULL;
}
}*/
return SUCCESS;
}
int VehicleRecognition_Release(void *& handle)
{
if (handle)
vr_release(&handle);
return SUCCESS;
}