#include "XuAilib.h" bool XuAilib::Run(const char* path, const int roi[8], const char* format, string& result, string arg) { const char* pstrModelFile = "Model_det.m"; CNanoDetector cNanoDetector(pstrModelFile); cNanoDetector.Init(); Mat mat = imread(path); if (mat.data != NULL) { cNanoDetector.Execute(mat); vector vec; cNanoDetector.GetResults(vec); if (vec.size() > 0) { for (size_t i = 0; i < vec.size(); i++) { int width = vec[i].width; int height = vec[i].height; Rect m_select = Rect(vec[i].left, vec[i].top, width, height); if (string("biaopan").compare(vec[i].name) == 0) { if (arg.compare("biaopan") == 0) { Mat roi = mat(m_select); DoublePointerAlgorithm doublePointerAlgorithm; int resultValue = doublePointerAlgorithm.GetResult(roi, false); //cout << "biaopan结果 :" << resultValue << endl; result = "避雷器次数结果:" + to_string(resultValue) + "次"; } } if (string("ceshi").compare(vec[i].name) == 0) { if (arg.compare("ceshi") == 0) { Mat roi = mat(m_select); SemicircularMeter semicircularMeter; double resultValue = semicircularMeter.GetResult(roi, false); //cout << "ceshi结果 :" << result << endl; result = "避雷器电流读数:" + to_string(resultValue) + "A"; } } } waitKey(0); } } return false; }