MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
CameraContainer.cpp
Go to the documentation of this file.
1#include "CameraContainer.hpp"
2
7
8namespace MayaFlux::Kakshya {
9
10CameraContainer::CameraContainer(uint32_t width, uint32_t height,
11 uint32_t channels, double frame_rate)
12 : VideoStreamContainer(width, height, channels, frame_rate)
13{
14 m_num_frames = 1;
15
16 const size_t frame_bytes = get_frame_byte_size();
17
18 m_data.resize(1);
19 auto& pixels = m_data[0].emplace<std::vector<uint8_t>>();
20 pixels.resize(frame_bytes, 0);
21
23
25 "CameraContainer created: {}x{} @{:.1f}fps ({} bytes/frame)",
26 width, height, frame_rate, frame_bytes);
27}
28
30{
31 if (m_data.empty())
32 return nullptr;
33
34 auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
35 if (!pixels || pixels->empty())
36 return nullptr;
37
38 return pixels->data();
39}
40
41void CameraContainer::setup_io(uint64_t reader_id)
42{
43 m_io_reader_id = reader_id;
46
48 "CameraContainer: wired IOService with reader_id={}", reader_id);
49}
50
52{
53 auto processor = std::make_shared<FrameAccessProcessor>();
54 processor->set_auto_advance(false);
55 processor->set_global_fps(m_frame_rate);
56 set_default_processor(processor);
57}
58
66
67} // namespace MayaFlux::Kakshya
#define MF_INFO(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
void create_default_processor() override
Create FrameAccessProcessor with auto_advance disabled.
uint8_t * mutable_frame_ptr()
Mutable pointer into m_data[0] for the caller to write decoded pixels.
void process_default() override
Override to fire request_frame after each processor cycle.
CameraContainer(uint32_t width, uint32_t height, uint32_t channels=4, double frame_rate=30.0)
Construct a CameraContainer with specified resolution.
Registry::Service::IOService * m_io_service
void setup_io(uint64_t reader_id)
Wire the CameraIOService callback for demand-driven frame pulls.
void set_default_processor(const std::shared_ptr< DataProcessor > &processor) override
Set the default data processor for this container.
size_t get_frame_byte_size() const
Get the total byte size of one frame (width * height * channels).
void process_default() override
Process the container's data using the default processor.
Concrete base implementation for streaming video containers.
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ Init
Engine/subsystem initialization.
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::function< void(uint64_t reader_id)> request_frame
Request the identified camera reader to pull the next frame.
Definition IOService.hpp:44
Backend IO streaming service interface.
Definition IOService.hpp:18