-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyolo_run.cpp
59 lines (44 loc) · 1.07 KB
/
yolo_run.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
56
57
58
59
#include <fstream>
#include <sstream>
#include <iostream>
#include <thread>
#include <vector>
// Required for dnn modules.
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
#include "yolo/src/yolo.h"
using namespace std;
using namespace cv;
using namespace dnn;
static String CONFIG = "./yolo/cfg/yolov3.cfg";
static String MODEL = "./yolo/cfg/yolov3.weights";
static String CLASSESFILE = "./yolo/cfg/coco_copy.names";
static int CHANNEL_CAPACITY = 10;
// Global variables
Yolo yolo(CONFIG, MODEL, CLASSESFILE);
void RunYolo(char *argv)
{
Mat frame;
frame_with_boxes *result = nullptr;
cv::VideoCapture cap;
cap.open(argv);
while(true)
{
cap.read(frame);
if(frame.empty())
break;
result = yolo.detect(frame);
cv:namedWindow("Display", cv::WINDOW_NORMAL);
cv::resizeWindow("Display", 1024, 1024);
cv::imshow("Display", result->frame);
char c = (char)cv::waitKey(25);
if (c == 27)
break;
}
}
int main(int argc, char **argv)
{
RunYolo(argv[1]);
}