forked from jtanx/omxcv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglsl-test.cpp
executable file
·61 lines (48 loc) · 1.62 KB
/
glsl-test.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
/**
* @file glsl-test.cpp
* @brief Simple testing application for GLSL.
*/
#include "image_gpu.h"
#include <cstdio>
#include <cstdlib>
#include <chrono>
#include <thread>
#include <opencv2/opencv.hpp>
#define TIMEDIFF(start) (duration_cast<microseconds>(steady_clock::now() - start).count())
using std::this_thread::sleep_for;
using std::chrono::microseconds;
using std::chrono::milliseconds;
using std::chrono::steady_clock;
using std::chrono::duration_cast;
using namespace picopter;
int main(int argc, char *argv[]) {
cv::VideoCapture capture(-1);
int width = 640, height = 480, framecount = 200, processed = 0;
if (argc >= 3) {
width = atoi(argv[1]);
height = atoi(argv[2]);
}
if (argc >= 4) {
framecount = atoi(argv[3]);
}
//Open the camera (testing only)
if (!capture.isOpened()) {
printf("Cannot open camera\n");
return 1;
}
//We can try to set these, but the camera may ignore this anyway...
capture.set(CV_CAP_PROP_FRAME_WIDTH, width);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, height);
capture.set(CV_CAP_PROP_FPS, 30);
auto totstart = steady_clock::now();
cv::Mat image, out;
//FILE *fp = fopen("log.txt", "w");
GLThreshold t(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT));
for(int i = 0; i < framecount; i++) {
capture >> image;
auto start = steady_clock::now();
t.Threshold(image, out);
printf("Processed frame %4d (%4d ms)\r", i+1, (int)TIMEDIFF(start)/1000);
fflush(stdout);
}
}