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