| | |
| | | #include <QtCore/QSharedMemory> |
| | | #include <basic/timer_counter/Clocktimer.h> |
| | | |
| | | YoloDetectServerI::YoloDetectServerI():m_thresh(0.5),m_hier_thresh(0.5),m_nms(0.5),names(nullptr),alphabet(nullptr), |
| | | m_thdInit(init,this),m_bInitThd(false) |
| | | { |
| | | YoloDetectServerI::YoloDetectServerI() : m_thresh(0.5), m_hier_thresh(0.5), m_nms(0.5), names(nullptr), |
| | | alphabet(nullptr), |
| | | m_thdInit(init, this), m_bInitThd(false) { |
| | | } |
| | | |
| | | YoloDetectServerI::~YoloDetectServerI() |
| | | {} |
| | | YoloDetectServerI::~YoloDetectServerI() {} |
| | | |
| | | ::YoloDetect::ObjInfos YoloDetectServerI::YoloDetect(::Ice::Int w, ::Ice::Int h, const ::std::string& shM, const ::Ice::Current&) |
| | | { |
| | | ::YoloDetect::ObjInfos |
| | | YoloDetectServerI::YoloDetect(::Ice::Int w, ::Ice::Int h, const ::std::string &shM, const ::Ice::Current &) { |
| | | ClockTimer ct("YoloDetectServerI::YoloDetect"); |
| | | ::YoloDetect::ObjInfos objInfos; |
| | | if(!m_bInitThd) return objInfos; |
| | |
| | | detection *dets = get_network_boxes(m_net, im.w, im.h, m_thresh, m_hier_thresh, 0, 1, &nboxes); |
| | | if (m_nms) do_nms_sort(dets, nboxes, l.classes, m_nms); |
| | | // draw_detections(im, dets, nboxes, m_thresh, names, alphabet, l.classes); |
| | | for(int i=0;i<nboxes;i++) |
| | | { |
| | | for (int i = 0; i < nboxes; i++) { |
| | | ::YoloDetect::ObjInfo objInfo; |
| | | std::vector<float> vec(80); |
| | | memcpy(&vec[0],dets[i].prob,sizeof(float)*80); |
| | |
| | | return objInfos; |
| | | } |
| | | |
| | | int YoloDetectServerI::init(void* arg) |
| | | { |
| | | int YoloDetectServerI::init(void *arg) { |
| | | YoloDetectServerI* p = (YoloDetectServerI*)arg; |
| | | |
| | | p->m_thresh = appPref.getFloatData("thresh.detect"); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | cv::Mat YoloDetectServerI::bufferToMat(const int w,const int h,const int channels,const void* buffer) |
| | | { |
| | | cv::Mat YoloDetectServerI::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;}} |
| | | 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; |
| | | } |
| | |
| | | return im; |
| | | } |
| | | |
| | | YoloDetect::stringData YoloDetectServerI::getCocoData(const Ice::Current &) |
| | | { |
| | | YoloDetect::stringData YoloDetectServerI::getCocoData(const Ice::Current &) { |
| | | YoloDetect::stringData retval; |
| | | std::fstream fs("./data/coco.names"); |
| | | std::string str; |