SmartCrop: allow target image aspect ratio to be different than 1:1
This commit is contained in:
parent
422debd897
commit
57361af9fe
4 changed files with 43 additions and 28 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#include "yolo.h"
|
||||
#include "log.h"
|
||||
|
|
@ -309,7 +310,7 @@ void pipeline(const std::filesystem::path& path, const Config& config, Yolo& yol
|
|||
}
|
||||
|
||||
cv::Rect crop;
|
||||
bool incompleate = intRoi.getCropRectangle(crop, detections, image.size());
|
||||
bool incompleate = intRoi.getCropRectangle(crop, detections, image.size(), config.targetSize.aspectRatio());
|
||||
|
||||
if(config.seamCarving && incompleate)
|
||||
{
|
||||
|
|
@ -329,7 +330,7 @@ void pipeline(const std::filesystem::path& path, const Config& config, Yolo& yol
|
|||
else
|
||||
{
|
||||
if(incompleate)
|
||||
intRoi.getCropRectangle(crop, detections, image.size());
|
||||
intRoi.getCropRectangle(crop, detections, image.size(), config.targetSize.aspectRatio());
|
||||
if(config.debug)
|
||||
{
|
||||
cv::Mat debugImage = image.clone();
|
||||
|
|
@ -444,7 +445,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
std::vector<std::vector<std::filesystem::path>> imagePathParts = splitVector(imagePaths, std::thread::hardware_concurrency());
|
||||
std::vector<std::vector<std::filesystem::path>> imagePathParts = splitVector(imagePaths, 1/*std::thread::hardware_concurrency()*/);
|
||||
|
||||
for(size_t i = 0; i < imagePathParts.size(); ++i)
|
||||
threads.push_back(std::thread(threadFn, imagePathParts[i], std::ref(config), recognizer, std::ref(recognizerMutex), std::ref(debugOutputPath)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue