Download ultralytics/examples/YOLOv8-OpenVINO-CPP-Inference/main.cc from voidljc/cherrydata: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/voidljc/cherrydata/resolve/main/ultralytics/examples/YOLOv8-OpenVINO-CPP-Inference/main.cc
- Command line
-
hf download hf://voidljc/cherrydata/ultralytics/examples/YOLOv8-OpenVINO-CPP-Inference/main.cc
-
curl -L -o main.cc https://huggingface.co/voidljc/cherrydata/resolve/main/ultralytics/examples/YOLOv8-OpenVINO-CPP-Inference/main.cc
1.11 kB
| 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; | |
| } | |