[352] | 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
|
---|
[403] | 50 | * \param useMemoryUsrPtr true to use memory user pointer (ex with cmem on omap3730), false to use mmap
|
---|
[352] | 51 | */
|
---|
| 52 | V4LCamera_impl(flair::sensor::V4LCamera *self,std::string name,
|
---|
| 53 | uint8_t camera_index, uint16_t width, uint16_t height,
|
---|
[403] | 54 | flair::core::Image::Type::Format format,bool useMemoryUsrPtr);
|
---|
[352] | 55 |
|
---|
| 56 | /*!
|
---|
| 57 | * \brief Destructor
|
---|
| 58 | *
|
---|
| 59 | */
|
---|
| 60 | ~V4LCamera_impl();
|
---|
| 61 |
|
---|
| 62 | /*!
|
---|
| 63 | * \brief Run function
|
---|
| 64 | *
|
---|
| 65 | */
|
---|
| 66 | void Run(void);
|
---|
| 67 |
|
---|
| 68 | bool hasProblems;
|
---|
| 69 |
|
---|
| 70 | /*!
|
---|
| 71 | * \brief Set Gain
|
---|
| 72 | *
|
---|
| 73 | * \param value value between 0 and 1
|
---|
| 74 | */
|
---|
| 75 | void SetGain(float value);
|
---|
| 76 |
|
---|
| 77 | /*!
|
---|
| 78 | * \brief Set Auto Gain
|
---|
| 79 | *
|
---|
| 80 | * \param value value
|
---|
| 81 | */
|
---|
| 82 | void SetAutoGain(bool value);
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | * \brief Set Exposure
|
---|
| 86 | *
|
---|
| 87 | * \param value value between 0 and 1
|
---|
| 88 | */
|
---|
| 89 | void SetExposure(float value);
|
---|
| 90 |
|
---|
| 91 | /*!
|
---|
| 92 | * \brief Set Auto Exposure
|
---|
| 93 | *
|
---|
| 94 | * \param value value
|
---|
| 95 | */
|
---|
| 96 | void SetAutoExposure(bool value);
|
---|
| 97 |
|
---|
| 98 | /*!
|
---|
| 99 | * \brief Set Brightness
|
---|
| 100 | *
|
---|
| 101 | * \param value value between 0 and 1
|
---|
| 102 | */
|
---|
| 103 | void SetBrightness(float value);
|
---|
| 104 |
|
---|
| 105 | /*!
|
---|
| 106 | * \brief Set Saturation
|
---|
| 107 | *
|
---|
| 108 | * \param value value between 0 and 1
|
---|
| 109 | */
|
---|
| 110 | void SetSaturation(float value);
|
---|
| 111 |
|
---|
| 112 | /*!
|
---|
| 113 | * \brief Set Hue
|
---|
| 114 | *
|
---|
| 115 | * \param value value between 0 and 1
|
---|
| 116 | */
|
---|
| 117 | void SetHue(float value);
|
---|
| 118 |
|
---|
| 119 | /*!
|
---|
| 120 | * \brief Set Contrast
|
---|
| 121 | *
|
---|
| 122 | * \param value value between 0 and 1
|
---|
| 123 | */
|
---|
| 124 | void SetContrast(float value);
|
---|
| 125 |
|
---|
| 126 | private:
|
---|
| 127 |
|
---|
| 128 | flair::sensor::V4LCamera *self;
|
---|
| 129 | flair::gui::Tab *sensor_tab;
|
---|
| 130 | flair::gui::DoubleSpinBox *bright, *exposure, *gain, *contrast, *hue, *sharpness,*sat;
|
---|
| 131 | flair::gui::CheckBox *autogain, *awb, *autoexposure;
|
---|
| 132 | flair::gui::Label *fps;
|
---|
| 133 |
|
---|
| 134 | int device;
|
---|
| 135 |
|
---|
| 136 | void* buffers[DEFAULT_V4L_BUFFERS];
|
---|
| 137 | int nbBuffers;
|
---|
| 138 | char *imageData;
|
---|
| 139 | bool useMemoryUsrPtr;
|
---|
| 140 |
|
---|
| 141 | int Init(int width, int height,unsigned long colorspace);
|
---|
| 142 | int xioctl( int fd, int request, void *arg);
|
---|
| 143 | void SetProperty(int property,float value);
|
---|
| 144 | float GetProperty(int property);
|
---|
| 145 | int GrabFrame(void);
|
---|
| 146 | int AllocV4LBuffers(void);
|
---|
| 147 | int AllocUserBuffers(void);
|
---|
| 148 | int QueueBuffer(int index);
|
---|
| 149 | int QueueBuffer(struct v4l2_buffer *buf);
|
---|
| 150 | struct v4l2_buffer dQueuedBuffer;
|
---|
| 151 | };
|
---|
| 152 |
|
---|
| 153 | #endif // V4LCAMERA_IMPL_H
|
---|