32 lines
761 B
C++
32 lines
761 B
C++
#pragma once
|
|
#include "image.hpp"
|
|
#include <atomic>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
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;
|
|
};
|
|
// 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();
|
|
}
|