//
|
// Created by ps on 19-4-10.
|
//
|
|
#include "VptServerI.h"
|
#include <QtCore/QString>
|
#include <QtCore/QSharedMemory>
|
|
VptServerI::VptServerI() {}
|
|
VptServerI::~VptServerI() {
|
|
}
|
|
VptDetect::ObjInfos
|
VptServerI::VptDetect(Ice::Int width, Ice::Int height, const ::std::string &shM,
|
const ::Ice::Current ¤t) {
|
|
VptDetect::ObjInfos objInfos;
|
QSharedMemory shareMemory(QString(shM.c_str()));
|
if (shareMemory.attach()) {
|
int channel = 3;
|
cv::Mat _mat = bufferToMat(width, height, channel, shareMemory.constData());
|
auto res = std::move(m_vptDetectWrapper.process_image(_mat));
|
|
for (auto &item : res) {
|
::VptDetect::VptDetectResult vptDetectResult;
|
|
vptDetectResult.sdkDetectType = static_cast<Ice::Int>(item.sdkDetectType);
|
|
vptDetectResult.bskRect.left = item.bskRect.left_;
|
vptDetectResult.bskRect.top = item.bskRect.top_;
|
vptDetectResult.bskRect.width = item.bskRect.width_;
|
vptDetectResult.bskRect.height = item.bskRect.height_;
|
|
switch (vptDetectResult.sdkDetectType) {
|
case 0 : {
|
vptDetectResult.personDetectRes.res_objs.resize(HP_FIR_INDEX_SIZE);
|
memcpy(vptDetectResult.personDetectRes.res_objs.data(), item.vptDetectRes.personDetectRes.res_objs,
|
sizeof(classfy_boj_res) * HP_FIR_INDEX_SIZE);
|
};
|
break;
|
case 1:
|
case 2 : {
|
vptDetectResult.perRideCarDetectRes.res_objs.resize(HCP_FIR_INDEX_SIZE);
|
memcpy(vptDetectResult.perRideCarDetectRes.res_objs.data(),
|
item.vptDetectRes.perRideCarDetectRes.res_objs,
|
sizeof(classfy_boj_res) * HCP_FIR_INDEX_SIZE);
|
};
|
break;
|
case 4 :
|
case 5 :
|
case 6 :
|
case 8 : {
|
//#todo
|
vptDetectResult.carDetectRes;
|
};
|
break;
|
}
|
objInfos.push_back(vptDetectResult);
|
}
|
|
}
|
return objInfos;
|
}
|
|
VptDetect::stringDatas VptServerI::getStr(Ice::Int type_, const ::Ice::Current ¤t) {
|
VptDetect::stringDatas res;
|
//#todo extern to func
|
switch (type_) {
|
case 0 : {
|
for (auto &items : HpResStr) {
|
::VptDetect::stringData stringData;
|
for (auto &item : items) {
|
stringData.push_back(item);
|
}
|
res.push_back(std::move(stringData));
|
}
|
};
|
break;
|
case 1 : {
|
for (auto &items : HcpResStr) {
|
::VptDetect::stringData stringData;
|
for (auto &item : items) {
|
stringData.push_back(item);
|
}
|
res.push_back(std::move(stringData));
|
}
|
};
|
break;
|
case 2 : {
|
::VptDetect::stringData stringData;
|
for (auto &item : type) {
|
stringData.push_back(item);
|
}
|
res.push_back(std::move(stringData));
|
};
|
break;
|
case 3 : {
|
::VptDetect::stringData stringData;
|
for (auto &item : colorLabelStr) {
|
stringData.push_back(item);
|
}
|
res.push_back(std::move(stringData));
|
};
|
break;
|
}
|
return res;
|
}
|
|
VptDetect::stringData VptServerI::getTypeStr(const ::Ice::Current ¤t) {
|
//#todo
|
return VptDetect::stringData();
|
}
|
|
VptDetect::stringData VptServerI::getColorLabel(const ::Ice::Current ¤t) {
|
//#todo
|
return VptDetect::stringData();
|
}
|
|
VptDetect::stringDatas VptServerI::getHpResStr(const ::Ice::Current ¤t) {
|
//#todo
|
return VptDetect::stringDatas();
|
}
|
|
VptDetect::stringDatas VptServerI::getHcpResStr(const ::Ice::Current ¤t) {
|
//#todo
|
return VptDetect::stringDatas();
|
}
|
|
cv::Mat VptServerI::bufferToMat(const int w, const int h, const int channels, const void *buffer) {
|
int nType = -1;
|
switch (channels) {
|
case 1: {
|
nType = CV_8UC1;
|
break;
|
}
|
case 2: {
|
nType = CV_8UC2;
|
break;
|
}
|
case 3: {
|
nType = CV_8UC3;
|
break;
|
}
|
default: {
|
nType = CV_8UC3;
|
break;
|
}
|
}
|
cv::Mat mat(h, w, nType, (void *) buffer);
|
return mat;
|
}
|