RAPICAM_3-15-2015
RaspiCamControl.h
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  * AWB Mode
50  * MMAL_PARAM_AWBMODE_OFF,
51  MMAL_PARAM_AWBMODE_AUTO,
52  MMAL_PARAM_AWBMODE_SUNLIGHT,
53  MMAL_PARAM_AWBMODE_CLOUDY,
54  MMAL_PARAM_AWBMODE_SHADE,
55  MMAL_PARAM_AWBMODE_TUNGSTEN,
56  MMAL_PARAM_AWBMODE_FLUORESCENT,
57  MMAL_PARAM_AWBMODE_INCANDESCENT,
58  MMAL_PARAM_AWBMODE_FLASH,
59  MMAL_PARAM_AWBMODE_HORIZON,
60  *
61  * Image FX
62  MMAL_PARAM_IMAGEFX_NONE,
63  MMAL_PARAM_IMAGEFX_NEGATIVE,
64  MMAL_PARAM_IMAGEFX_SOLARIZE,
65  MMAL_PARAM_IMAGEFX_POSTERIZE,
66  MMAL_PARAM_IMAGEFX_WHITEBOARD,
67  MMAL_PARAM_IMAGEFX_BLACKBOARD,
68  MMAL_PARAM_IMAGEFX_SKETCH,
69  MMAL_PARAM_IMAGEFX_DENOISE,
70  MMAL_PARAM_IMAGEFX_EMBOSS,
71  MMAL_PARAM_IMAGEFX_OILPAINT,
72  MMAL_PARAM_IMAGEFX_HATCH,
73  MMAL_PARAM_IMAGEFX_GPEN,
74  MMAL_PARAM_IMAGEFX_PASTEL,
75  MMAL_PARAM_IMAGEFX_WATERCOLOUR,
76  MMAL_PARAM_IMAGEFX_FILM,
77  MMAL_PARAM_IMAGEFX_BLUR,
78  MMAL_PARAM_IMAGEFX_SATURATION,
79  MMAL_PARAM_IMAGEFX_COLOURSWAP,
80  MMAL_PARAM_IMAGEFX_WASHEDOUT,
81  MMAL_PARAM_IMAGEFX_POSTERISE,
82  MMAL_PARAM_IMAGEFX_COLOURPOINT,
83  MMAL_PARAM_IMAGEFX_COLOURBALANCE,
84  MMAL_PARAM_IMAGEFX_CARTOON,
85 
86  */
87 
90 #define ANNOTATE_USER_TEXT 1
91 #define ANNOTATE_APP_TEXT 2
93 #define ANNOTATE_DATE_TEXT 4
95 // Insert current time
96 #define ANNOTATE_TIME_TEXT 8
97 
98 #define ANNOTATE_SHUTTER_SETTINGS 16
99 #define ANNOTATE_CAF_SETTINGS 32
100 #define ANNOTATE_GAIN_SETTINGS 64
101 #define ANNOTATE_LENS_SETTINGS 128
102 #define ANNOTATE_MOTION_SETTINGS 256
103 #define ANNOTATE_FRAME_NUMBER 512
104 #define ANNOTATE_BLACK_BACKGROUND 1024
105 
106 
107 // There isn't actually a MMAL structure for the following, so make one
108 typedef struct
109 {
110  int enable;
111  int u,v;
113 
114 typedef struct
115 {
116  int enable;
117  int width,height;
118  int quality;
120 
121 typedef struct
122 {
123  double x;
124  double y;
125  double w;
126  double h;
128 
130 typedef struct
131 {
132  int sharpness;
133  int contrast;
136  int ISO;
139  MMAL_PARAM_EXPOSUREMODE_T exposureMode;
140  MMAL_PARAM_EXPOSUREMETERINGMODE_T exposureMeterMode;
141  MMAL_PARAM_AWBMODE_T awbMode;
142  MMAL_PARAM_IMAGEFX_T imageEffect;
143  MMAL_PARAMETER_IMAGEFX_PARAMETERS_T imageEffectsParameters;
144  MMAL_PARAM_COLOURFX_T colourEffects;
145  int rotation;
146  int hflip;
147  int vflip;
150  float awb_gains_r;
151  float awb_gains_b;
152  MMAL_PARAMETER_DRC_STRENGTH_T drc_level; // Strength of Dynamic Range compression to apply
153  MMAL_BOOL_T stats_pass;
155  char annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V2];
156 
158 
159 
160 void raspicamcontrol_check_configuration(int min_gpu_mem);
161 
162 int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2);
163 void raspicamcontrol_display_help();
164 int raspicamcontrol_cycle_test(MMAL_COMPONENT_T *camera);
165 
166 int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_CAMERA_PARAMETERS *params);
167 int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA_PARAMETERS *params);
168 void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params);
169 
170 void raspicamcontrol_set_defaults(RASPICAM_CAMERA_PARAMETERS *params);
171 
172 void raspicamcontrol_check_configuration(int min_gpu_mem);
173 
174 // Individual setting functions
175 int raspicamcontrol_set_saturation(MMAL_COMPONENT_T *camera, int saturation);
176 int raspicamcontrol_set_sharpness(MMAL_COMPONENT_T *camera, int sharpness);
177 int raspicamcontrol_set_contrast(MMAL_COMPONENT_T *camera, int contrast);
178 int raspicamcontrol_set_brightness(MMAL_COMPONENT_T *camera, int brightness);
179 int raspicamcontrol_set_ISO(MMAL_COMPONENT_T *camera, int ISO);
180 int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMETERINGMODE_T mode);
181 int raspicamcontrol_set_video_stabilisation(MMAL_COMPONENT_T *camera, int vstabilisation);
182 int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_comp);
183 int raspicamcontrol_set_exposure_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOSUREMODE_T mode);
184 int raspicamcontrol_set_awb_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_AWBMODE_T awb_mode);
185 int raspicamcontrol_set_awb_gains(MMAL_COMPONENT_T *camera, float r_gain, float b_gain);
186 int raspicamcontrol_set_imageFX(MMAL_COMPONENT_T *camera, MMAL_PARAM_IMAGEFX_T imageFX);
187 int raspicamcontrol_set_colourFX(MMAL_COMPONENT_T *camera, const MMAL_PARAM_COLOURFX_T *colourFX);
188 int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation);
189 int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip);
190 int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect);
191 int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed_ms);
192 int raspicamcontrol_set_DRC(MMAL_COMPONENT_T *camera, MMAL_PARAMETER_DRC_STRENGTH_T strength);
193 int raspicamcontrol_set_stats_pass(MMAL_COMPONENT_T *camera, int stats_pass);
194 int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int bitmask, const char *string);
195 
196 //Individual getting functions
197 int raspicamcontrol_get_saturation(MMAL_COMPONENT_T *camera);
198 int raspicamcontrol_get_sharpness(MMAL_COMPONENT_T *camera);
199 int raspicamcontrol_get_contrast(MMAL_COMPONENT_T *camera);
200 int raspicamcontrol_get_brightness(MMAL_COMPONENT_T *camera);
201 int raspicamcontrol_get_ISO(MMAL_COMPONENT_T *camera);
202 MMAL_PARAM_EXPOSUREMETERINGMODE_T raspicamcontrol_get_metering_mode(MMAL_COMPONENT_T *camera);
203 int raspicamcontrol_get_video_stabilisation(MMAL_COMPONENT_T *camera);
204 int raspicamcontrol_get_exposure_compensation(MMAL_COMPONENT_T *camera);
205 MMAL_PARAM_THUMBNAIL_CONFIG_T raspicamcontrol_get_thumbnail_parameters(MMAL_COMPONENT_T *camera);
206 MMAL_PARAM_EXPOSUREMODE_T raspicamcontrol_get_exposure_mode(MMAL_COMPONENT_T *camera);
207 MMAL_PARAM_AWBMODE_T raspicamcontrol_get_awb_mode(MMAL_COMPONENT_T *camera);
208 MMAL_PARAM_IMAGEFX_T raspicamcontrol_get_imageFX(MMAL_COMPONENT_T *camera);
209 MMAL_PARAM_COLOURFX_T raspicamcontrol_get_colourFX(MMAL_COMPONENT_T *camera);
210 
211 
212 #endif /* RASPICAMCONTROL_H_ */
int ISO
-100 to 100
Definition: RaspiCamControl.h:136
MMAL_PARAMETER_DRC_STRENGTH_T drc_level
AWB blue gain.
Definition: RaspiCamControl.h:152
int brightness
-100 to 100
Definition: RaspiCamControl.h:134
int exposureCompensation
0 or 1 (false or true)
Definition: RaspiCamControl.h:138
Definition: RaspiCamControl.h:121
PARAM_FLOAT_RECT_T roi
0 or 1
Definition: RaspiCamControl.h:148
MMAL_PARAM_EXPOSUREMODE_T exposureMode
-10 to +10 ?
Definition: RaspiCamControl.h:139
Definition: RaspiCamControl.h:108
int hflip
0-359
Definition: RaspiCamControl.h:146
float awb_gains_r
0 = auto, otherwise the shutter speed in ms
Definition: RaspiCamControl.h:150
Definition: RaspiCamControl.h:114
int u
Turn colourFX on or off.
Definition: RaspiCamControl.h:111
int enable_annotate
Stills capture statistics pass on/off.
Definition: RaspiCamControl.h:154
int videoStabilisation
TODO : what range?
Definition: RaspiCamControl.h:137
struct contain camera settings
Definition: RaspiCamControl.h:130
int saturation
0 to 100
Definition: RaspiCamControl.h:135
int contrast
-100 to 100
Definition: RaspiCamControl.h:133
int shutter_speed
region of interest to use on the sensor. Normalised [0,1] values in the rect
Definition: RaspiCamControl.h:149
float awb_gains_b
AWB red gain.
Definition: RaspiCamControl.h:151
int vflip
0 or 1
Definition: RaspiCamControl.h:147