-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvideo_cam.h
More file actions
32 lines (29 loc) · 1.03 KB
/
video_cam.h
File metadata and controls
32 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include "infinite_sense.h"
#include <opencv2/opencv.hpp>
#include <atomic>
#include <thread>
#include <vector>
#include <mutex>
namespace infinite_sense {
// 继承自 Sensor 类,会自动调用初始化,开始,停止等函数
class VideoCam final : public Sensor {
public:
explicit VideoCam(const std::vector<std::pair<std::string, int>>& cam_list);
~VideoCam() override;
bool Initialization() override; // 相机初始化函数
void Stop() override; // 相机停止采集函数
void Start() override;// 相机参数函数
private:
// 具体读取相机的实现
void Receive(void* handle, const std::string&) override;
// opencv 读取 video 设备的函数
std::map<std::string, cv::VideoCapture> caps_;
std::vector<std::pair<std::string, int>> cam_lists_;
// 是否初始化的标识
std::atomic<bool> is_initialized_{false};
// 读取图像设备的多线程,一个线程读取一个相机
std::mutex cap_mutex_;
std::vector<std::thread> cam_threads_;
};
} // namespace infinite_sense