pansen
2019-04-10 ecb47d89dcb2b1d8e4be9b6cb0a84d8b49e2e3cc
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
#include "vpt_pic.h"
//#include <highgui.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include "sy_common.h"
#include "mainAssist.h"
 
#ifdef _WIN32
#include<windows.h>
#else
 
#include <sys/time.h>
 
#endif
 
#include <basic/util/app/AppUtil.h>
#include "VptDetectWrapper.h"
#include <Ice/Ice.h>
#include <basic/rpc/IceRpc.hpp>
#include <basic/util/app/AppPreference.hpp>
#include "VptServerI.h"
#include <basic/debug/Debug.h>
 
#include <basic/util/app/AppConfig.h>
 
using namespace std;
#define varName(x) #x
#define printExp(exp) cout<<#exp<<"为:\t\t"<<(exp)<<endl
#define printExpToString(exp) cout<<(string(#exp)+"为:\t\t")<<(exp).toString()<<endl //注意exp加括号更安全
 
 
int main(int argc, char **argv) {
 
    std::cout << __DATE__ << " " << __TIME__ << std::endl;
    SAVE_APP_ARGS;
    ENABLEGLOG(GET_STR_CONFIG("logPath").c_str());
    auto ich = Ice::initialize(argc, argv);
 
    if (argc < 4) {
        assert("t_value.size()");
    }
    appPref.setIntData("gpu.index", atoi(argv[1]));
    appPref.setIntData("RpcVptPort", atoi(argv[2]));
    appPref.setFloatData("thresh.detect", atof(argv[3]));
 
 
    IceRpcServer<VptServerI> server("vptServer", appPref.getIntData("RpcVptPort"), "tcp");
    server.setMessageSizeMax(1024 * 1024 * 50);
    server.setPoolInitSize(5);
    server.setPoolMaxSize(10);
    server.runWaitShutDown();
    return 0;
}
 
 
int main2(int argc, char **argv) {
    string imgpath;
 
    if (argc < 2) {
        printf("Parameter number not right.\n");
        return 0;
    } else {
        imgpath = argv[1];
    }
 
    printf("SDK Version: %s\n", vpt_pic_get_version());
 
    CvFont font;
    cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0, 0, 1, 3);
    int fontFace = CV_FONT_HERSHEY_COMPLEX;
    double fontScale = 1;
    int thickness = 2;
 
    VptDetectWrapper vptDetectWrapper;
 
 
    cv::VideoCapture capture;
    capture.open(imgpath);
 
    cv::Mat process_image;
    capture >> process_image;//读出每一帧的图像
 
    cv::Mat image;
 
    while (!process_image.empty()) {
 
        process_image.copyTo(image);
        vptDetectWrapper.process_image(image);
 
//        for (int i = 0; i < result.count; i++) {
//            char str_i[100];
//            int colorIndex = result.info[i].obj_index;
//            if (colorIndex < 0 || colorIndex >= 9)continue;
//            sprintf(str_i, "%s:%.2f", type[colorIndex].c_str(), result.info[i].obj_score);
//
//            rectangle(process_image,
//                      cvPoint(result.info[i].obj_rect.left_ - 5, result.info[i].obj_rect.top_ - 15),
//                      cvPoint(result.info[i].obj_rect.left_ + result.info[i].obj_rect.width_ + 5,
//                              result.info[i].obj_rect.top_ + result.info[i].obj_rect.height_ + 10),
//                      cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), 3, 1);
//
//            cv::putText(process_image, str_i,
//                        cv::Point(result.info[i].obj_rect.left_, result.info[i].obj_rect.top_),
//                        fontFace, fontScale,
//                        cv::Scalar(color[colorIndex][0], color[colorIndex][1], color[colorIndex][2]), thickness, 8);
//
//            //输出二次属性分析结果
//            printfAnalysisRes(colorIndex, result.info[i].analysis_res);
//        }
 
#ifdef _MSC_VER
        cv::imshow("res", image);
        cv::waitKey(0);
#else
//        char svpath[1024];
//        memset(svpath, 0, sizeof(svpath));
//        std::string strNewTime2 = AppUtil::getTimeUSecString();
//        strNewTime2.append(".jpg");
//
//        sprintf(svpath, "vpt_res/%s", strNewTime2.c_str());
//        imwrite(svpath, process_image);
#endif
 
        capture >> process_image;//读出每一帧的图像
    }
 
 
    return 0;
}