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:
cristhian aguilera
2026-03-25 09:11:00 -03:00
parent 9ac14c07e2
commit 55a87d3a14
8 changed files with 430 additions and 298 deletions
+50
View File
@@ -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