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