|
9 | 9 |
|
10 | 10 | YOLOv11SegDetectorNcnn::YOLOv11SegDetectorNcnn(const std::string &modelPath, |
11 | 11 | const std::string &labelsPath, |
12 | | - bool useGPU) : Yolo11Segementation(labelsPath) |
| 12 | + bool useGPU, bool use320x320input) : Yolo11Segementation(labelsPath) |
13 | 13 | { |
14 | 14 | QString ressourcePathGeneric = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "models", QStandardPaths::LocateDirectory); |
15 | 15 | QString ressourcePathApp = QStandardPaths::locate(QStandardPaths::AppDataLocation, "models", QStandardPaths::LocateDirectory); |
@@ -48,7 +48,14 @@ YOLOv11SegDetectorNcnn::YOLOv11SegDetectorNcnn(const std::string &modelPath, |
48 | 48 | numOutputNodes = net.output_names().size(); |
49 | 49 |
|
50 | 50 | isDynamicInputShape = false; // Assume static input shape by default. NCNN models typically have fixed input shapes. |
51 | | - inputImageShape = cv::Size(640, 640); // Default shape. This is fixed for YOLOv11SegNCNN |
| 51 | + |
| 52 | + if(use320x320input) { |
| 53 | + inputImageShape = cv::Size(320, 320); |
| 54 | + } |
| 55 | + else |
| 56 | + { |
| 57 | + inputImageShape = cv::Size(640, 640); // Default shape. This is fixed for YOLOv11SegNCNN |
| 58 | + } |
52 | 59 |
|
53 | 60 | // Input |
54 | 61 | if (numInputNodes != 1) |
@@ -277,7 +284,7 @@ std::vector<Segmentation> YOLOv11SegDetectorNcnn::segment(const cv::Mat &image, |
277 | 284 | cv::Scalar(114, 114, 114), /*auto_=*/false, |
278 | 285 | /*scaleFill=*/false, /*scaleUp=*/true, /*stride=*/32); |
279 | 286 |
|
280 | | - ncnn::Mat in = ncnn::Mat::from_pixels_resize(letterboxImage.data, ncnn::Mat::PIXEL_BGR2RGB, letterboxImage.cols, letterboxImage.rows, 640, 640); |
| 287 | + ncnn::Mat in = ncnn::Mat::from_pixels_resize(letterboxImage.data, ncnn::Mat::PIXEL_BGR2RGB, letterboxImage.cols, letterboxImage.rows, inputImageShape.width, inputImageShape.height); |
281 | 288 |
|
282 | 289 | const float norm_vals[3] = {1 / 255.f, 1 / 255.f, 1 / 255.f}; |
283 | 290 | in.substract_mean_normalize(0, norm_vals); |
|
0 commit comments