SOMS/test/XuAilibTest/XuAilib.cpp
2024-07-15 10:31:26 +08:00

52 lines
1.9 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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<DetectorResult> 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;
}