49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
//
|
|
// Created by lgv on 2026/2/26.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
#include "devices/camera/abstract_camera.h"
|
|
|
|
namespace cmvr::device {
|
|
|
|
class MujocoCamera final : public AbstractCamera {
|
|
public:
|
|
using FetchRgbdFn = std::function<bool(std::vector<unsigned char>& rgb,
|
|
std::vector<float>& depth,
|
|
int& width,
|
|
int& height,
|
|
uint64_t& frame_id)>;
|
|
|
|
explicit MujocoCamera(FetchRgbdFn fetch_rgbd_fn);
|
|
~MujocoCamera() override = default;
|
|
|
|
std::string typeName() const override { return "MujocoCamera"; }
|
|
void setFovyDeg(double fovy_deg);
|
|
void setConsumeNewFrameOnly(bool enable);
|
|
|
|
void getRGBImage(cv::Mat& color, Rs2Intrinsics& intrinsics) override;
|
|
void getDepthImage(cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
|
|
void getRGBDImages(cv::Mat& color, cv::Mat& depth, Rs2Intrinsics& intrinsics) override;
|
|
|
|
private:
|
|
bool fetch(cv::Mat& color, cv::Mat& depth, Rs2Intrinsics& intrinsics);
|
|
void fillIntrinsics(int width, int height, Rs2Intrinsics& intrinsics) const;
|
|
|
|
private:
|
|
FetchRgbdFn fetch_rgbd_fn_;
|
|
mutable std::mutex mtx_;
|
|
double fovy_deg_{60.0};
|
|
bool consume_new_frame_only_{true};
|
|
uint64_t last_frame_id_{0};
|
|
bool has_last_frame_id_{false};
|
|
};
|
|
|
|
} // namespace cmvr::device
|