52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
![]() |
#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<61><6E><EFBFBD><EFBFBD> <20><>" << resultValue << endl;
|
|||
|
result = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + to_string(resultValue) + "<EFBFBD><EFBFBD>";
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
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<68><69><EFBFBD><EFBFBD> <20><>" << result << endl;
|
|||
|
result = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" + to_string(resultValue) + "A";
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
waitKey(0);
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|