source: flair-src/trunk/lib/FlairSensorActuator/src/V4LCamera.h@ 349

Last change on this file since 349 was 349, checked in by Sanahuja Guillaume, 2 years ago

modifs v4l2

File size: 3.3 KB
Line 
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_H
14#define V4LCamera_H
15
16#include <Thread.h>
17#include "Camera.h"
18//todo use pimpl and remove this
19#include <linux/videodev2.h>
20#include <libv4l1-videodev.h>
21
22#define DEFAULT_V4L_BUFFERS 4
23
24namespace flair {
25 namespace core {
26 class Image;
27 }
28 namespace gui {
29 class DoubleSpinBox;
30 class CheckBox;
31 class Label;
32 }
33}
34
35namespace flair {
36namespace sensor {
37/*! \class V4LCamera
38*
39* \brief Base class for V4l camera
40*/
41class V4LCamera : public core::Thread, public Camera {
42public:
43 /*!
44 * \brief Constructor
45 *
46 * Construct a Camera.
47 * It will be child of the FrameworkManager.
48 *
49 * \param name name
50 * \param camera_index camera index
51 * \param width width
52 * \param height height
53 * \param format image format
54 * \param priority priority of the Thread
55 */
56 V4LCamera(std::string name,
57 uint8_t camera_index, uint16_t width, uint16_t height,
58 core::Image::Type::Format format, uint8_t priority);
59
60 /*!
61 * \brief Destructor
62 *
63 */
64 ~V4LCamera();
65
66 //hack for ps3eye in hds uav
67 //TODO: put this in ps3eye class
68 bool HasProblems(void);
69
70protected:
71 /*!
72 * \brief Set Gain
73 *
74 * \param value value between 0 and 1
75 */
76 virtual void SetGain(float value);
77
78 /*!
79 * \brief Set Auto Gain
80 *
81 * \param value value
82 */
83 virtual void SetAutoGain(bool value);
84
85 /*!
86 * \brief Set Exposure
87 *
88 * \param value value between 0 and 1
89 */
90 virtual void SetExposure(float value);
91
92 /*!
93 * \brief Set Auto Exposure
94 *
95 * \param value value
96 */
97 virtual void SetAutoExposure(bool value);
98
99 /*!
100 * \brief Set Brightness
101 *
102 * \param value value between 0 and 1
103 */
104 virtual void SetBrightness(float value);
105
106 /*!
107 * \brief Set Saturation
108 *
109 * \param value value between 0 and 1
110 */
111 virtual void SetSaturation(float value);
112
113 /*!
114 * \brief Set Hue
115 *
116 * \param value value between 0 and 1
117 */
118 virtual void SetHue(float value);
119
120 /*!
121 * \brief Set Contrast
122 *
123 * \param value value between 0 and 1
124 */
125 virtual void SetContrast(float value);
126
127private:
128 /*!
129 * \brief Update using provided datas
130 *
131 * Reimplemented from IODevice.
132 *
133 * \param data data from the parent to process
134 */
135 void UpdateFrom(const core::io_data *data){};
136
137 /*!
138 * \brief Run function
139 *
140 * Reimplemented from Thread.
141 *
142 */
143 void Run(void);
144
145 gui::Tab *sensor_tab;
146 gui::DoubleSpinBox *bright, *exposure, *gain, *contrast, *hue, *sharpness,*sat;
147 gui::CheckBox *autogain, *awb, *autoexposure;
148 gui::Label *fps;
149
150 int device;
151 bool hasProblems;
152 void* buffers[DEFAULT_V4L_BUFFERS];
153 int nbBuffers;
154 int bufferIndex;
155 char *imageData;
156
157 int init(int width, int height,unsigned long colorspace);
158 static int xioctl( int fd, int request, void *arg);
159 void SetProperty(int property,float value);
160 float GetProperty(int property);
161 int GrabFrame(void);
162 int AllocBuffers(void);
163 int allocBuffers (void);
164 int QueueBuffer(int index);
165
166
167int cvGrabFrame(void);
168int read_frame_v4l2(void);
169void cvRetrieveRawFrame(void);
170
171
172};
173} // end namespace sensor
174} // end namespace flair
175#endif // V4LCamera_H
Note: See TracBrowser for help on using the repository browser.