-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.cpp
55 lines (49 loc) · 1.1 KB
/
2.cpp
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
51
52
53
54
55
#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <highgui/highgui_c.h>
#include <iostream>
#include "yolo5.h"
using namespace cv;
using namespace cv::dnn;
using namespace std;
int main()
{
string img_path = "/home/liqianqi/SVM/armor/0013.png";
string model_path = "/home/liqianqi/SVM/best.onnx";
YOLO test;
Net net;
if (test.readModel(net, model_path, false))
{
cout << "read net ok!" << endl;
}
else
{
cout << "read net false!" << endl;
return -1;
}
//生成随机颜色
vector<Scalar> color;
srand(time(0));
for (int i = 0; i < 80; i++)
{
int b = rand() % 256;
int g = rand() % 256;
int r = rand() % 256;
color.push_back(Scalar(b, g, r));
}
vector<Output> result;
Mat src = imread(img_path);
Mat img;
resize(src.clone(),img,Size(640,640));
imshow("resize",img);
if (test.Detect(img, net, result))
{
test.drawPred(img, result, color);
}
else
{
cout << "Detect Failed!" << endl;
}
//system("pause");
return 0;
}