File size: 1,149 Bytes
f6228f9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#include "inference.h"
#include <iostream>
#include <opencv2/highgui.hpp>
int main(int argc, char **argv) {
// Check if the correct number of arguments is provided
if (argc != 3) {
std::cerr << "usage: " << argv[0] << " <model_path> <image_path>" << std::endl;
return 1;
}
// Get the model and image paths from the command-line arguments
const std::string model_path = argv[1];
const std::string image_path = argv[2];
// Read the input image
cv::Mat image = cv::imread(image_path);
// Check if the image was successfully loaded
if (image.empty()) {
std::cerr << "ERROR: image is empty" << std::endl;
return 1;
}
// Define the confidence and NMS thresholds
const float confidence_threshold = 0.5;
const float NMS_threshold = 0.5;
// Initialize the YOLO inference with the specified model and parameters
yolo::Inference inference(model_path, cv::Size(640, 640), confidence_threshold, NMS_threshold);
// Run inference on the input image
inference.RunInference(image);
// Display the image with the detections
cv::imshow("image", image);
cv::waitKey(0);
return 0;
}
|