#pragma once #include "fgc/ICameraSource.h" #include "fgc/Logger.h" #include namespace fgc { // Synthetic camera for development without hardware. On trigger() it generates // a small RGB gradient frame (varying with time so successive captures differ) // and delivers it to the frame callback. class MockCameraSource : public ICameraSource { public: explicit MockCameraSource(int count = 1, uint32_t width = 640, uint32_t height = 480) : count_(count), width_(width), height_(height) {} void open() override { LOG_INFO << "[mock] camera opened (" << count_ << ")"; } void close() override {} void start() override { LOG_INFO << "[mock] camera acquisition started"; } void stop() override {} bool trigger() override { if (!callback_) return false; Frame f; f.width = width_; f.height = height_; f.channels = 3; f.cam_id = 0; f.timestamp_ms = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) .count(); f.data.resize(static_cast(width_) * height_ * 3); const uint8_t phase = static_cast(f.timestamp_ms); for (uint32_t y = 0; y < height_; ++y) { for (uint32_t x = 0; x < width_; ++x) { size_t i = (static_cast(y) * width_ + x) * 3; f.data[i + 0] = static_cast(x + phase); f.data[i + 1] = static_cast(y + phase); f.data[i + 2] = phase; } } callback_(f); return true; } void setFrameCallback(FrameCallback cb) override { callback_ = std::move(cb); } int cameraCount() const override { return count_; } private: int count_; uint32_t width_; uint32_t height_; FrameCallback callback_; }; } // namespace fgc