mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Add USB and OpenCV processed dual stream example.
This commit is contained in:
27
examples/usbcvstream/usbcvstream.cpp
Normal file
27
examples/usbcvstream/usbcvstream.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "cameraserver.h"
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
cs::USBCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
cs::MJPEGServer mjpegServer{"httpserver", 8080};
|
||||
mjpegServer.SetSource(camera);
|
||||
cs::CvSink cvsink{"cvsink"};
|
||||
cvsink.SetSource(camera);
|
||||
cs::CvSource cvsource{"cvsource", cs::VideoMode::kMJPEG, 320, 240, 30};
|
||||
cs::MJPEGServer cvMjpegServer{"cvhttpserver", 8081};
|
||||
cvMjpegServer.SetSource(cvsource);
|
||||
|
||||
cv::Mat test;
|
||||
cv::Mat flip;
|
||||
for (;;) {
|
||||
uint64_t time = cvsink.GrabFrame(test);
|
||||
std::cout << "got frame at time " << time << " size " << test.size() << std::endl;
|
||||
if (time == 0) continue;
|
||||
cv::flip(test, flip, 0);
|
||||
cvsource.PutFrame(flip);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user