blob: 37da5b0b1f4f94b5c823e8e581a29af79ba54ef5 (
plain)
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
|
#pragma once
#include <cstdint>
#include <queue>
#include <thread>
#include "constants.h"
#include "image.h"
#include "icamera.h"
class VeyeIMX287m : public ICamera
{
constexpr static char videoDevice[] = "/dev/video0";
public:
using buffer_t = std::array<uint8_t, img_size>;
public:
VeyeIMX287m();
~VeyeIMX287m() override;
public:
static std::vector<std::shared_ptr<ICamera>> search();
public:
bool startStream() override;
bool init();
bool setExposureTimeUs(int value) override;
bool setGain(int value) override;
bool setLaserLevel(int value) override;
bool setSomething(int value) override;
// bool dequeueImageBuffer(Image &image);
bool dequeueImageBuffer(size_t &image);
bool getImage(Image &image);
// Image &getImage();
public:
// libcamera::Signal<std::shared_ptr<Pixels>> newPixels;
// libcamera::Signal<std::shared_ptr<Image>> newImage;
private:
bool setCamParam(unsigned int v4l2controlId, int value);
bool openCam();
bool selectCam(int camIdx = 0);
bool initCam();
void dequeueFrameLoop(std::stop_token stopToken);
void calcFrameLoop(std::stop_token stopToken);
private:
int m_cam_fd{-1};
static constexpr uint8_t BUFFER_COUNT{8};
std::array<std::mutex, BUFFER_COUNT> m_imageMutexes;
std::array<Image, BUFFER_COUNT> m_images;
std::array<std::mutex, BUFFER_COUNT> m_bufferMutexes;
std::array<uint8_t *, BUFFER_COUNT> m_videoBuffers;
// std::mutex m_queueMtx;
std::mutex m_camMtx;
std::queue<size_t> m_buffersQueue;
std::jthread m_streamThread;
std::jthread m_calcThreads[4];
};
|