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

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

V4l modifs

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