MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
CameraContainer.cpp
Go to the documentation of this file.
1#include "CameraContainer.hpp"
2
8
9namespace MayaFlux::Kakshya {
10
12 Portal::Graphics::ImageFormat format, double frame_rate)
13 : VideoStreamContainer(width, height, format, frame_rate)
14{
15 m_num_frames = 1;
16
17 m_data.resize(1);
19
21
23 "CameraContainer created: {}x{} @{:.1f}fps ({} bytes/frame)",
24 width, height, frame_rate, get_frame_byte_size());
25}
26
28{
29 if (m_data.empty())
30 return nullptr;
31
32 auto [ptr, bytes] = variant_bytes_mutable(m_data[0]);
33 if (!ptr || bytes < get_frame_byte_size())
34 return nullptr;
35
36 return ptr;
37}
38
39void CameraContainer::setup_io(uint64_t reader_id)
40{
41 m_io_reader_id = reader_id;
44
46 "CameraContainer: wired IOService with reader_id={}", reader_id);
47}
48
50{
51 auto processor = std::make_shared<FrameAccessProcessor>();
52 processor->set_auto_advance(false);
53 processor->set_global_fps(m_frame_rate);
54 set_default_processor(processor);
55}
56
64
65} // namespace MayaFlux::Kakshya
#define MF_INFO(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
const uint8_t * ptr
uint32_t width
uint32_t height
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.
Registry::Service::IOService * m_io_service
CameraContainer(uint32_t width, uint32_t height, Portal::Graphics::ImageFormat format, double frame_rate=30.0)
Construct a CameraContainer with specified resolution and format.
void setup_io(uint64_t reader_id)
Wire the CameraIOService callback for demand-driven frame pulls.
size_t get_frame_element_count() const
Elements in one frame: width * height * channels.
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
Total byte size of one frame: width * height * bytes_per_pixel.
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.
DataVariant make_empty_storage(ImageFormat format, size_t element_count)
std::pair< uint8_t *, size_t > variant_bytes_mutable(DataVariant &v)
Get a mutable pointer to the raw bytes of a DataVariant and its size.
ImageFormat
User-friendly image format enum.
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