refactor ZED capture into modular camera class with env config
Extract camera lifecycle (open, warmup, grab, close) and
environment-based configuration into src/zed/camera.{h,cc}.
Thin main.cc now only handles the dora event loop.
Closes #2
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <sl/Camera.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace zed {
|
||||
|
||||
struct Config {
|
||||
int resolution = 720;
|
||||
int fps = 15;
|
||||
std::string depth_mode = "NEURAL";
|
||||
int depth_min_mm = 10;
|
||||
int depth_max_mm = 500;
|
||||
bool depth_fill = false;
|
||||
std::string flip = "ON";
|
||||
int warmup_frames = 30;
|
||||
int retry_interval_ms = 5000;
|
||||
|
||||
static Config from_env();
|
||||
};
|
||||
|
||||
struct Calibration {
|
||||
float fx, fy, cx, cy;
|
||||
std::vector<double> distortion;
|
||||
};
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
explicit Camera(const Config& config);
|
||||
~Camera();
|
||||
|
||||
void open();
|
||||
void close();
|
||||
void warmup();
|
||||
bool grab();
|
||||
Calibration calibration() const;
|
||||
sl::Mat& image();
|
||||
sl::Mat& point_cloud();
|
||||
|
||||
private:
|
||||
Config config_;
|
||||
sl::Camera zed_;
|
||||
sl::InitParameters init_params_;
|
||||
sl::RuntimeParameters runtime_params_;
|
||||
sl::Mat image_mat_;
|
||||
sl::Mat point_cloud_mat_;
|
||||
};
|
||||
|
||||
} // namespace zed
|
||||
Reference in New Issue
Block a user