ACMX 2.136.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
media_helpers.hpp
Go to the documentation of this file.
1#ifndef ACMXVK_APP_MEDIA_HELPERS_HPP
2#define ACMXVK_APP_MEDIA_HELPERS_HPP
3
4#include "options.hpp"
5
6#include <opencv2/core.hpp>
7
8#include <condition_variable>
9#include <cstdint>
10#include <mutex>
11#include <thread>
12
13namespace mxvk {
14 class VK_Capture;
15}
16
17namespace acmxvk {
19 public:
20 LatestCameraFrame() = default;
26
27 void start(mxvk::VK_Capture &source);
28 void stop() noexcept;
29 [[nodiscard]] bool takeLatest(cv::Mat &frame, bool wait_for_first);
30
31 private:
32 void captureLoop() noexcept;
33
34 mxvk::VK_Capture *capture_source = nullptr;
35 cv::Mat latest_frame;
36 std::thread capture_thread;
37 std::mutex frame_mutex;
38 std::condition_variable frame_condition;
39 std::uint64_t published_generation = 0;
40 std::uint64_t consumed_generation = 0;
41 bool stopping = true;
42 };
43} // namespace acmxvk
44
45#endif
LatestCameraFrame & operator=(const LatestCameraFrame &)=delete
std::uint64_t published_generation
bool takeLatest(cv::Mat &frame, bool wait_for_first)
void start(mxvk::VK_Capture &source)
std::condition_variable frame_condition
LatestCameraFrame(LatestCameraFrame &&)=delete
std::uint64_t consumed_generation
LatestCameraFrame & operator=(LatestCameraFrame &&)=delete
mxvk::VK_Capture * capture_source
LatestCameraFrame(const LatestCameraFrame &)=delete