//
|
// Created by ps on 19-4-11.
|
//
|
#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 <Ice/Ice.h>
|
#include <basic/rpc/IceRpc.hpp>
|
#include <basic/util/app/AppPreference.hpp>
|
#include <basic/debug/Debug.h>
|
|
#include <basic/util/app/AppConfig.h>
|
#include <QtCore/QSharedMemory>
|
#include "rpc/VptServer.h"
|
|
int main(int argc, char **argv) {
|
string imgpath;
|
|
if (argc < 2) {
|
printf("Parameter number not right.\n");
|
return 0;
|
} else {
|
imgpath = argv[1];
|
}
|
|
IceRpcClient<VptDetect::VptDetectServerPrx> rpcClient("vptServer", "", 12003, "tcp");
|
|
auto server = rpcClient.getServer();
|
std::string shareMemoryName = "vptServer";
|
QSharedMemory *sharedMemory = new QSharedMemory(QString(shareMemoryName.c_str()));
|
//1520 x 2688 1080 x 1920 //2560 * 1440 * 4
|
if (!sharedMemory->create(4608 * 2592 * 4)) {
|
sharedMemory->attach();
|
}
|
|
// server->getStr(1);
|
|
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;
|
|
|
cv::VideoCapture capture;
|
capture.open(imgpath);
|
|
cv::Mat process_image;
|
capture >> process_image;//读出每一帧的图像
|
|
cv::Mat image;
|
|
while (!process_image.empty()) {
|
|
image = cv::Mat(process_image.rows, process_image.cols, CV_8UC3, sharedMemory->data());
|
process_image.copyTo(image);
|
|
auto res = server->VptDetect(image.cols, image.rows, sharedMemory->key().toStdString());
|
if (res.size() > 0) {
|
|
DBG(res.size());
|
}
|
|
// 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;
|
}
|