1 | /* |
2 | Copyright (c) 2013, Broadcom Europe Ltd |
3 | Copyright (c) 2013, James Hughes |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: |
8 | * Redistributions of source code must retain the above copyright |
9 | notice, this list of conditions and the following disclaimer. |
10 | * Redistributions in binary form must reproduce the above copyright |
11 | notice, this list of conditions and the following disclaimer in the |
12 | documentation and/or other materials provided with the distribution. |
13 | * Neither the name of the copyright holder nor the |
14 | names of its contributors may be used to endorse or promote products |
15 | derived from this software without specific prior written permission. |
16 | |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
28 | |
29 | #ifndef RASPICAMCONTROL_H_ |
30 | #define RASPICAMCONTROL_H_ |
31 | |
32 | /* Various parameters |
33 | * |
34 | * Exposure Mode |
35 | * MMAL_PARAM_EXPOSUREMODE_OFF, |
36 | MMAL_PARAM_EXPOSUREMODE_AUTO, |
37 | MMAL_PARAM_EXPOSUREMODE_NIGHT, |
38 | MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, |
39 | MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, |
40 | MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, |
41 | MMAL_PARAM_EXPOSUREMODE_SPORTS, |
42 | MMAL_PARAM_EXPOSUREMODE_SNOW, |
43 | MMAL_PARAM_EXPOSUREMODE_BEACH, |
44 | MMAL_PARAM_EXPOSUREMODE_VERYLONG, |
45 | MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, |
46 | MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, |
47 | MMAL_PARAM_EXPOSUREMODE_FIREWORKS, |
48 | * |
49 | * Flicker Avoid Mode |
50 | * MMAL_PARAM_FLICKERAVOID_OFF, |
51 | MMAL_PARAM_FLICKERAVOID_AUTO, |
52 | MMAL_PARAM_FLICKERAVOID_50HZ, |
53 | MMAL_PARAM_FLICKERAVOID_60HZ, |
54 | * |
55 | * AWB Mode |
56 | * MMAL_PARAM_AWBMODE_OFF, |
57 | MMAL_PARAM_AWBMODE_AUTO, |
58 | MMAL_PARAM_AWBMODE_SUNLIGHT, |
59 | MMAL_PARAM_AWBMODE_CLOUDY, |
60 | MMAL_PARAM_AWBMODE_SHADE, |
61 | MMAL_PARAM_AWBMODE_TUNGSTEN, |
62 | MMAL_PARAM_AWBMODE_FLUORESCENT, |
63 | MMAL_PARAM_AWBMODE_INCANDESCENT, |
64 | MMAL_PARAM_AWBMODE_FLASH, |
65 | MMAL_PARAM_AWBMODE_HORIZON, |
66 | MMAL_PARAM_AWBMODE_GREYWORLD |
67 | * |
68 | * Image FX |
69 | MMAL_PARAM_IMAGEFX_NONE, |
70 | MMAL_PARAM_IMAGEFX_NEGATIVE, |
71 | MMAL_PARAM_IMAGEFX_SOLARIZE, |
72 | MMAL_PARAM_IMAGEFX_POSTERIZE, |
73 | MMAL_PARAM_IMAGEFX_WHITEBOARD, |
74 | MMAL_PARAM_IMAGEFX_BLACKBOARD, |
75 | MMAL_PARAM_IMAGEFX_SKETCH, |
76 | MMAL_PARAM_IMAGEFX_DENOISE, |
77 | MMAL_PARAM_IMAGEFX_EMBOSS, |
78 | MMAL_PARAM_IMAGEFX_OILPAINT, |
79 | MMAL_PARAM_IMAGEFX_HATCH, |
80 | MMAL_PARAM_IMAGEFX_GPEN, |
81 | MMAL_PARAM_IMAGEFX_PASTEL, |
82 | MMAL_PARAM_IMAGEFX_WATERCOLOUR, |
83 | MMAL_PARAM_IMAGEFX_FILM, |
84 | MMAL_PARAM_IMAGEFX_BLUR, |
85 | MMAL_PARAM_IMAGEFX_SATURATION, |
86 | MMAL_PARAM_IMAGEFX_COLOURSWAP, |
87 | MMAL_PARAM_IMAGEFX_WASHEDOUT, |
88 | MMAL_PARAM_IMAGEFX_POSTERISE, |
89 | MMAL_PARAM_IMAGEFX_COLOURPOINT, |
90 | MMAL_PARAM_IMAGEFX_COLOURBALANCE, |
91 | MMAL_PARAM_IMAGEFX_CARTOON, |
92 | |
93 | */ |
94 | |
95 | /// Annotate bitmask options |
96 | /// Supplied by user on command line |
97 | #define ANNOTATE_USER_TEXT 1 |
98 | /// Supplied by app using this module |
99 | #define ANNOTATE_APP_TEXT 2 |
100 | /// Insert current date |
101 | #define ANNOTATE_DATE_TEXT 4 |
102 | // Insert current time |
103 | #define ANNOTATE_TIME_TEXT 8 |
104 | |
105 | #define ANNOTATE_SHUTTER_SETTINGS 16 |
106 | #define ANNOTATE_CAF_SETTINGS 32 |
107 | #define ANNOTATE_GAIN_SETTINGS 64 |
108 | #define ANNOTATE_LENS_SETTINGS 128 |
109 | #define ANNOTATE_MOTION_SETTINGS 256 |
110 | #define ANNOTATE_FRAME_NUMBER 512 |
111 | #define ANNOTATE_BLACK_BACKGROUND 1024 |
112 | |
113 | |
114 | // There isn't actually a MMAL structure for the following, so make one |
115 | typedef struct mmal_param_colourfx_s |
116 | { |
117 | int enable; /// Turn colourFX on or off |
118 | int u,v; /// U and V to use |
119 | } MMAL_PARAM_COLOURFX_T; |
120 | |
121 | typedef struct mmal_param_thumbnail_config_s |
122 | { |
123 | int enable; |
124 | int width,height; |
125 | int quality; |
126 | } MMAL_PARAM_THUMBNAIL_CONFIG_T; |
127 | |
128 | typedef struct param_float_rect_s |
129 | { |
130 | double x; |
131 | double y; |
132 | double w; |
133 | double h; |
134 | } PARAM_FLOAT_RECT_T; |
135 | |
136 | /// struct contain camera settings |
137 | typedef struct raspicam_camera_parameters_s |
138 | { |
139 | int sharpness; /// -100 to 100 |
140 | int contrast; /// -100 to 100 |
141 | int brightness; /// 0 to 100 |
142 | int saturation; /// -100 to 100 |
143 | int ISO; /// TODO : what range? |
144 | int videoStabilisation; /// 0 or 1 (false or true) |
145 | int exposureCompensation; /// -10 to +10 ? |
146 | MMAL_PARAM_EXPOSUREMODE_T exposureMode; |
147 | MMAL_PARAM_EXPOSUREMETERINGMODE_T exposureMeterMode; |
148 | MMAL_PARAM_AWBMODE_T awbMode; |
149 | MMAL_PARAM_IMAGEFX_T imageEffect; |
150 | MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imageEffectsParameters; |
151 | MMAL_PARAM_COLOURFX_T colourEffects; |
152 | MMAL_PARAM_FLICKERAVOID_T flickerAvoidMode; |
153 | int rotation; /// 0-359 |
154 | int hflip; /// 0 or 1 |
155 | int vflip; /// 0 or 1 |
156 | PARAM_FLOAT_RECT_T roi; /// region of interest to use on the sensor. Normalised [0,1] values in the rect |
157 | int shutter_speed; /// 0 = auto, otherwise the shutter speed in ms |
158 | float awb_gains_r; /// AWB red gain |
159 | float awb_gains_b; /// AWB blue gain |
160 | MMAL_PARAMETER_DRC_STRENGTH_T drc_level; // Strength of Dynamic Range compression to apply |
161 | MMAL_BOOL_T stats_pass; /// Stills capture statistics pass on/off |
162 | int enable_annotate; /// Flag to enable the annotate, 0 = disabled, otherwise a bitmask of what needs to be displayed |
163 | char annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2]; /// String to use for annotate - overrides certain bitmask settings |
164 | int annotate_text_size; // Text size for annotation |
165 | int annotate_text_colour; // Text colour for annotation |
166 | int annotate_bg_colour; // Background colour for annotation |
167 | unsigned int annotate_justify; |
168 | unsigned int annotate_x; |
169 | unsigned int annotate_y; |
170 | |
171 | MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo_mode; |
172 | float analog_gain; // Analog gain |
173 | float digital_gain; // Digital gain |
174 | |
175 | int settings; |
176 | } RASPICAM_CAMERA_PARAMETERS; |
177 | |
178 | typedef enum |
179 | { |
180 | ZOOM_IN, ZOOM_OUT, ZOOM_RESET |
181 | } ZOOM_COMMAND_T; |
182 | |
183 | |
184 | void raspicamcontrol_check_configuration(int min_gpu_mem); |
185 | |
186 | int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2); |
187 | void raspicamcontrol_display_help(); |
188 | int raspicamcontrol_cycle_test(MMAL_COMPONENT_T *camera); |
189 | |
190 | int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_CAMERA_PARAMETERS *params); |
191 | int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA_PARAMETERS *params); |
192 | void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params); |
193 | |
194 | void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params); |
195 | |
196 | void raspicamcontrol_check_configuration(int min_gpu_mem); |
197 | |
198 | // Individual setting functions |
199 | int raspicamcontrol_set_saturation(MMAL_COMPONENT_T *camera, int saturation); |
200 | int raspicamcontrol_set_sharpness(MMAL_COMPONENT_T *camera, int sharpness); |
201 | int raspicamcontrol_set_contrast(MMAL_COMPONENT_T *camera, int contrast); |
202 | int raspicamcontrol_set_brightness(MMAL_COMPONENT_T *camera, int brightness); |
203 | int raspicamcontrol_set_ISO(MMAL_COMPONENT_T *camera, int ISO); |
204 | int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMETERINGMODE_T mode); |
205 | int raspicamcontrol_set_video_stabilisation(MMAL_COMPONENT_T *camera, int vstabilisation); |
206 | int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_comp); |
207 | int raspicamcontrol_set_exposure_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMODE_T mode); |
208 | int raspicamcontrol_set_flicker_avoid_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_FLICKERAVOID_T mode); |
209 | int raspicamcontrol_set_awb_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_AWBMODE_T awb_mode); |
210 | int raspicamcontrol_set_awb_gains(MMAL_COMPONENT_T *camera, float r_gain, float b_gain); |
211 | int raspicamcontrol_set_imageFX(MMAL_COMPONENT_T *camera, MMAL_PARAM_IMAGEFX_T imageFX); |
212 | int raspicamcontrol_set_colourFX(MMAL_COMPONENT_T *camera, const MMAL_PARAM_COLOURFX_T *colourFX); |
213 | int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation); |
214 | int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip); |
215 | int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect); |
216 | int raspicamcontrol_zoom_in_zoom_out(MMAL_COMPONENT_T *camera, ZOOM_COMMAND_T zoom_command, PARAM_FLOAT_RECT_T *roi); |
217 | int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed_ms); |
218 | int raspicamcontrol_set_DRC(MMAL_COMPONENT_T *camera, MMAL_PARAMETER_DRC_STRENGTH_T strength); |
219 | int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass); |
220 | int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int bitmask, const char *string, |
221 | const int text_size, const int text_colour, const int bg_colour, |
222 | const unsigned int justify, const unsigned int x, const unsigned int y); |
223 | int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOPIC_MODE_T *stereo_mode); |
224 | int raspicamcontrol_set_gains(MMAL_COMPONENT_T *camera, float analog, float digital); |
225 | |
226 | //Individual getting functions |
227 | int raspicamcontrol_get_saturation(MMAL_COMPONENT_T *camera); |
228 | int raspicamcontrol_get_sharpness(MMAL_COMPONENT_T *camera); |
229 | int raspicamcontrol_get_contrast(MMAL_COMPONENT_T *camera); |
230 | int raspicamcontrol_get_brightness(MMAL_COMPONENT_T *camera); |
231 | int raspicamcontrol_get_ISO(MMAL_COMPONENT_T *camera); |
232 | MMAL_PARAM_EXPOSUREMETERINGMODE_T raspicamcontrol_get_metering_mode(MMAL_COMPONENT_T *camera); |
233 | int raspicamcontrol_get_video_stabilisation(MMAL_COMPONENT_T *camera); |
234 | int raspicamcontrol_get_exposure_compensation(MMAL_COMPONENT_T *camera); |
235 | MMAL_PARAM_THUMBNAIL_CONFIG_T raspicamcontrol_get_thumbnail_parameters(MMAL_COMPONENT_T *camera); |
236 | MMAL_PARAM_EXPOSUREMODE_T raspicamcontrol_get_exposure_mode(MMAL_COMPONENT_T *camera); |
237 | MMAL_PARAM_FLICKERAVOID_T raspicamcontrol_get_flicker_avoid_mode(MMAL_COMPONENT_T *camera); |
238 | MMAL_PARAM_AWBMODE_T raspicamcontrol_get_awb_mode(MMAL_COMPONENT_T *camera); |
239 | MMAL_PARAM_IMAGEFX_T raspicamcontrol_get_imageFX(MMAL_COMPONENT_T *camera); |
240 | MMAL_PARAM_COLOURFX_T raspicamcontrol_get_colourFX(MMAL_COMPONENT_T *camera); |
241 | |
242 | /** Default camera callback function |
243 | */ |
244 | void default_camera_control_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); |
245 | |
246 | |
247 | |
248 | #endif /* RASPICAMCONTROL_H_ */ |
249 | |