-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.cpp
78 lines (61 loc) · 2.11 KB
/
main2.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <fstream>
#include <sstream>
#include <iostream>
#include <thread>
// Required for dnn modules.
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
using namespace dnn;
#include "yolo/src/yolo.h"
#include "scheduler/src/YoloDetector.h"
#include "scheduler/src/YoloPrinter.h"
#include "pipert/Scheduler.h"
#include "pipert/Profiler.h"
vector<string> classes;
int main(int argc, char **argv)
{
String configuration = "./yolo/cfg/yolov3-tiny.cfg";
String model = "./yolo/cfg/yolov3-tiny.weights";
string classesFile = "./yolo/cfg/coco.names";
Yolo yolo(configuration, model, classesFile);
// pipert::Scheduler sch(0, pipert::Profiler("file:profilerlog.txt"));
pipert::Scheduler sch(0, pipert::Profiler("udp:127.0.0.1:8000"));
int channel_capacity = 10;
pipert::PolledChannel<Mat> pc =
sch.CreatePolledChannel<Mat>("OutChannel", channel_capacity);
YoloDetector yd(&pc, yolo);
pipert::ScheduledChannel<Mat> sc2 =
sch.CreateScheduledChannel<Mat>("DetectorChannel", channel_capacity, nullptr, bind(&YoloDetector::Detect, &yd, placeholders::_1));
YoloPrinter yp(&sc2);
pipert::ScheduledChannel<Mat> sc1 =
sch.CreateScheduledChannel<Mat>("PrinterChannel", channel_capacity, nullptr, bind(&YoloPrinter::Print, &yp, placeholders::_1));
sch.Start();
pipert::Timer::Time time = pipert::Timer::time();
Mat frame;
cv::VideoCapture cap;
cap.open(argv[1]);
while (true)
{
cap.read(frame);
if (frame.empty())
break;
pipert::PacketToFill<Mat> packet_to_fill =
sc1.Acquire(time, frame.clone());
packet_to_fill.Push();
pipert::PacketToProcess<Mat> packet_to_process = pc.Poll();
while (packet_to_process.IsEmpty())
{
packet_to_process = pc.Poll();
}
sch.GetProfiler().GatherNSend();
cv::imshow("Display", packet_to_process.data());
char c = (char)cv::waitKey(25);
if (c == 27)
break;
}
sch.Stop();
}