|
@@ -16,7 +16,8 @@
|
|
|
|
|
|
|
|
YoloFeatureManager::YoloFeatureManager()
|
|
YoloFeatureManager::YoloFeatureManager()
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ inputWidth = 320;
|
|
|
|
|
+ inputHeight = 320;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
YoloFeatureManager::~YoloFeatureManager()
|
|
YoloFeatureManager::~YoloFeatureManager()
|
|
@@ -28,9 +29,6 @@ void YoloFeatureManager::loadModel(const std::string & modelPath)
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- inputWidth = 448;
|
|
|
|
|
- inputHeight = 448;
|
|
|
|
|
-
|
|
|
|
|
net = cv::dnn::readNetFromONNX(modelPath);
|
|
net = cv::dnn::readNetFromONNX(modelPath);
|
|
|
|
|
|
|
|
CONF_THRESHOLD = 0.5f; // 可以根据需要调整置信度阈值
|
|
CONF_THRESHOLD = 0.5f; // 可以根据需要调整置信度阈值
|
|
@@ -50,9 +48,6 @@ void YoloFeatureManager::loadModel(const std::string& modelPath, const std::stri
|
|
|
{
|
|
{
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- inputWidth = 448;
|
|
|
|
|
- inputHeight = 448;
|
|
|
|
|
-
|
|
|
|
|
net = cv::dnn::readNetFromModelOptimizer(modelPath, configPath);
|
|
net = cv::dnn::readNetFromModelOptimizer(modelPath, configPath);
|
|
|
|
|
|
|
|
// 设置目标设备 (可选: CPU, GPU, MYRIAD等)
|
|
// 设置目标设备 (可选: CPU, GPU, MYRIAD等)
|
|
@@ -344,10 +339,10 @@ std::string YoloFeatureManager::Class(cv::Mat & image)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 在画面上绘制分类结果
|
|
// 在画面上绘制分类结果
|
|
|
- //std::wstring resultText = CLewaimaiString::ANSIToUnicode(className) + L" : " + std::to_wstring(round(topConfidence * 10000) / 100) + L"%";
|
|
|
|
|
- //this->drawChineseText(image, resultText.c_str(), cv::Point(20, 50), cv::Scalar(0, 255, 0), 24);
|
|
|
|
|
- //cv::imshow("YOLOv8s-cls 实时图像分类", image);
|
|
|
|
|
- //if (cv::waitKey(30) >= 0); // 按任意键退出
|
|
|
|
|
|
|
+ std::wstring resultText = CLewaimaiString::ANSIToUnicode(className) + L" : " + std::to_wstring(round(topConfidence * 10000) / 100) + L"%";
|
|
|
|
|
+ this->drawChineseText(image, resultText.c_str(), cv::Point(20, 50), cv::Scalar(0, 255, 0), 24);
|
|
|
|
|
+ cv::imshow("YOLOv8s-cls 实时图像分类", image);
|
|
|
|
|
+ if (cv::waitKey(30) >= 0); // 按任意键退出
|
|
|
|
|
|
|
|
return className;
|
|
return className;
|
|
|
}
|
|
}
|