-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
37 lines (33 loc) · 995 Bytes
/
main.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
#include "llvm/StringRef.h"
#include "ntcore.h"
#include <iostream>
#include <llvm/raw_ostream.h>
#include <cscore.h>
#include <opencv2/core.hpp>
int main() {
auto inst = NT_GetDefaultInstance();
(void)inst;
cs::UsbCamera camera{"usbcam", 0};
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
cs::MjpegServer mjpegServer{"httpserver", 8081};
mjpegServer.SetSource(camera);
cs::CvSink cvsink{"cvsink"};
cvsink.SetSource(camera);
cs::CvSource cvsource{"cvsource", cs::VideoMode::kMJPEG, 320, 240, 30};
cs::MjpegServer cvMjpegServer{"cvhttpserver", 8082};
cvMjpegServer.SetSource(cvsource);
cv::Mat test;
cv::Mat flip;
for (;;) {
uint64_t time = cvsink.GrabFrame(test);
if (time == 0) {
std::cout << "error: " << cvsink.GetError() << std::endl;
continue;
}
std::cout << "got frame at time " << time << " size " << test.size()
<< std::endl;
cv::flip(test, flip, 0);
cvsource.PutFrame(flip);
}
return 0;
}