-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (32 loc) · 1.36 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (32 loc) · 1.36 KB
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
43
44
45
46
47
48
49
50
// Include necessary headers
#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>
#include "YOLO12.hpp"
#include <Windows.h>
int main() {
// Configuration parameters
const std::string labelsPath = "coco.names"; // Path to class labels
const std::string modelPath = "yolov12l.onnx"; // Path to YOLO12 model
const std::string imagePath = "data/dog.jpg"; // Path to input image
bool isGPU = false; // Set to false for CPU processing
// Initialize the YOLO12 detector
YOLO12Detector detector(modelPath, labelsPath, isGPU);
while (1)
{
DWORD start_time = GetTickCount();
// Load an image
cv::Mat image = cv::imread(imagePath);
// Perform object detection to get bboxs
std::vector<Detection> detections = detector.detect(image);
// Draw bounding boxes on the image
detector.drawBoundingBoxMask(image, detections);
auto end = std::chrono::high_resolution_clock::now();
DWORD end_time = GetTickCount();
printf("The run time is:%dms\n", end_time - start_time);
}
// Display the annotated image
//cv::imshow("YOLO12 Detections", image);
cv::waitKey(0); // Wait indefinitely until a key is pressed
return 0;
}