35 lines
926 B
C++
35 lines
926 B
C++
#pragma once
|
|
#include "image.hpp"
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
namespace cms {
|
|
struct CameraConfig {
|
|
std::string device{"/dev/video5"};
|
|
int width{1920},height{1536},fps{30},buffers{4},timeout_ms{2000};
|
|
};
|
|
struct CapturedFrame {
|
|
CaptureMetadata metadata;
|
|
std::shared_ptr<const BgrImage> image;
|
|
// Present only for offline replay; keeps original timestamps and context.
|
|
std::shared_ptr<const nlohmann::json> replay_record;
|
|
};
|
|
// The capture thread exclusively owns read(); requestStop() is thread safe.
|
|
class Camera {
|
|
public:
|
|
explicit Camera(CameraConfig config);
|
|
~Camera();
|
|
Camera(Camera const&)=delete;
|
|
Camera& operator=(Camera const&)=delete;
|
|
std::optional<CapturedFrame> read();
|
|
void requestStop() noexcept;
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_;
|
|
};
|
|
std::uint64_t monotonicNs();
|
|
}
|