forked from berndporr/opencv-camera-callback
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.h
More file actions
58 lines (51 loc) · 1.13 KB
/
camera.h
File metadata and controls
58 lines (51 loc) · 1.13 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
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>
#include <stdlib.h>
#include <thread>
/*!
* Camera class with callback
* GNU GPL v3.0
* (C) 2022
* [Ross Gardiner](https://github.com/rossGardiner)
* [Adam Frew](https://github.com/Saweenbarra)
* [Alban Joseph](https://github.com/albanjoseph)
* [Lewis Russell](https://github.com/charger4241)
* Bernd Porr
*/
class Camera {
public:
/**
* Callback which needs to be implemented by the client
**/
struct SceneCallback {
virtual void nextScene(const cv::Mat &mat) = 0;
};
/**
* Default constructor
**/
Camera() = default;
/**
* Starts the acquisition from the camera
* and then the callback is called at the framerate.
**/
void start(int deviceID = 0, int apiID = 0);
/**
* Stops the data aqusisition
**/
void stop();
/**
* Registers the callback which receives the
* frames.
**/
void registerSceneCallback(SceneCallback* sc) {
sceneCallback = sc;
}
private:
void postFrame();
void threadLoop();
cv::VideoCapture videoCapture;
std::thread cameraThread;
bool isOn = false;
SceneCallback* sceneCallback = nullptr;
};