SmartCrop: fix debug image not being outputed in all cases where it should

This commit is contained in:
2024-06-17 22:19:42 +02:00
parent e083ce3da7
commit 2a6908c849
2 changed files with 11 additions and 15 deletions

View File

@ -302,7 +302,7 @@ void pipeline(const std::filesystem::path& path, const Config& config, Yolo& yol
{ {
detection.priority += 10; detection.priority += 10;
hasmatch = true; hasmatch = true;
detections.push_back({0, "Face", match.confidence, 20, {255, 0, 0}, match.rect}); //detections.push_back({0, "Face", match.confidence, 20, {255, 0, 0}, match.rect});
} }
} }
Log(Log::DEBUG)<<detection.class_id<<": "<<detection.className<<" at "<<detection.box<<" with prio "<<detection.priority<<(hasmatch ? " has match" : ""); Log(Log::DEBUG)<<detection.class_id<<": "<<detection.className<<" at "<<detection.box<<" with prio "<<detection.priority<<(hasmatch ? " has match" : "");
@ -322,10 +322,14 @@ void pipeline(const std::filesystem::path& path, const Config& config, Yolo& yol
cv::Mat croppedImage; cv::Mat croppedImage;
if(image.size().aspectRatio() != config.targetSize.aspectRatio() && incompleate) if(image.size().aspectRatio() == config.targetSize.aspectRatio())
{ {
intRoi.getCropRectangle(crop, detections, image.size()); croppedImage = image;
}
else
{
if(incompleate)
intRoi.getCropRectangle(crop, detections, image.size());
if(config.debug) if(config.debug)
{ {
cv::Mat debugImage = image.clone(); cv::Mat debugImage = image.clone();
@ -337,14 +341,6 @@ void pipeline(const std::filesystem::path& path, const Config& config, Yolo& yol
croppedImage = image(crop); croppedImage = image(crop);
} }
else if(!incompleate)
{
croppedImage = image(crop);
}
else
{
croppedImage = image;
}
cv::Mat resizedImage; cv::Mat resizedImage;
cv::resize(croppedImage, resizedImage, config.targetSize, 0, 0, cv::INTER_CUBIC); cv::resize(croppedImage, resizedImage, config.targetSize, 0, 0, cv::INTER_CUBIC);

View File

@ -42,9 +42,9 @@ public:
}; };
private: private:
static constexpr float modelConfidenceThreshold = 0.25; static constexpr float modelConfidenceThreshold = 0.20;
static constexpr float modelScoreThreshold = 0.45; static constexpr float modelScoreThreshold = 0.40;
static constexpr float modelNMSThreshold = 0.50; static constexpr float modelNMSThreshold = 0.45;
std::string modelPath; std::string modelPath;
std::vector<std::pair<std::string, int>> classes; std::vector<std::pair<std::string, int>> classes;