1 | // %flair:license{
|
---|
2 | // This file is part of the Flair framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %flair:license}
|
---|
5 | /*!
|
---|
6 | * \file V4LCamera.h
|
---|
7 | * \brief Base class for V4l camera
|
---|
8 | * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
9 | * \date 2014/07/17
|
---|
10 | * \version 4.0
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef V4LCAMERA_IMPL_H
|
---|
14 | #define V4LCAMERA_IMPL_H
|
---|
15 |
|
---|
16 | #include "V4LCamera.h"
|
---|
17 | #include <linux/videodev2.h>
|
---|
18 |
|
---|
19 | #define DEFAULT_V4L_BUFFERS 4
|
---|
20 |
|
---|
21 | namespace flair {
|
---|
22 | namespace core {
|
---|
23 | class Image;
|
---|
24 | }
|
---|
25 | namespace gui {
|
---|
26 | class DoubleSpinBox;
|
---|
27 | class CheckBox;
|
---|
28 | class Label;
|
---|
29 | }
|
---|
30 | }
|
---|
31 |
|
---|
32 |
|
---|
33 | /*! \class V4LCamera_impl
|
---|
34 | *
|
---|
35 | * \brief Base class for V4l camera
|
---|
36 | */
|
---|
37 | class V4LCamera_impl {
|
---|
38 | public:
|
---|
39 | /*!
|
---|
40 | * \brief Constructor
|
---|
41 | *
|
---|
42 | * Construct a Camera.
|
---|
43 | * It will be child of the FrameworkManager.
|
---|
44 | *
|
---|
45 | * \param name name
|
---|
46 | * \param camera_index camera index
|
---|
47 | * \param width width
|
---|
48 | * \param height height
|
---|
49 | * \param format image format
|
---|
50 | */
|
---|
51 | V4LCamera_impl(flair::sensor::V4LCamera *self,std::string name,
|
---|
52 | uint8_t camera_index, uint16_t width, uint16_t height,
|
---|
53 | flair::core::Image::Type::Format format);
|
---|
54 |
|
---|
55 | /*!
|
---|
56 | * \brief Destructor
|
---|
57 | *
|
---|
58 | */
|
---|
59 | ~V4LCamera_impl();
|
---|
60 |
|
---|
61 | /*!
|
---|
62 | * \brief Run function
|
---|
63 | *
|
---|
64 | */
|
---|
65 | void Run(void);
|
---|
66 |
|
---|
67 | bool hasProblems;
|
---|
68 |
|
---|
69 | /*!
|
---|
70 | * \brief Set Gain
|
---|
71 | *
|
---|
72 | * \param value value between 0 and 1
|
---|
73 | */
|
---|
74 | void SetGain(float value);
|
---|
75 |
|
---|
76 | /*!
|
---|
77 | * \brief Set Auto Gain
|
---|
78 | *
|
---|
79 | * \param value value
|
---|
80 | */
|
---|
81 | void SetAutoGain(bool value);
|
---|
82 |
|
---|
83 | /*!
|
---|
84 | * \brief Set Exposure
|
---|
85 | *
|
---|
86 | * \param value value between 0 and 1
|
---|
87 | */
|
---|
88 | void SetExposure(float value);
|
---|
89 |
|
---|
90 | /*!
|
---|
91 | * \brief Set Auto Exposure
|
---|
92 | *
|
---|
93 | * \param value value
|
---|
94 | */
|
---|
95 | void SetAutoExposure(bool value);
|
---|
96 |
|
---|
97 | /*!
|
---|
98 | * \brief Set Brightness
|
---|
99 | *
|
---|
100 | * \param value value between 0 and 1
|
---|
101 | */
|
---|
102 | void SetBrightness(float value);
|
---|
103 |
|
---|
104 | /*!
|
---|
105 | * \brief Set Saturation
|
---|
106 | *
|
---|
107 | * \param value value between 0 and 1
|
---|
108 | */
|
---|
109 | void SetSaturation(float value);
|
---|
110 |
|
---|
111 | /*!
|
---|
112 | * \brief Set Hue
|
---|
113 | *
|
---|
114 | * \param value value between 0 and 1
|
---|
115 | */
|
---|
116 | void SetHue(float value);
|
---|
117 |
|
---|
118 | /*!
|
---|
119 | * \brief Set Contrast
|
---|
120 | *
|
---|
121 | * \param value value between 0 and 1
|
---|
122 | */
|
---|
123 | void SetContrast(float value);
|
---|
124 |
|
---|
125 | private:
|
---|
126 |
|
---|
127 | flair::sensor::V4LCamera *self;
|
---|
128 | flair::gui::Tab *sensor_tab;
|
---|
129 | flair::gui::DoubleSpinBox *bright, *exposure, *gain, *contrast, *hue, *sharpness,*sat;
|
---|
130 | flair::gui::CheckBox *autogain, *awb, *autoexposure;
|
---|
131 | flair::gui::Label *fps;
|
---|
132 |
|
---|
133 | int device;
|
---|
134 |
|
---|
135 | void* buffers[DEFAULT_V4L_BUFFERS];
|
---|
136 | int nbBuffers;
|
---|
137 | char *imageData;
|
---|
138 | bool useMemoryUsrPtr;
|
---|
139 |
|
---|
140 | int Init(int width, int height,unsigned long colorspace);
|
---|
141 | int xioctl( int fd, int request, void *arg);
|
---|
142 | void SetProperty(int property,float value);
|
---|
143 | float GetProperty(int property);
|
---|
144 | int GrabFrame(void);
|
---|
145 | int AllocV4LBuffers(void);
|
---|
146 | int AllocUserBuffers(void);
|
---|
147 | int QueueBuffer(int index);
|
---|
148 | int QueueBuffer(struct v4l2_buffer *buf);
|
---|
149 | struct v4l2_buffer dQueuedBuffer;
|
---|
150 | };
|
---|
151 |
|
---|
152 | #endif // V4LCAMERA_IMPL_H
|
---|