#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(1);
|
server.setPoolMaxSize(3);
|
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;
|
}
|