-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcamera.h
More file actions
76 lines (56 loc) · 1.49 KB
/
camera.h
File metadata and controls
76 lines (56 loc) · 1.49 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef CAMERA_H
#define CAMERA_H
#include <thread>
#include <atomic>
#include <opencv2/core/core.hpp>
#include "opencv2/videoio.hpp"
#include <opencv2/imgproc/imgproc.hpp>
#include <thread>
#include "frame-grabber.h"
#include <string>
#include <vector>
#include "work-queue.h"
class Camera
{
public:
enum Mode {
cap_320_by_240_by_30fps
};
int cam_number = 10;
double get_fps();
Mode mode = cap_320_by_240_by_30fps;
Camera();
~Camera();
void set_recording_path(std::string path);
void warm_up();
void prepare_video_writer(std::string path);
void begin_capture_movie();
void end_capture_movie();
void release_video_writer();
bool get_latest_frame();
void write_latest_frame();
int get_frame_count_grabbed();
int get_frame_count_saved();
void load_calibration_from_json(std::string camera_name, std::string json_path);
void undistort(cv::Mat frame);
bool frame_is_ready();
ObservableTopic<const cv::Mat> frames_topic;
cv::Mat camera_matrix;
cv::Mat dist_coefs;
cv::Mat latest_frame;
FrameGrabber grabber; // todo: make private again, adding here so clients can use the queue
private:
WorkQueue<cv::Mat> frames_queue{1};
int fps = 0;
bool warmed_up = false;
std::string recording_path;
int frame_count_saved = 0;
cv::VideoWriter output_video;
std::atomic<bool> record_on; //this is lock free
std::thread record_thread;
void record_thread_proc();
cv::VideoCapture cap;
};
void test_camera();
void test_stereo_camera();
#endif // CAMERA_H