-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
40 lines (40 loc) · 1002 Bytes
/
example.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
#include "tuner.h"
#include <thread>
#include <chrono>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
Mat img;
void callback(const vector<int> ¶)
{
cout<<"Thresh: " << para[0]<<endl;
Mat gray;
cvtColor(img, gray, COLOR_BGR2GRAY);
threshold(gray, gray, para[0], 255, THRESH_BINARY);
publish(para[1], gray);
//imshow("w", gray);
//waitKey(30);
return;
}
signed main()
{
img = imread("a.webp");
assert(!img.empty());
waitKey(30);
Tuner tuner("tuneeee", callback);
tuner.addWidgets(NW("thresh", 255), VW("threshed"), VW("video"));
VideoCapture cap("aaa.mp4");
Mat frame;
if(tuner.start()) {
for(;;) {
if(cap.read(frame)) {
publish(tuner.data[2], frame);
this_thread::sleep_for(chrono::milliseconds(1000 / 30)); // fps=30
} else {
break;
}
}
}
this_thread::sleep_for(chrono::seconds(10000));
return 0;
}