-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWebcamStream.h
36 lines (31 loc) · 943 Bytes
/
WebcamStream.h
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
/**
* @file WebcamStream.h
* @brief header for the object WebcamStream which open camera,
* streams, and do threading
* @author Ari Nguyen
*/
#ifndef WEBCAMSTREAM_H
#define WEBCAMSTREAM_H
#include <mutex>
#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
class WebcamStream {
private:
int apiID = cv::CAP_ANY; // 0 = autodetect default API
int device_id = 0; // 0 = open default camera
bool stopped = false;
cv::VideoCapture stream; //--- INITIALIZE VIDEOCAPTURE
cv::Mat frame;
std::mutex m;
WebcamStream& operator=(const WebcamStream& o); // protect assignment
WebcamStream(const WebcamStream&) {}; // protect copy constructor
void init(); // base constructor
public:
WebcamStream();
WebcamStream(int device, int api);
void start();
void update();
cv::Mat *read();
void stop();
};
#endif