PiImageStreamer
Loading...
Searching...
No Matches
NewCamera.h
1/*
2 * Camera.h
3 * This class will use the OpenCV Video capture feature to capture images from the camera on the Raspberry Pi.
4 * It is a free running task. Its thread grabs every frame the camera delivers, so that the camera's buffer never holds
5 * a stale frame, but it only decodes (retrieves) a frame when takePicture() has requested one. Each call to takePicture()
6 * returns the frame decoded in response to the previous call, so that the caller never waits on the camera.
7 */
8
9#ifndef CAMERA_H_
10#define CAMERA_H_
11
13#include <opencv2/opencv.hpp>
14#include <mutex>
15#include <atomic>
16
17
18namespace SWE4211RPi {
19
21private:
25 cv::VideoCapture *capture;
26
31 cv::Mat *lastFrame;
32
38
43 std::atomic<bool> frameRequested{false};
44
49 std::mutex mtx;
50
54 bool startupCompleted = false;
55public:
62 NewCamera(int width, int height, std::string threadName);
63
67 virtual ~NewCamera();
68
73 void taskMethod();
74
82 cv::Mat *takePicture();
83};
84}
85#endif /* CAMERA_H_ */
86
A runnable whose taskMethod is invoked back to back, with the rate set by whatever the taskMethod blo...
Definition FreeRunningRepeatingTask.h:43
Definition NewCamera.h:20
std::atomic< bool > frameRequested
Definition NewCamera.h:43
bool startupCompleted
Definition NewCamera.h:54
cv::VideoCapture * capture
Definition NewCamera.h:25
virtual ~NewCamera()
Definition NewCamera.cpp:55
cv::Mat * takePicture()
Definition NewCamera.cpp:113
cv::Mat * lastFrame
Definition NewCamera.h:31
std::mutex mtx
Definition NewCamera.h:49
cv::Mat capturedFrame
Definition NewCamera.h:37
void taskMethod()
Definition NewCamera.cpp:77