Switch Controller
Loading...
Searching...
No Matches
TestVideo.h
Go to the documentation of this file.
1#pragma once
2
3#include "pch.h"
4
8
9#include <boost/program_options.hpp>
10
11void TestVideo(const boost::program_options::variables_map &vm,
12 const std::map<std::string, std::string> &ffmpegOptions) {
13 std::vector<std::unique_ptr<FFmpegFrameSink>> sinks;
14 sinks.push_back(std::make_unique<VideoFrameSink>());
15 auto videoSink = dynamic_cast<VideoFrameSink *>(sinks[0].get());
16
17 av_log_set_level(AV_LOG_QUIET);
18
19 FFmpegRecorder recorder(vm["inputFormat"].as<std::string>(),
20 vm["deviceName"].as<std::string>(), ffmpegOptions,
21 sinks);
22
23 std::vector<uint8_t> data;
24 long long lastFrame = videoSink->getData(data);
25 cv::Mat mat = cv::Mat(videoSink->getHeight(), videoSink->getWidth(),
26 CV_8UC3, data.data());
27
28 std::atomic<bool> running = true;
29 std::string title = std::to_string(
30 std::chrono::steady_clock::now().time_since_epoch().count());
31
32 std::thread t([&]() {
33 while (running.load()) {
34 lastFrame = videoSink->getNextData(data, lastFrame);
35 cv::imshow(title, mat);
36 cv::waitKey(1);
37 }
38 });
39
40 std::cout << "Press enter to stop\n";
41 std::cin.get();
42 running.store(false);
43 t.join();
44}
void TestVideo(const boost::program_options::variables_map &vm, const std::map< std::string, std::string > &ffmpegOptions)
Definition: TestVideo.h:11
Definition: FFmpegRecorder.h:12
Definition: VideoFrameSink.h:17