"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "raspicam/RaspiCamControl.c" between
motion-release-4.2.2.tar.gz and motion-Release-4.3.0.tar.gz

About: Motion monitors the video signal from one or more cameras and is able to detect motion.

RaspiCamControl.c  (motion-release-4.2.2):RaspiCamControl.c  (motion-Release-4.3.0)
skipping to change at line 29 skipping to change at line 29
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/*
This file was modified to be used with the motion project. The controls are pars
ed
via "mmalcam_control_params" function in motion to the raspicam driver. To fulfi
ll
such functionality without bloating the motion code, the following changes were
made:
- remove call to helper module "RaspiHelpers.h";
- include only "mmal_status_to_int" function from "RaspiHelpers.h". This functio
n
was copied exactly as written in "RaspiHelpers.h" file.
*/
#include <stdio.h> #include <stdio.h>
#include <memory.h> #include <memory.h>
#include <ctype.h> #include <ctype.h>
#include "interface/vcos/vcos.h" #include "interface/vcos/vcos.h"
#include "interface/vmcs_host/vc_vchi_gencmd.h" #include "interface/vmcs_host/vc_vchi_gencmd.h"
#include "interface/mmal/mmal.h" #include "interface/mmal/mmal.h"
#include "interface/mmal/mmal_logging.h" #include "interface/mmal/mmal_logging.h"
#include "interface/mmal/util/mmal_util.h" #include "interface/mmal/util/mmal_util.h"
#include "interface/mmal/util/mmal_util_params.h" #include "interface/mmal/util/mmal_util_params.h"
#include "interface/mmal/util/mmal_default_components.h" #include "interface/mmal/util/mmal_default_components.h"
#include "interface/mmal/util/mmal_connection.h"
#include "RaspiCamControl.h" #include "RaspiCamControl.h"
#include "RaspiCLI.h" #include "RaspiCLI.h"
/// Structure to cross reference exposure strings against the MMAL parameter equ ivalent /// Structure to cross reference exposure strings against the MMAL parameter equ ivalent
static XREF_T exposure_map[] = static XREF_T exposure_map[] =
{ {
{"off", MMAL_PARAM_EXPOSUREMODE_OFF}, {"off", MMAL_PARAM_EXPOSUREMODE_OFF},
{"auto", MMAL_PARAM_EXPOSUREMODE_AUTO}, {"auto", MMAL_PARAM_EXPOSUREMODE_AUTO},
{"night", MMAL_PARAM_EXPOSUREMODE_NIGHT}, {"night", MMAL_PARAM_EXPOSUREMODE_NIGHT},
{"nightpreview", MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW}, {"nightpreview", MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW},
skipping to change at line 64 skipping to change at line 76
{"snow", MMAL_PARAM_EXPOSUREMODE_SNOW}, {"snow", MMAL_PARAM_EXPOSUREMODE_SNOW},
{"beach", MMAL_PARAM_EXPOSUREMODE_BEACH}, {"beach", MMAL_PARAM_EXPOSUREMODE_BEACH},
{"verylong", MMAL_PARAM_EXPOSUREMODE_VERYLONG}, {"verylong", MMAL_PARAM_EXPOSUREMODE_VERYLONG},
{"fixedfps", MMAL_PARAM_EXPOSUREMODE_FIXEDFPS}, {"fixedfps", MMAL_PARAM_EXPOSUREMODE_FIXEDFPS},
{"antishake", MMAL_PARAM_EXPOSUREMODE_ANTISHAKE}, {"antishake", MMAL_PARAM_EXPOSUREMODE_ANTISHAKE},
{"fireworks", MMAL_PARAM_EXPOSUREMODE_FIREWORKS} {"fireworks", MMAL_PARAM_EXPOSUREMODE_FIREWORKS}
}; };
static const int exposure_map_size = sizeof(exposure_map) / sizeof(exposure_map[ 0]); static const int exposure_map_size = sizeof(exposure_map) / sizeof(exposure_map[ 0]);
/// Structure to cross reference flicker avoid strings against the MMAL paramete
r equivalent
static XREF_T flicker_avoid_map[] =
{
{"off", MMAL_PARAM_FLICKERAVOID_OFF},
{"auto", MMAL_PARAM_FLICKERAVOID_AUTO},
{"50hz", MMAL_PARAM_FLICKERAVOID_50HZ},
{"60hz", MMAL_PARAM_FLICKERAVOID_60HZ}
};
static const int flicker_avoid_map_size = sizeof(flicker_avoid_map) / sizeof(fli
cker_avoid_map[0]);
/// Structure to cross reference awb strings against the MMAL parameter equivale nt /// Structure to cross reference awb strings against the MMAL parameter equivale nt
static XREF_T awb_map[] = static XREF_T awb_map[] =
{ {
{"off", MMAL_PARAM_AWBMODE_OFF}, {"off", MMAL_PARAM_AWBMODE_OFF},
{"auto", MMAL_PARAM_AWBMODE_AUTO}, {"auto", MMAL_PARAM_AWBMODE_AUTO},
{"sun", MMAL_PARAM_AWBMODE_SUNLIGHT}, {"sun", MMAL_PARAM_AWBMODE_SUNLIGHT},
{"cloud", MMAL_PARAM_AWBMODE_CLOUDY}, {"cloud", MMAL_PARAM_AWBMODE_CLOUDY},
{"shade", MMAL_PARAM_AWBMODE_SHADE}, {"shade", MMAL_PARAM_AWBMODE_SHADE},
{"tungsten", MMAL_PARAM_AWBMODE_TUNGSTEN}, {"tungsten", MMAL_PARAM_AWBMODE_TUNGSTEN},
{"fluorescent", MMAL_PARAM_AWBMODE_FLUORESCENT}, {"fluorescent", MMAL_PARAM_AWBMODE_FLUORESCENT},
{"incandescent", MMAL_PARAM_AWBMODE_INCANDESCENT}, {"incandescent", MMAL_PARAM_AWBMODE_INCANDESCENT},
{"flash", MMAL_PARAM_AWBMODE_FLASH}, {"flash", MMAL_PARAM_AWBMODE_FLASH},
{"horizon", MMAL_PARAM_AWBMODE_HORIZON} {"horizon", MMAL_PARAM_AWBMODE_HORIZON},
{"greyworld", MMAL_PARAM_AWBMODE_GREYWORLD}
}; };
static const int awb_map_size = sizeof(awb_map) / sizeof(awb_map[0]); static const int awb_map_size = sizeof(awb_map) / sizeof(awb_map[0]);
/// Structure to cross reference image effect against the MMAL parameter equival ent /// Structure to cross reference image effect against the MMAL parameter equival ent
static XREF_T imagefx_map[] = static XREF_T imagefx_map[] =
{ {
{"none", MMAL_PARAM_IMAGEFX_NONE}, {"none", MMAL_PARAM_IMAGEFX_NONE},
{"negative", MMAL_PARAM_IMAGEFX_NEGATIVE}, {"negative", MMAL_PARAM_IMAGEFX_NEGATIVE},
{"solarise", MMAL_PARAM_IMAGEFX_SOLARIZE}, {"solarise", MMAL_PARAM_IMAGEFX_SOLARIZE},
skipping to change at line 104 skipping to change at line 129
{"watercolour", MMAL_PARAM_IMAGEFX_WATERCOLOUR}, {"watercolour", MMAL_PARAM_IMAGEFX_WATERCOLOUR},
{"film", MMAL_PARAM_IMAGEFX_FILM}, {"film", MMAL_PARAM_IMAGEFX_FILM},
{"blur", MMAL_PARAM_IMAGEFX_BLUR}, {"blur", MMAL_PARAM_IMAGEFX_BLUR},
{"saturation", MMAL_PARAM_IMAGEFX_SATURATION}, {"saturation", MMAL_PARAM_IMAGEFX_SATURATION},
{"colourswap", MMAL_PARAM_IMAGEFX_COLOURSWAP}, {"colourswap", MMAL_PARAM_IMAGEFX_COLOURSWAP},
{"washedout", MMAL_PARAM_IMAGEFX_WASHEDOUT}, {"washedout", MMAL_PARAM_IMAGEFX_WASHEDOUT},
{"posterise", MMAL_PARAM_IMAGEFX_POSTERISE}, {"posterise", MMAL_PARAM_IMAGEFX_POSTERISE},
{"colourpoint", MMAL_PARAM_IMAGEFX_COLOURPOINT}, {"colourpoint", MMAL_PARAM_IMAGEFX_COLOURPOINT},
{"colourbalance", MMAL_PARAM_IMAGEFX_COLOURBALANCE}, {"colourbalance", MMAL_PARAM_IMAGEFX_COLOURBALANCE},
{"cartoon", MMAL_PARAM_IMAGEFX_CARTOON} {"cartoon", MMAL_PARAM_IMAGEFX_CARTOON}
}; };
static const int imagefx_map_size = sizeof(imagefx_map) / sizeof(imagefx_map[0]) ; static const int imagefx_map_size = sizeof(imagefx_map) / sizeof(imagefx_map[0]) ;
static XREF_T metering_mode_map[] = static XREF_T metering_mode_map[] =
{ {
{"average", MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE}, {"average", MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE},
{"spot", MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT}, {"spot", MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT},
{"backlit", MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT}, {"backlit", MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT},
{"matrix", MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX} {"matrix", MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX}
}; };
skipping to change at line 137 skipping to change at line 162
static XREF_T stereo_mode_map[] = static XREF_T stereo_mode_map[] =
{ {
{"off", MMAL_STEREOSCOPIC_MODE_NONE}, {"off", MMAL_STEREOSCOPIC_MODE_NONE},
{"sbs", MMAL_STEREOSCOPIC_MODE_SIDE_BY_SIDE}, {"sbs", MMAL_STEREOSCOPIC_MODE_SIDE_BY_SIDE},
{"tb", MMAL_STEREOSCOPIC_MODE_TOP_BOTTOM}, {"tb", MMAL_STEREOSCOPIC_MODE_TOP_BOTTOM},
}; };
static const int stereo_mode_map_size = sizeof(stereo_mode_map)/sizeof(stereo_mo de_map[0]); static const int stereo_mode_map_size = sizeof(stereo_mode_map)/sizeof(stereo_mo de_map[0]);
#define CommandSharpness 0 enum
#define CommandContrast 1 {
#define CommandBrightness 2 CommandSharpness,
#define CommandSaturation 3 CommandContrast,
#define CommandISO 4 CommandBrightness,
#define CommandVideoStab 5 CommandSaturation,
#define CommandEVComp 6 CommandISO,
#define CommandExposure 7 CommandVideoStab,
#define CommandAWB 8 CommandEVComp,
#define CommandImageFX 9 CommandExposure,
#define CommandColourFX 10 CommandAWB,
#define CommandMeterMode 11 CommandImageFX,
#define CommandRotation 12 CommandColourFX,
#define CommandHFlip 13 CommandMeterMode,
#define CommandVFlip 14 CommandRotation,
#define CommandROI 15 CommandHFlip,
#define CommandShutterSpeed 16 CommandVFlip,
#define CommandAwbGains 17 CommandROI,
#define CommandDRCLevel 18 CommandShutterSpeed,
#define CommandStatsPass 19 CommandAwbGains,
#define CommandAnnotate 20 CommandDRCLevel,
#define CommandStereoMode 21 CommandStatsPass,
#define CommandStereoDecimate 22 CommandAnnotate,
#define CommandStereoSwap 23 CommandStereoMode,
#define CommandAnnotateExtras 24 CommandStereoDecimate,
CommandStereoSwap,
CommandAnnotateExtras,
CommandFlicker,
CommandAnalogGain,
CommandDigitalGain,
CommandSettings
};
static COMMAND_LIST cmdline_commands[] = static COMMAND_LIST cmdline_commands[] =
{ {
{CommandSharpness, "-sharpness", "sh", "Set image sharpness (-100 to 100)", 1}, {CommandSharpness, "-sharpness", "sh", "Set image sharpness (-100 to 100)", 1},
{CommandContrast, "-contrast", "co", "Set image contrast (-100 to 100)", 1}, {CommandContrast, "-contrast", "co", "Set image contrast (-100 to 100)", 1},
{CommandBrightness, "-brightness","br", "Set image brightness (0 to 100)", 1}, {CommandBrightness, "-brightness","br", "Set image brightness (0 to 100)", 1},
{CommandSaturation, "-saturation","sa", "Set image saturation (-100 to 100)" , 1}, {CommandSaturation, "-saturation","sa", "Set image saturation (-100 to 100)" , 1},
{CommandISO, "-ISO", "ISO","Set capture ISO", 1}, {CommandISO, "-ISO", "ISO","Set capture ISO", 1},
{CommandVideoStab, "-vstab", "vs", "Turn on video stabilisation", 0}, {CommandVideoStab, "-vstab", "vs", "Turn on video stabilisation", 0},
{CommandEVComp, "-ev", "ev", "Set EV compensation - steps of 1/6 stop", 1}, {CommandEVComp, "-ev", "ev", "Set EV compensation - steps of 1/6 stop", 1},
{CommandExposure, "-exposure", "ex", "Set exposure mode (see Notes)", 1}, {CommandExposure, "-exposure", "ex", "Set exposure mode (see Notes)", 1},
{CommandFlicker, "-flicker", "fli","Set flicker avoid mode (see Notes)" , 1},
{CommandAWB, "-awb", "awb","Set AWB mode (see Notes)", 1}, {CommandAWB, "-awb", "awb","Set AWB mode (see Notes)", 1},
{CommandImageFX, "-imxfx", "ifx","Set image effect (see Notes)", 1}, {CommandImageFX, "-imxfx", "ifx","Set image effect (see Notes)", 1},
{CommandColourFX, "-colfx", "cfx","Set colour effect (U:V)", 1}, {CommandColourFX, "-colfx", "cfx","Set colour effect (U:V)", 1},
{CommandMeterMode, "-metering", "mm", "Set metering mode (see Notes)", 1}, {CommandMeterMode, "-metering", "mm", "Set metering mode (see Notes)", 1},
{CommandRotation, "-rotation", "rot","Set image rotation (0-359)", 1}, {CommandRotation, "-rotation", "rot","Set image rotation (0-359)", 1},
{CommandHFlip, "-hflip", "hf", "Set horizontal flip", 0}, {CommandHFlip, "-hflip", "hf", "Set horizontal flip", 0},
{CommandVFlip, "-vflip", "vf", "Set vertical flip", 0}, {CommandVFlip, "-vflip", "vf", "Set vertical flip", 0},
{CommandROI, "-roi", "roi","Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])", 1}, {CommandROI, "-roi", "roi","Set region of interest (x,y,w,d as normalised coordinates [0.0-1.0])", 1},
{CommandShutterSpeed,"-shutter", "ss", "Set shutter speed in microseconds", 1}, {CommandShutterSpeed,"-shutter", "ss", "Set shutter speed in microseconds", 1},
{CommandAwbGains, "-awbgains", "awbg", "Set AWB gains - AWB mode must be off", 1}, {CommandAwbGains, "-awbgains", "awbg", "Set AWB gains - AWB mode must be off", 1},
{CommandDRCLevel, "-drc", "drc", "Set DRC Level (see Notes)", 1}, {CommandDRCLevel, "-drc", "drc", "Set DRC Level (see Notes)", 1},
{CommandStatsPass, "-stats", "st", "Force recomputation of statistics o n stills capture pass"}, {CommandStatsPass, "-stats", "st", "Force recomputation of statistics o n stills capture pass"},
{CommandAnnotate, "-annotate", "a", "Enable/Set annotate flags or text", 1}, {CommandAnnotate, "-annotate", "a", "Enable/Set annotate flags or text", 1},
{CommandStereoMode, "-stereo", "3d", "Select stereoscopic mode", 1}, {CommandStereoMode, "-stereo", "3d", "Select stereoscopic mode", 1},
{CommandStereoDecimate,"-decimate","dec", "Half width/height of stereo image" }, {CommandStereoDecimate,"-decimate","dec", "Half width/height of stereo image" },
{CommandStereoSwap, "-3dswap", "3dswap", "Swap camera order for stereosco pic"}, {CommandStereoSwap, "-3dswap", "3dswap", "Swap camera order for stereosco pic"},
{CommandAnnotateExtras,"-annotateex","ae", "Set extra annotation parameters {CommandAnnotateExtras,"-annotateex","ae", "Set extra annotation parameters
(text size, text colour(hex YUV), bg colour(hex YUV))", 2}, (text size, text colour(hex YUV), bg colour(hex YUV), justify, x, y)", 2},
{CommandAnalogGain, "-analoggain", "ag", "Set the analog gain (floating poin
t)", 1},
{CommandDigitalGain, "-digitalgain", "dg", "Set the digital gain (floating po
int)", 1},
{CommandSettings, "-settings", "set","Retrieve camera settings and write
to stdout", 0},
}; };
static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_com mands[0]); static int cmdline_commands_size = sizeof(cmdline_commands) / sizeof(cmdline_com mands[0]);
#define parameter_reset -99999 #define parameter_reset -99999
#define zoom_full_16P16 ((unsigned int)(65536 * 0.15))
#define zoom_increment_16P16 (65536UL / 10)
/** /**
* Update the passed in parameter according to the rest of the parameters * Update the passed in parameter according to the rest of the parameters
* passed in. * passed in.
* *
* *
* @return 0 if reached end of cycle for this parameter, !0 otherwise * @return 0 if reached end of cycle for this parameter, !0 otherwise
*/ */
static int update_cycle_parameter(int *option, int min, int max, int increment) static int update_cycle_parameter(int *option, int min, int max, int increment)
{ {
vcos_assert(option); vcos_assert(option);
skipping to change at line 255 skipping to change at line 294
{ {
// sharpness // sharpness
if (update_cycle_parameter(&parameter_option, -100, 100, 10)) if (update_cycle_parameter(&parameter_option, -100, 100, 10))
raspicamcontrol_set_sharpness(camera, parameter_option); raspicamcontrol_set_sharpness(camera, parameter_option);
else else
{ {
raspicamcontrol_set_sharpness(camera, 0); raspicamcontrol_set_sharpness(camera, 0);
parameter++; parameter++;
} }
} }
else else if (parameter == 1)
if (parameter == 1)
{ {
// contrast // contrast
if (update_cycle_parameter(&parameter_option, -100, 100, 10)) if (update_cycle_parameter(&parameter_option, -100, 100, 10))
raspicamcontrol_set_contrast(camera, parameter_option); raspicamcontrol_set_contrast(camera, parameter_option);
else else
{ {
raspicamcontrol_set_contrast(camera, 0); raspicamcontrol_set_contrast(camera, 0);
parameter++; parameter++;
} }
} }
else else if (parameter == 2)
if (parameter == 2)
{ {
// brightness // brightness
if (update_cycle_parameter(&parameter_option, 0, 100, 10)) if (update_cycle_parameter(&parameter_option, 0, 100, 10))
raspicamcontrol_set_brightness(camera, parameter_option); raspicamcontrol_set_brightness(camera, parameter_option);
else else
{ {
raspicamcontrol_set_brightness(camera, 50); raspicamcontrol_set_brightness(camera, 50);
parameter++; parameter++;
} }
} }
else else if (parameter == 3)
if (parameter == 3)
{ {
// contrast // contrast
if (update_cycle_parameter(&parameter_option, -100, 100, 10)) if (update_cycle_parameter(&parameter_option, -100, 100, 10))
raspicamcontrol_set_saturation(camera, parameter_option); raspicamcontrol_set_saturation(camera, parameter_option);
else else
{ {
parameter++; parameter++;
raspicamcontrol_set_saturation(camera, 0); raspicamcontrol_set_saturation(camera, 0);
} }
} }
else else if (parameter == 4)
if (parameter == 4)
{ {
// EV // EV
if (update_cycle_parameter(&parameter_option, -10, 10, 4)) if (update_cycle_parameter(&parameter_option, -10, 10, 4))
raspicamcontrol_set_exposure_compensation(camera, parameter_option); raspicamcontrol_set_exposure_compensation(camera, parameter_option);
else else
{ {
raspicamcontrol_set_exposure_compensation(camera, 0); raspicamcontrol_set_exposure_compensation(camera, 0);
parameter++; parameter++;
} }
} }
else else if (parameter == 5)
if (parameter == 5)
{ {
// MMAL_PARAM_EXPOSUREMODE_T // MMAL_PARAM_EXPOSUREMODE_T
if (update_cycle_parameter(&parameter_option, 0, exposure_map_size, 1)) if (update_cycle_parameter(&parameter_option, 0, exposure_map_size, 1))
raspicamcontrol_set_exposure_mode(camera, exposure_map[parameter_option ].mmal_mode); raspicamcontrol_set_exposure_mode(camera, exposure_map[parameter_option ].mmal_mode);
else else
{ {
raspicamcontrol_set_exposure_mode(camera, MMAL_PARAM_EXPOSUREMODE_AUTO) ; raspicamcontrol_set_exposure_mode(camera, MMAL_PARAM_EXPOSUREMODE_AUTO) ;
parameter++; parameter++;
} }
} }
else else if (parameter == 6)
if (parameter == 6)
{ {
// MMAL_PARAM_AWB_T // MMAL_PARAM_AWB_T
if (update_cycle_parameter(&parameter_option, 0, awb_map_size, 1)) if (update_cycle_parameter(&parameter_option, 0, awb_map_size, 1))
raspicamcontrol_set_awb_mode(camera, awb_map[parameter_option].mmal_mod e); raspicamcontrol_set_awb_mode(camera, awb_map[parameter_option].mmal_mod e);
else else
{ {
raspicamcontrol_set_awb_mode(camera, MMAL_PARAM_AWBMODE_AUTO); raspicamcontrol_set_awb_mode(camera, MMAL_PARAM_AWBMODE_AUTO);
parameter++; parameter++;
} }
} }
skipping to change at line 343 skipping to change at line 376
{ {
raspicamcontrol_set_imageFX(camera, MMAL_PARAM_IMAGEFX_NONE); raspicamcontrol_set_imageFX(camera, MMAL_PARAM_IMAGEFX_NONE);
parameter++; parameter++;
} }
} }
if (parameter == 8) if (parameter == 8)
{ {
MMAL_PARAM_COLOURFX_T colfx = {0,0,0}; MMAL_PARAM_COLOURFX_T colfx = {0,0,0};
switch (parameter_option) switch (parameter_option)
{ {
case parameter_reset : case parameter_reset :
parameter_option = 1; parameter_option = 1;
colfx.u = 128; colfx.u = 128;
colfx.v = 128; colfx.v = 128;
break; break;
case 1 : case 1 :
parameter_option = 2; parameter_option = 2;
colfx.u = 100; colfx.u = 100;
colfx.v = 200; colfx.v = 200;
break; break;
case 2 : case 2 :
parameter_option = parameter_reset; parameter_option = parameter_reset;
colfx.enable = 0; colfx.enable = 0;
parameter++; parameter++;
break; break;
} }
raspicamcontrol_set_colourFX(camera, &colfx); raspicamcontrol_set_colourFX(camera, &colfx);
} }
// Orientation // Orientation
if (parameter == 9) if (parameter == 9)
{ {
switch (parameter_option) switch (parameter_option)
{ {
case parameter_reset: case parameter_reset:
skipping to change at line 437 skipping to change at line 470
int i = raspicli_map_xref(str, exposure_map, exposure_map_size); int i = raspicli_map_xref(str, exposure_map, exposure_map_size);
if( i != -1) if( i != -1)
return (MMAL_PARAM_EXPOSUREMODE_T)i; return (MMAL_PARAM_EXPOSUREMODE_T)i;
vcos_log_error("Unknown exposure mode: %s", str); vcos_log_error("Unknown exposure mode: %s", str);
return MMAL_PARAM_EXPOSUREMODE_AUTO; return MMAL_PARAM_EXPOSUREMODE_AUTO;
} }
/** /**
* Convert string to the MMAL parameter for flicker avoid mode
* @param str Incoming string to match
* @return MMAL parameter matching the string, or the AUTO option if no match fo
und
*/
static MMAL_PARAM_FLICKERAVOID_T flicker_avoid_mode_from_string(const char *str)
{
int i = raspicli_map_xref(str, flicker_avoid_map, flicker_avoid_map_size);
if( i != -1)
return (MMAL_PARAM_FLICKERAVOID_T)i;
vcos_log_error("Unknown flicker avoid mode: %s", str);
return MMAL_PARAM_FLICKERAVOID_OFF;
}
/**
* Convert string to the MMAL parameter for AWB mode * Convert string to the MMAL parameter for AWB mode
* @param str Incoming string to match * @param str Incoming string to match
* @return MMAL parameter matching the string, or the AUTO option if no match fo und * @return MMAL parameter matching the string, or the AUTO option if no match fo und
*/ */
static MMAL_PARAM_AWBMODE_T awb_mode_from_string(const char *str) static MMAL_PARAM_AWBMODE_T awb_mode_from_string(const char *str)
{ {
int i = raspicli_map_xref(str, awb_map, awb_map_size); int i = raspicli_map_xref(str, awb_map, awb_map_size);
if( i != -1) if( i != -1)
return (MMAL_PARAM_AWBMODE_T)i; return (MMAL_PARAM_AWBMODE_T)i;
skipping to change at line 462 skipping to change at line 511
/** /**
* Convert string to the MMAL parameter for image effects mode * Convert string to the MMAL parameter for image effects mode
* @param str Incoming string to match * @param str Incoming string to match
* @return MMAL parameter matching the strong, or the AUTO option if no match fo und * @return MMAL parameter matching the strong, or the AUTO option if no match fo und
*/ */
MMAL_PARAM_IMAGEFX_T imagefx_mode_from_string(const char *str) MMAL_PARAM_IMAGEFX_T imagefx_mode_from_string(const char *str)
{ {
int i = raspicli_map_xref(str, imagefx_map, imagefx_map_size); int i = raspicli_map_xref(str, imagefx_map, imagefx_map_size);
if( i != -1) if( i != -1)
return (MMAL_PARAM_IMAGEFX_T)i; return (MMAL_PARAM_IMAGEFX_T)i;
vcos_log_error("Unknown image fx: %s", str); vcos_log_error("Unknown image fx: %s", str);
return MMAL_PARAM_IMAGEFX_NONE; return MMAL_PARAM_IMAGEFX_NONE;
} }
/** /**
* Convert string to the MMAL parameter for exposure metering mode * Convert string to the MMAL parameter for exposure metering mode
* @param str Incoming string to match * @param str Incoming string to match
* @return MMAL parameter matching the string, or the AUTO option if no match fo und * @return MMAL parameter matching the string, or the AUTO option if no match fo und
*/ */
skipping to change at line 527 skipping to change at line 576
* Parse a possible command pair - command and parameter * Parse a possible command pair - command and parameter
* @param arg1 Command * @param arg1 Command
* @param arg2 Parameter (could be NULL) * @param arg2 Parameter (could be NULL)
* @return How many parameters were used, 0,1,2 * @return How many parameters were used, 0,1,2
*/ */
int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2) int raspicamcontrol_parse_cmdline(RASPICAM_CAMERA_PARAMETERS *params, const char *arg1, const char *arg2)
{ {
int command_id, used = 0, num_parameters; int command_id, used = 0, num_parameters;
if (!arg1) if (!arg1)
return 0; return 0;
command_id = raspicli_get_command_id(cmdline_commands, cmdline_commands_size, arg1, &num_parameters); command_id = raspicli_get_command_id(cmdline_commands, cmdline_commands_size, arg1, &num_parameters);
// If invalid command, or we are missing a parameter, drop out // If invalid command, or we are missing a parameter, drop out
if (command_id==-1 || (command_id != -1 && num_parameters > 0 && arg2 == NULL )) if (command_id==-1 || (command_id != -1 && num_parameters > 0 && arg2 == NULL ))
return 0; return 0;
switch (command_id) switch (command_id)
{ {
case CommandSharpness : // sharpness - needs single number parameter case CommandSharpness : // sharpness - needs single number parameter
skipping to change at line 577 skipping to change at line 626
case CommandEVComp : // EV - needs single number parameter case CommandEVComp : // EV - needs single number parameter
sscanf(arg2, "%d", &params->exposureCompensation); sscanf(arg2, "%d", &params->exposureCompensation);
used = 2; used = 2;
break; break;
case CommandExposure : // exposure mode - needs string case CommandExposure : // exposure mode - needs string
params->exposureMode = exposure_mode_from_string(arg2); params->exposureMode = exposure_mode_from_string(arg2);
used = 2; used = 2;
break; break;
case CommandFlicker : // flicker avoid mode - needs string
params->flickerAvoidMode = flicker_avoid_mode_from_string(arg2);
used = 2;
break;
case CommandAWB : // AWB mode - needs single number parameter case CommandAWB : // AWB mode - needs single number parameter
params->awbMode = awb_mode_from_string(arg2); params->awbMode = awb_mode_from_string(arg2);
used = 2; used = 2;
break; break;
case CommandImageFX : // Image FX - needs string case CommandImageFX : // Image FX - needs string
params->imageEffect = imagefx_mode_from_string(arg2); params->imageEffect = imagefx_mode_from_string(arg2);
used = 2; used = 2;
break; break;
skipping to change at line 649 skipping to change at line 703
} }
case CommandShutterSpeed : // Shutter speed needs single number parameter case CommandShutterSpeed : // Shutter speed needs single number parameter
{ {
sscanf(arg2, "%d", &params->shutter_speed); sscanf(arg2, "%d", &params->shutter_speed);
used = 2; used = 2;
break; break;
} }
case CommandAwbGains : case CommandAwbGains :
{ {
double r,b; double r,b;
int args; int args;
args = sscanf(arg2, "%lf,%lf", &r,&b); args = sscanf(arg2, "%lf,%lf", &r,&b);
if (args != 2 || r > 8.0 || b > 8.0) if (args != 2 || r > 8.0 || b > 8.0)
{ {
return 0; return 0;
} }
params->awb_gains_r = r; params->awb_gains_r = r;
params->awb_gains_b = b; params->awb_gains_b = b;
used = 2; used = 2;
break; break;
} }
case CommandDRCLevel: case CommandDRCLevel:
{ {
params->drc_level = drc_mode_from_string(arg2); params->drc_level = drc_mode_from_string(arg2);
used = 2; used = 2;
break; break;
} }
case CommandStatsPass: case CommandStatsPass:
{ {
skipping to change at line 704 skipping to change at line 758
unsigned char c; unsigned char c;
char const *s = arg2; char const *s = arg2;
char *t = &params->annotate_string[0]; char *t = &params->annotate_string[0];
int n=0; int n=0;
while ((c = *s++) && n < MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1) while ((c = *s++) && n < MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1)
{ {
if (c == '\\' && *s) if (c == '\\' && *s)
{ {
switch (c = *s++) switch (c = *s++)
{ {
case 'n': case 'n':
c = '\n'; c = '\n';
break; break;
default: default:
c = '\\'; c = '\\';
s--; s--;
break; break;
} }
} }
*(t++) = c; *(t++) = c;
n++; n++;
} }
*t='\0'; *t='\0';
//params->annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0 '; //params->annotate_string[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0 ';
} }
used=2; used=2;
break; break;
} }
case CommandAnnotateExtras: case CommandAnnotateExtras:
{ {
// 3 parameters - text size (6-80), text colour (Hex VVUUYY) and backgroun d colour (Hex VVUUYY) // 3 parameters - text size (6-80), text colour (Hex VVUUYY) and backgroun d colour (Hex VVUUYY)
sscanf(arg2, "%u,%X,%X", &params->annotate_text_size, sscanf(arg2, "%u,%X,%X,%u,%u,%u", &params->annotate_text_size,
&params->annotate_text_colour, &params->annotate_text_colour,
&params->annotate_bg_colour); &params->annotate_bg_colour,
&params->annotate_justify,
&params->annotate_x,
&params->annotate_y
);
used=2; used=2;
break; break;
} }
case CommandStereoMode: case CommandStereoMode:
{ {
params->stereo_mode.mode = stereo_mode_from_string(arg2); params->stereo_mode.mode = stereo_mode_from_string(arg2);
used = 2; used = 2;
break; break;
} }
skipping to change at line 756 skipping to change at line 814
break; break;
} }
case CommandStereoSwap: case CommandStereoSwap:
{ {
params->stereo_mode.swap_eyes = MMAL_TRUE; params->stereo_mode.swap_eyes = MMAL_TRUE;
used = 1; used = 1;
break; break;
} }
case CommandAnalogGain:
{
double gain;
int args;
args = sscanf(arg2, "%lf", &gain);
if (args != 1 || gain > 16.0)
{
return 0;
}
params->analog_gain = gain;
used = 2;
break;
}
case CommandDigitalGain:
{
double gain;
int args;
args = sscanf(arg2, "%lf", &gain);
if (args != 1 || gain > 64.0)
{
return 0;
}
params->digital_gain = gain;
used = 2;
break;
}
case CommandSettings:
{
params->settings = 1;
used = 1;
break;
}
} }
return used; return used;
} }
/** /**
* Display help for command line options * Display help for command line options
*/ */
void raspicamcontrol_display_help() void raspicamcontrol_display_help()
{ {
int i; int i;
fprintf(stdout, "\nImage parameter commands\n\n"); fprintf(stdout, "\nImage parameter commands\n\n");
raspicli_display_help(cmdline_commands, cmdline_commands_size); raspicli_display_help(cmdline_commands, cmdline_commands_size);
fprintf(stdout, "\n\nNotes\n\nExposure mode options :\n%s", exposure_map[0].m ode ); fprintf(stdout, "\n\nNotes\n\nExposure mode options :\n%s", exposure_map[0].m ode );
for (i=1;i<exposure_map_size;i++) for (i=1; i<exposure_map_size; i++)
{ {
fprintf(stdout, ",%s", exposure_map[i].mode); fprintf(stdout, ",%s", exposure_map[i].mode);
} }
fprintf(stdout, "\n\nFlicker avoid mode options :\n%s", flicker_avoid_map[0].
mode );
for (i=1; i<flicker_avoid_map_size; i++)
{
fprintf(stdout, ",%s", flicker_avoid_map[i].mode);
}
fprintf(stdout, "\n\nAWB mode options :\n%s", awb_map[0].mode ); fprintf(stdout, "\n\nAWB mode options :\n%s", awb_map[0].mode );
for (i=1;i<awb_map_size;i++) for (i=1; i<awb_map_size; i++)
{ {
fprintf(stdout, ",%s", awb_map[i].mode); fprintf(stdout, ",%s", awb_map[i].mode);
} }
fprintf(stdout, "\n\nImage Effect mode options :\n%s", imagefx_map[0].mode ); fprintf(stdout, "\n\nImage Effect mode options :\n%s", imagefx_map[0].mode );
for (i=1;i<imagefx_map_size;i++) for (i=1; i<imagefx_map_size; i++)
{ {
fprintf(stdout, ",%s", imagefx_map[i].mode); fprintf(stdout, ",%s", imagefx_map[i].mode);
} }
fprintf(stdout, "\n\nMetering Mode options :\n%s", metering_mode_map[0].mode ); fprintf(stdout, "\n\nMetering Mode options :\n%s", metering_mode_map[0].mode );
for (i=1;i<metering_mode_map_size;i++) for (i=1; i<metering_mode_map_size; i++)
{ {
fprintf(stdout, ",%s", metering_mode_map[i].mode); fprintf(stdout, ",%s", metering_mode_map[i].mode);
} }
fprintf(stdout, "\n\nDynamic Range Compression (DRC) options :\n%s", drc_mode _map[0].mode ); fprintf(stdout, "\n\nDynamic Range Compression (DRC) options :\n%s", drc_mode _map[0].mode );
for (i=1;i<drc_mode_map_size;i++) for (i=1; i<drc_mode_map_size; i++)
{ {
fprintf(stdout, ",%s", drc_mode_map[i].mode); fprintf(stdout, ",%s", drc_mode_map[i].mode);
} }
fprintf(stdout, "\n"); fprintf(stdout, "\n");
} }
/** /**
* Dump contents of camera parameter structure to stderr for debugging/verbose l ogging * Dump contents of camera parameter structure to stderr for debugging/verbose l ogging
* *
* @param params Const pointer to parameters structure to dump * @param params Const pointer to parameters structure to dump
*/ */
void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params) void raspicamcontrol_dump_parameters(const RASPICAM_CAMERA_PARAMETERS *params)
{ {
const char *exp_mode = raspicli_unmap_xref(params->exposureMode, exposure_map , exposure_map_size); const char *exp_mode = raspicli_unmap_xref(params->exposureMode, exposure_map , exposure_map_size);
const char *fl_mode = raspicli_unmap_xref(params->flickerAvoidMode, flicker_a void_map, flicker_avoid_map_size);
const char *awb_mode = raspicli_unmap_xref(params->awbMode, awb_map, awb_map_ size); const char *awb_mode = raspicli_unmap_xref(params->awbMode, awb_map, awb_map_ size);
const char *image_effect = raspicli_unmap_xref(params->imageEffect, imagefx_m ap, imagefx_map_size); const char *image_effect = raspicli_unmap_xref(params->imageEffect, imagefx_m ap, imagefx_map_size);
const char *metering_mode = raspicli_unmap_xref(params->exposureMeterMode, me tering_mode_map, metering_mode_map_size); const char *metering_mode = raspicli_unmap_xref(params->exposureMeterMode, me tering_mode_map, metering_mode_map_size);
fprintf(stderr, "Sharpness %d, Contrast %d, Brightness %d\n", params->sharpne ss, params->contrast, params->brightness); fprintf(stderr, "Sharpness %d, Contrast %d, Brightness %d\n", params->sharpne ss, params->contrast, params->brightness);
fprintf(stderr, "Saturation %d, ISO %d, Video Stabilisation %s, Exposure comp ensation %d\n", params->saturation, params->ISO, params->videoStabilisation ? "Y es": "No", params->exposureCompensation); fprintf(stderr, "Saturation %d, ISO %d, Video Stabilisation %s, Exposure comp ensation %d\n", params->saturation, params->ISO, params->videoStabilisation ? "Y es": "No", params->exposureCompensation);
fprintf(stderr, "Exposure Mode '%s', AWB Mode '%s', Image Effect '%s'\n", exp _mode, awb_mode, image_effect); fprintf(stderr, "Exposure Mode '%s', AWB Mode '%s', Image Effect '%s'\n", exp _mode, awb_mode, image_effect);
fprintf(stderr, "Flicker Avoid Mode '%s'\n", fl_mode);
fprintf(stderr, "Metering Mode '%s', Colour Effect Enabled %s with U = %d, V = %d\n", metering_mode, params->colourEffects.enable ? "Yes":"No", params->colou rEffects.u, params->colourEffects.v); fprintf(stderr, "Metering Mode '%s', Colour Effect Enabled %s with U = %d, V = %d\n", metering_mode, params->colourEffects.enable ? "Yes":"No", params->colou rEffects.u, params->colourEffects.v);
fprintf(stderr, "Rotation %d, hflip %s, vflip %s\n", params->rotation, params ->hflip ? "Yes":"No",params->vflip ? "Yes":"No"); fprintf(stderr, "Rotation %d, hflip %s, vflip %s\n", params->rotation, params ->hflip ? "Yes":"No",params->vflip ? "Yes":"No");
fprintf(stderr, "ROI x %lf, y %f, w %f h %f\n", params->roi.x, params->roi.y, params->roi.w, params->roi.h); fprintf(stderr, "ROI x %lf, y %f, w %f h %f\n", params->roi.x, params->roi.y, params->roi.w, params->roi.h);
} }
/** /**
* This function is copied from "RaspiHelpers.h" module, without any changes
* It is inserted here only for usage with motion project
*
* Convert a MMAL status return value to a simple boolean of success * Convert a MMAL status return value to a simple boolean of success
* ALso displays a fault if code is not success * ALso displays a fault if code is not success
* *
* @param status The error code to convert * @param status The error code to convert
* @return 0 if status is success, 1 otherwise * @return 0 if status is success, 1 otherwise
*/ */
int mmal_status_to_int(MMAL_STATUS_T status) int mmal_status_to_int(MMAL_STATUS_T status)
{ {
if (status == MMAL_SUCCESS) if (status == MMAL_SUCCESS)
return 0; return 0;
else else
{ {
switch (status) switch (status)
{ {
case MMAL_ENOMEM : vcos_log_error("Out of memory"); break; case MMAL_ENOMEM :
case MMAL_ENOSPC : vcos_log_error("Out of resources (other than memory)" vcos_log_error("Out of memory");
); break; break;
case MMAL_EINVAL: vcos_log_error("Argument is invalid"); break; case MMAL_ENOSPC :
case MMAL_ENOSYS : vcos_log_error("Function not implemented"); break; vcos_log_error("Out of resources (other than memory)");
case MMAL_ENOENT : vcos_log_error("No such file or directory"); break; break;
case MMAL_ENXIO : vcos_log_error("No such device or address"); break; case MMAL_EINVAL:
case MMAL_EIO : vcos_log_error("I/O error"); break; vcos_log_error("Argument is invalid");
case MMAL_ESPIPE : vcos_log_error("Illegal seek"); break; break;
case MMAL_ECORRUPT : vcos_log_error("Data is corrupt \attention FIXME: not case MMAL_ENOSYS :
POSIX"); break; vcos_log_error("Function not implemented");
case MMAL_ENOTREADY :vcos_log_error("Component is not ready \attention FIX break;
ME: not POSIX"); break; case MMAL_ENOENT :
case MMAL_ECONFIG : vcos_log_error("Component is not configured \attentio vcos_log_error("No such file or directory");
n FIXME: not POSIX"); break; break;
case MMAL_EISCONN : vcos_log_error("Port is already connected "); break; case MMAL_ENXIO :
case MMAL_ENOTCONN : vcos_log_error("Port is disconnected"); break; vcos_log_error("No such device or address");
case MMAL_EAGAIN : vcos_log_error("Resource temporarily unavailable. Try break;
again later"); break; case MMAL_EIO :
case MMAL_EFAULT : vcos_log_error("Bad address"); break; vcos_log_error("I/O error");
default : vcos_log_error("Unknown status error"); break; break;
case MMAL_ESPIPE :
vcos_log_error("Illegal seek");
break;
case MMAL_ECORRUPT :
vcos_log_error("Data is corrupt \attention FIXME: not POSIX");
break;
case MMAL_ENOTREADY :
vcos_log_error("Component is not ready \attention FIXME: not POSIX");
break;
case MMAL_ECONFIG :
vcos_log_error("Component is not configured \attention FIXME: not POSIX
");
break;
case MMAL_EISCONN :
vcos_log_error("Port is already connected ");
break;
case MMAL_ENOTCONN :
vcos_log_error("Port is disconnected");
break;
case MMAL_EAGAIN :
vcos_log_error("Resource temporarily unavailable. Try again later");
break;
case MMAL_EFAULT :
vcos_log_error("Bad address");
break;
default :
vcos_log_error("Unknown status error");
break;
} }
return 1; return 1;
} }
} }
/** /**
* Give the supplied parameter block a set of default values * Give the supplied parameter block a set of default values
* @params Pointer to parameter block * @params Pointer to parameter block
*/ */
skipping to change at line 883 skipping to change at line 1027
vcos_assert(params); vcos_assert(params);
params->sharpness = 0; params->sharpness = 0;
params->contrast = 0; params->contrast = 0;
params->brightness = 50; params->brightness = 50;
params->saturation = 0; params->saturation = 0;
params->ISO = 0; // 0 = auto params->ISO = 0; // 0 = auto
params->videoStabilisation = 0; params->videoStabilisation = 0;
params->exposureCompensation = 0; params->exposureCompensation = 0;
params->exposureMode = MMAL_PARAM_EXPOSUREMODE_AUTO; params->exposureMode = MMAL_PARAM_EXPOSUREMODE_AUTO;
params->flickerAvoidMode = MMAL_PARAM_FLICKERAVOID_OFF;
params->exposureMeterMode = MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE; params->exposureMeterMode = MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE;
params->awbMode = MMAL_PARAM_AWBMODE_AUTO; params->awbMode = MMAL_PARAM_AWBMODE_AUTO;
params->imageEffect = MMAL_PARAM_IMAGEFX_NONE; params->imageEffect = MMAL_PARAM_IMAGEFX_NONE;
params->colourEffects.enable = 0; params->colourEffects.enable = 0;
params->colourEffects.u = 128; params->colourEffects.u = 128;
params->colourEffects.v = 128; params->colourEffects.v = 128;
params->rotation = 0; params->rotation = 0;
params->hflip = params->vflip = 0; params->hflip = params->vflip = 0;
params->roi.x = params->roi.y = 0.0; params->roi.x = params->roi.y = 0.0;
params->roi.w = params->roi.h = 1.0; params->roi.w = params->roi.h = 1.0;
skipping to change at line 906 skipping to change at line 1051
params->drc_level = MMAL_PARAMETER_DRC_STRENGTH_OFF; params->drc_level = MMAL_PARAMETER_DRC_STRENGTH_OFF;
params->stats_pass = MMAL_FALSE; params->stats_pass = MMAL_FALSE;
params->enable_annotate = 0; params->enable_annotate = 0;
params->annotate_string[0] = '\0'; params->annotate_string[0] = '\0';
params->annotate_text_size = 0; //Use firmware default params->annotate_text_size = 0; //Use firmware default
params->annotate_text_colour = -1; //Use firmware default params->annotate_text_colour = -1; //Use firmware default
params->annotate_bg_colour = -1; //Use firmware default params->annotate_bg_colour = -1; //Use firmware default
params->stereo_mode.mode = MMAL_STEREOSCOPIC_MODE_NONE; params->stereo_mode.mode = MMAL_STEREOSCOPIC_MODE_NONE;
params->stereo_mode.decimate = MMAL_FALSE; params->stereo_mode.decimate = MMAL_FALSE;
params->stereo_mode.swap_eyes = MMAL_FALSE; params->stereo_mode.swap_eyes = MMAL_FALSE;
params->annotate_justify = 0;
params->annotate_x = 0;
params->annotate_y = 0;
params->analog_gain = 0;
params->digital_gain = 0;
params->settings = 0;
} }
/** /**
* Get all the current camera parameters from specified camera component * Get all the current camera parameters from specified camera component
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param params Pointer to parameter block to accept settings * @param params Pointer to parameter block to accept settings
* @return 0 if successful, non-zero if unsuccessful * @return 0 if successful, non-zero if unsuccessful
*/ */
int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA _PARAMETERS *params) int raspicamcontrol_get_all_parameters(MMAL_COMPONENT_T *camera, RASPICAM_CAMERA _PARAMETERS *params)
{ {
vcos_assert(camera); vcos_assert(camera);
vcos_assert(params); vcos_assert(params);
if (!camera || !params) if (!camera || !params)
return 1; return 1;
/* TODO : Write these get functions /* TODO : Write these get functions
params->sharpness = raspicamcontrol_get_sharpness(camera); params->sharpness = raspicamcontrol_get_sharpness(camera);
params->contrast = raspicamcontrol_get_contrast(camera); params->contrast = raspicamcontrol_get_contrast(camera);
params->brightness = raspicamcontrol_get_brightness(camera); params->brightness = raspicamcontrol_get_brightness(camera);
params->saturation = raspicamcontrol_get_saturation(camera); params->saturation = raspicamcontrol_get_saturation(camera);
params->ISO = raspicamcontrol_get_ISO(camera); params->ISO = raspicamcontrol_get_ISO(camera);
params->videoStabilisation = raspicamcontrol_get_video_stabilisation(camera); params->videoStabilisation = raspicamcontrol_get_video_stabilisation(camer
params->exposureCompensation = raspicamcontrol_get_exposure_compensation(came a);
ra); params->exposureCompensation = raspicamcontrol_get_exposure_compensation(c
params->exposureMode = raspicamcontrol_get_exposure_mode(camera); amera);
params->awbMode = raspicamcontrol_get_awb_mode(camera); params->exposureMode = raspicamcontrol_get_exposure_mode(camera);
params->imageEffect = raspicamcontrol_get_image_effect(camera); params->flickerAvoidMode = raspicamcontrol_get_flicker_avoid_mode(camera);
params->colourEffects = raspicamcontrol_get_colour_effect(camera); params->awbMode = raspicamcontrol_get_awb_mode(camera);
params->thumbnailConfig = raspicamcontrol_get_thumbnail_config(camera); params->imageEffect = raspicamcontrol_get_image_effect(camera);
*/ params->colourEffects = raspicamcontrol_get_colour_effect(camera);
params->thumbnailConfig = raspicamcontrol_get_thumbnail_config(camera);
*/
return 0; return 0;
} }
/** /**
* Set the specified camera to all the specified settings * Set the specified camera to all the specified settings
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param params Pointer to parameter block containing parameters * @param params Pointer to parameter block containing parameters
* @return 0 if successful, none-zero if unsuccessful. * @return 0 if successful, none-zero if unsuccessful.
*/ */
int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_ CAMERA_PARAMETERS *params) int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_ CAMERA_PARAMETERS *params)
skipping to change at line 957 skipping to change at line 1109
int result; int result;
result = raspicamcontrol_set_saturation(camera, params->saturation); result = raspicamcontrol_set_saturation(camera, params->saturation);
result += raspicamcontrol_set_sharpness(camera, params->sharpness); result += raspicamcontrol_set_sharpness(camera, params->sharpness);
result += raspicamcontrol_set_contrast(camera, params->contrast); result += raspicamcontrol_set_contrast(camera, params->contrast);
result += raspicamcontrol_set_brightness(camera, params->brightness); result += raspicamcontrol_set_brightness(camera, params->brightness);
result += raspicamcontrol_set_ISO(camera, params->ISO); result += raspicamcontrol_set_ISO(camera, params->ISO);
result += raspicamcontrol_set_video_stabilisation(camera, params->videoStabil isation); result += raspicamcontrol_set_video_stabilisation(camera, params->videoStabil isation);
result += raspicamcontrol_set_exposure_compensation(camera, params->exposureC ompensation); result += raspicamcontrol_set_exposure_compensation(camera, params->exposureC ompensation);
result += raspicamcontrol_set_exposure_mode(camera, params->exposureMode); result += raspicamcontrol_set_exposure_mode(camera, params->exposureMode);
result += raspicamcontrol_set_flicker_avoid_mode(camera, params->flickerAvoid Mode);
result += raspicamcontrol_set_metering_mode(camera, params->exposureMeterMode ); result += raspicamcontrol_set_metering_mode(camera, params->exposureMeterMode );
result += raspicamcontrol_set_awb_mode(camera, params->awbMode); result += raspicamcontrol_set_awb_mode(camera, params->awbMode);
result += raspicamcontrol_set_awb_gains(camera, params->awb_gains_r, params-> awb_gains_b); result += raspicamcontrol_set_awb_gains(camera, params->awb_gains_r, params-> awb_gains_b);
result += raspicamcontrol_set_imageFX(camera, params->imageEffect); result += raspicamcontrol_set_imageFX(camera, params->imageEffect);
result += raspicamcontrol_set_colourFX(camera, &params->colourEffects); result += raspicamcontrol_set_colourFX(camera, &params->colourEffects);
//result += raspicamcontrol_set_thumbnail_parameters(camera, &params->thumbna ilConfig); TODO Not working for some reason //result += raspicamcontrol_set_thumbnail_parameters(camera, &params->thumbna ilConfig); TODO Not working for some reason
result += raspicamcontrol_set_rotation(camera, params->rotation); result += raspicamcontrol_set_rotation(camera, params->rotation);
result += raspicamcontrol_set_flips(camera, params->hflip, params->vflip); result += raspicamcontrol_set_flips(camera, params->hflip, params->vflip);
result += raspicamcontrol_set_ROI(camera, params->roi); result += raspicamcontrol_set_ROI(camera, params->roi);
result += raspicamcontrol_set_shutter_speed(camera, params->shutter_speed); result += raspicamcontrol_set_shutter_speed(camera, params->shutter_speed);
result += raspicamcontrol_set_DRC(camera, params->drc_level); result += raspicamcontrol_set_DRC(camera, params->drc_level);
result += raspicamcontrol_set_stats_pass(camera, params->stats_pass); result += raspicamcontrol_set_stats_pass(camera, params->stats_pass);
result += raspicamcontrol_set_annotate(camera, params->enable_annotate, param s->annotate_string, result += raspicamcontrol_set_annotate(camera, params->enable_annotate, param s->annotate_string,
params->annotate_text_size, params->annotate_text_size,
params->annotate_text_colour, params->annotate_text_colour,
params->annotate_bg_colour); params->annotate_bg_colour,
params->annotate_justify,
params->annotate_x,
params->annotate_y);
result += raspicamcontrol_set_gains(camera, params->analog_gain, params->digi
tal_gain);
if (params->settings)
{
MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T change_event_request =
{
{MMAL_PARAMETER_CHANGE_EVENT_REQUEST, sizeof(MMAL_PARAMETER_CHANGE_EVEN
T_REQUEST_T)},
MMAL_PARAMETER_CAMERA_SETTINGS, 1
};
MMAL_STATUS_T status = mmal_port_parameter_set(camera->control, &change_ev
ent_request.hdr);
if ( status != MMAL_SUCCESS )
{
vcos_log_error("No camera settings events");
}
result += status;
}
return result; return result;
} }
/** /**
* Adjust the saturation level for images * Adjust the saturation level for images
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param saturation Value to adjust, -100 to 100 * @param saturation Value to adjust, -100 to 100
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
skipping to change at line 1111 skipping to change at line 1285
* @param saturation Value from following * @param saturation Value from following
* - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE, * - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
* - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT, * - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
* - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT, * - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
* - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX * - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOS UREMETERINGMODE_T m_mode ) int raspicamcontrol_set_metering_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_EXPOS UREMETERINGMODE_T m_mode )
{ {
MMAL_PARAMETER_EXPOSUREMETERINGMODE_T meter_mode = {{MMAL_PARAMETER_EXP_METER ING_MODE,sizeof(meter_mode)}, MMAL_PARAMETER_EXPOSUREMETERINGMODE_T meter_mode = {{MMAL_PARAMETER_EXP_METER ING_MODE,sizeof(meter_mode)},
m_mode}; m_mode
};
if (!camera) if (!camera)
return 1; return 1;
return mmal_status_to_int(mmal_port_parameter_set(camera->control, &meter_mod e.hdr)); return mmal_status_to_int(mmal_port_parameter_set(camera->control, &meter_mod e.hdr));
} }
/** /**
* Set the video stabilisation flag. Only used in video mode * Set the video stabilisation flag. Only used in video mode
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param saturation Flag 0 off 1 on * @param saturation Flag 0 off 1 on
skipping to change at line 1143 skipping to change at line 1318
* Adjust the exposure compensation for images (EV) * Adjust the exposure compensation for images (EV)
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param exp_comp Value to adjust, -10 to +10 * @param exp_comp Value to adjust, -10 to +10
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_ comp) int raspicamcontrol_set_exposure_compensation(MMAL_COMPONENT_T *camera, int exp_ comp)
{ {
if (!camera) if (!camera)
return 1; return 1;
return mmal_status_to_int(mmal_port_parameter_set_int32(camera->control, MMAL _PARAMETER_EXPOSURE_COMP , exp_comp)); return mmal_status_to_int(mmal_port_parameter_set_int32(camera->control, MMAL _PARAMETER_EXPOSURE_COMP, exp_comp));
} }
/** /**
* Set exposure mode for images * Set exposure mode for images
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param mode Exposure mode to set from * @param mode Exposure mode to set from
* - MMAL_PARAM_EXPOSUREMODE_OFF, * - MMAL_PARAM_EXPOSUREMODE_OFF,
* - MMAL_PARAM_EXPOSUREMODE_AUTO, * - MMAL_PARAM_EXPOSUREMODE_AUTO,
* - MMAL_PARAM_EXPOSUREMODE_NIGHT, * - MMAL_PARAM_EXPOSUREMODE_NIGHT,
* - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, * - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
skipping to change at line 1177 skipping to change at line 1352
{ {
MMAL_PARAMETER_EXPOSUREMODE_T exp_mode = {{MMAL_PARAMETER_EXPOSURE_MODE,sizeo f(exp_mode)}, mode}; MMAL_PARAMETER_EXPOSUREMODE_T exp_mode = {{MMAL_PARAMETER_EXPOSURE_MODE,sizeo f(exp_mode)}, mode};
if (!camera) if (!camera)
return 1; return 1;
return mmal_status_to_int(mmal_port_parameter_set(camera->control, &exp_mode. hdr)); return mmal_status_to_int(mmal_port_parameter_set(camera->control, &exp_mode. hdr));
} }
/** /**
* Set flicker avoid mode for images
* @param camera Pointer to camera component
* @param mode Exposure mode to set from
* - MMAL_PARAM_FLICKERAVOID_OFF,
* - MMAL_PARAM_FLICKERAVOID_AUTO,
* - MMAL_PARAM_FLICKERAVOID_50HZ,
* - MMAL_PARAM_FLICKERAVOID_60HZ,
*
* @return 0 if successful, non-zero if any parameters out of range
*/
int raspicamcontrol_set_flicker_avoid_mode(MMAL_COMPONENT_T *camera, MMAL_PARAM_
FLICKERAVOID_T mode)
{
MMAL_PARAMETER_FLICKERAVOID_T fl_mode = {{MMAL_PARAMETER_FLICKER_AVOID,sizeof
(fl_mode)}, mode};
if (!camera)
return 1;
return mmal_status_to_int(mmal_port_parameter_set(camera->control, &fl_mode.h
dr));
}
/**
* Set the aWB (auto white balance) mode for images * Set the aWB (auto white balance) mode for images
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param awb_mode Value to set from * @param awb_mode Value to set from
* - MMAL_PARAM_AWBMODE_OFF, * - MMAL_PARAM_AWBMODE_OFF,
* - MMAL_PARAM_AWBMODE_AUTO, * - MMAL_PARAM_AWBMODE_AUTO,
* - MMAL_PARAM_AWBMODE_SUNLIGHT, * - MMAL_PARAM_AWBMODE_SUNLIGHT,
* - MMAL_PARAM_AWBMODE_CLOUDY, * - MMAL_PARAM_AWBMODE_CLOUDY,
* - MMAL_PARAM_AWBMODE_SHADE, * - MMAL_PARAM_AWBMODE_SHADE,
* - MMAL_PARAM_AWBMODE_TUNGSTEN, * - MMAL_PARAM_AWBMODE_TUNGSTEN,
* - MMAL_PARAM_AWBMODE_FLUORESCENT, * - MMAL_PARAM_AWBMODE_FLUORESCENT,
skipping to change at line 1299 skipping to change at line 1495
*/ */
int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation) int raspicamcontrol_set_rotation(MMAL_COMPONENT_T *camera, int rotation)
{ {
int ret; int ret;
int my_rotation = ((rotation % 360 ) / 90) * 90; int my_rotation = ((rotation % 360 ) / 90) * 90;
ret = mmal_port_parameter_set_int32(camera->output[0], MMAL_PARAMETER_ROTATIO N, my_rotation); ret = mmal_port_parameter_set_int32(camera->output[0], MMAL_PARAMETER_ROTATIO N, my_rotation);
mmal_port_parameter_set_int32(camera->output[1], MMAL_PARAMETER_ROTATION, my_ rotation); mmal_port_parameter_set_int32(camera->output[1], MMAL_PARAMETER_ROTATION, my_ rotation);
mmal_port_parameter_set_int32(camera->output[2], MMAL_PARAMETER_ROTATION, my_ rotation); mmal_port_parameter_set_int32(camera->output[2], MMAL_PARAMETER_ROTATION, my_ rotation);
return ret; return mmal_status_to_int(ret);
} }
/** /**
* Set the flips state of the image * Set the flips state of the image
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param hflip If true, horizontally flip the image * @param hflip If true, horizontally flip the image
* @param vflip If true, vertically flip the image * @param vflip If true, vertically flip the image
* *
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip) int raspicamcontrol_set_flips(MMAL_COMPONENT_T *camera, int hflip, int vflip)
{ {
MMAL_PARAMETER_MIRROR_T mirror = {{MMAL_PARAMETER_MIRROR, sizeof(MMAL_PARAMET ER_MIRROR_T)}, MMAL_PARAM_MIRROR_NONE}; MMAL_PARAMETER_MIRROR_T mirror = {{MMAL_PARAMETER_MIRROR, sizeof(MMAL_PARAMET ER_MIRROR_T)}, MMAL_PARAM_MIRROR_NONE};
if (hflip && vflip) if (hflip && vflip)
mirror.value = MMAL_PARAM_MIRROR_BOTH; mirror.value = MMAL_PARAM_MIRROR_BOTH;
else else if (hflip)
if (hflip)
mirror.value = MMAL_PARAM_MIRROR_HORIZONTAL; mirror.value = MMAL_PARAM_MIRROR_HORIZONTAL;
else else if (vflip)
if (vflip)
mirror.value = MMAL_PARAM_MIRROR_VERTICAL; mirror.value = MMAL_PARAM_MIRROR_VERTICAL;
mmal_port_parameter_set(camera->output[0], &mirror.hdr); mmal_port_parameter_set(camera->output[0], &mirror.hdr);
mmal_port_parameter_set(camera->output[1], &mirror.hdr); mmal_port_parameter_set(camera->output[1], &mirror.hdr);
return mmal_port_parameter_set(camera->output[2], &mirror.hdr); return mmal_status_to_int(mmal_port_parameter_set(camera->output[2], &mirror. hdr));
} }
/** /**
* Set the ROI of the sensor to use for captures/preview * Set the ROI of the sensor to use for captures/preview
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param rect Normalised coordinates of ROI rectangle * @param rect Normalised coordinates of ROI rectangle
* *
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect) int raspicamcontrol_set_ROI(MMAL_COMPONENT_T *camera, PARAM_FLOAT_RECT_T rect)
{ {
MMAL_PARAMETER_INPUT_CROP_T crop = {{MMAL_PARAMETER_INPUT_CROP, sizeof(MMAL_P ARAMETER_INPUT_CROP_T)}}; MMAL_PARAMETER_INPUT_CROP_T crop = {{MMAL_PARAMETER_INPUT_CROP, sizeof(MMAL_P ARAMETER_INPUT_CROP_T)}};
crop.rect.x = (65536 * rect.x); crop.rect.x = (65536 * rect.x);
crop.rect.y = (65536 * rect.y); crop.rect.y = (65536 * rect.y);
crop.rect.width = (65536 * rect.w); crop.rect.width = (65536 * rect.w);
crop.rect.height = (65536 * rect.h); crop.rect.height = (65536 * rect.h);
return mmal_port_parameter_set(camera->control, &crop.hdr); return mmal_status_to_int(mmal_port_parameter_set(camera->control, &crop.hdr)
);
}
/**
* Zoom in and Zoom out by changing ROI
* @param camera Pointer to camera component
* @param zoom_command zoom command enum
* @return 0 if successful, non-zero otherwise
*/
int raspicamcontrol_zoom_in_zoom_out(MMAL_COMPONENT_T *camera, ZOOM_COMMAND_T zo
om_command, PARAM_FLOAT_RECT_T *roi)
{
MMAL_PARAMETER_INPUT_CROP_T crop;
crop.hdr.id = MMAL_PARAMETER_INPUT_CROP;
crop.hdr.size = sizeof(crop);
if (mmal_port_parameter_get(camera->control, &crop.hdr) != MMAL_SUCCESS)
{
vcos_log_error("mmal_port_parameter_get(camera->control, &crop.hdr) failed
, skip it");
return 0;
}
if (zoom_command == ZOOM_IN)
{
if (crop.rect.width <= (zoom_full_16P16 + zoom_increment_16P16))
{
crop.rect.width = zoom_full_16P16;
crop.rect.height = zoom_full_16P16;
}
else
{
crop.rect.width -= zoom_increment_16P16;
crop.rect.height -= zoom_increment_16P16;
}
}
else if (zoom_command == ZOOM_OUT)
{
unsigned int increased_size = crop.rect.width + zoom_increment_16P16;
if (increased_size < crop.rect.width) //overflow
{
crop.rect.width = 65536;
crop.rect.height = 65536;
}
else
{
crop.rect.width = increased_size;
crop.rect.height = increased_size;
}
}
if (zoom_command == ZOOM_RESET)
{
crop.rect.x = 0;
crop.rect.y = 0;
crop.rect.width = 65536;
crop.rect.height = 65536;
}
else
{
unsigned int centered_top_coordinate = (65536 - crop.rect.width) / 2;
crop.rect.x = centered_top_coordinate;
crop.rect.y = centered_top_coordinate;
}
int ret = mmal_status_to_int(mmal_port_parameter_set(camera->control, &crop.h
dr));
if (ret == 0)
{
roi->x = roi->y = (double)crop.rect.x/65536;
roi->w = roi->h = (double)crop.rect.width/65536;
}
else
{
vcos_log_error("Failed to set crop values, x/y: %u, w/h: %u", crop.rect.x,
crop.rect.width);
ret = 1;
}
return ret;
} }
/** /**
* Adjust the exposure time used for images * Adjust the exposure time used for images
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param shutter speed in microseconds * @param shutter speed in microseconds
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed) int raspicamcontrol_set_shutter_speed(MMAL_COMPONENT_T *camera, int speed)
{ {
skipping to change at line 1399 skipping to change at line 1669
/** /**
* Set the annotate data * Set the annotate data
* @param camera Pointer to camera component * @param camera Pointer to camera component
* @param Bitmask of required annotation data. 0 for off. * @param Bitmask of required annotation data. 0 for off.
* @param If set, a pointer to text string to use instead of bitmask, max length 32 characters * @param If set, a pointer to text string to use instead of bitmask, max length 32 characters
* *
* @return 0 if successful, non-zero if any parameters out of range * @return 0 if successful, non-zero if any parameters out of range
*/ */
int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c onst char *string, int raspicamcontrol_set_annotate(MMAL_COMPONENT_T *camera, const int settings, c onst char *string,
const int text_size, const int text_colour, const int bg_colour) const int text_size, const int text_colour, con
st int bg_colour,
const unsigned int justify, const unsigned int
x, const unsigned int y)
{ {
MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T annotate = MMAL_PARAMETER_CAMERA_ANNOTATE_V4_T annotate =
{{MMAL_PARAMETER_ANNOTATE, sizeof(MMAL_PARAMETER_CAMERA_ANNOTATE_V3_T)}}; {{MMAL_PARAMETER_ANNOTATE, sizeof(MMAL_PARAMETER_CAMERA_ANNOTATE_V4_T)}};
if (settings) if (settings)
{ {
time_t t = time(NULL); time_t t = time(NULL);
struct tm tm = *localtime(&t); struct tm tm = *localtime(&t);
char tmp[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3]; char tmp[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V4];
int process_datetime = 1; int process_datetime = 1;
annotate.enable = 1; annotate.enable = 1;
if (settings & (ANNOTATE_APP_TEXT | ANNOTATE_USER_TEXT)) if (settings & (ANNOTATE_APP_TEXT | ANNOTATE_USER_TEXT))
{ {
if ((settings & (ANNOTATE_TIME_TEXT | ANNOTATE_DATE_TEXT)) && strchr(st ring,'%') != NULL) if ((settings & (ANNOTATE_TIME_TEXT | ANNOTATE_DATE_TEXT)) && strchr(st ring,'%') != NULL)
{ //string contains strftime parameter? {
//string contains strftime parameter?
strftime(annotate.text, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3, string , &tm ); strftime(annotate.text, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3, string , &tm );
process_datetime = 0; process_datetime = 0;
}else{ }
else
{
strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3) ; strncpy(annotate.text, string, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3) ;
} }
annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0'; annotate.text[MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3-1] = '\0';
} }
if (process_datetime && (settings & ANNOTATE_TIME_TEXT)) if (process_datetime && (settings & ANNOTATE_TIME_TEXT))
{ {
if(strlen(annotate.text)){ if(strlen(annotate.text))
{
strftime(tmp, 32, " %X", &tm ); strftime(tmp, 32, " %X", &tm );
}else{ }
else
{
strftime(tmp, 32, "%X", &tm ); strftime(tmp, 32, "%X", &tm );
} }
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strl en(annotate.text) - 1); strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strl en(annotate.text) - 1);
} }
if (process_datetime && (settings & ANNOTATE_DATE_TEXT)) if (process_datetime && (settings & ANNOTATE_DATE_TEXT))
{ {
if(strlen(annotate.text)){ if(strlen(annotate.text))
{
strftime(tmp, 32, " %x", &tm ); strftime(tmp, 32, " %x", &tm );
}else{ }
else
{
strftime(tmp, 32, "%x", &tm ); strftime(tmp, 32, "%x", &tm );
} }
strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strl en(annotate.text) - 1); strncat(annotate.text, tmp, MMAL_CAMERA_ANNOTATE_MAX_TEXT_LEN_V3 - strl en(annotate.text) - 1);
} }
if (settings & ANNOTATE_SHUTTER_SETTINGS) if (settings & ANNOTATE_SHUTTER_SETTINGS)
annotate.show_shutter = MMAL_TRUE; annotate.show_shutter = MMAL_TRUE;
if (settings & ANNOTATE_GAIN_SETTINGS) if (settings & ANNOTATE_GAIN_SETTINGS)
annotate.show_analog_gain = MMAL_TRUE; annotate.show_analog_gain = MMAL_TRUE;
skipping to change at line 1487 skipping to change at line 1767
if (bg_colour != -1) if (bg_colour != -1)
{ {
annotate.custom_background_colour = MMAL_TRUE; annotate.custom_background_colour = MMAL_TRUE;
annotate.custom_background_Y = bg_colour&0xff; annotate.custom_background_Y = bg_colour&0xff;
annotate.custom_background_U = (bg_colour>>8)&0xff; annotate.custom_background_U = (bg_colour>>8)&0xff;
annotate.custom_background_V = (bg_colour>>16)&0xff; annotate.custom_background_V = (bg_colour>>16)&0xff;
} }
else else
annotate.custom_background_colour = MMAL_FALSE; annotate.custom_background_colour = MMAL_FALSE;
}
else annotate.justify = justify;
annotate.enable = 0; annotate.x_offset = x;
annotate.y_offset = y;
}
else
annotate.enable = 0;
return mmal_status_to_int(mmal_port_parameter_set(camera->control, &annotate. hdr)); return mmal_status_to_int(mmal_port_parameter_set(camera->control, &annotate. hdr));
} }
int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOP IC_MODE_T *stereo_mode) int raspicamcontrol_set_stereo_mode(MMAL_PORT_T *port, MMAL_PARAMETER_STEREOSCOP IC_MODE_T *stereo_mode)
{ {
MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo = { {MMAL_PARAMETER_STEREOSCOPIC_MO DE, sizeof(stereo)}, MMAL_PARAMETER_STEREOSCOPIC_MODE_T stereo = { {MMAL_PARAMETER_STEREOSCOPIC_MO DE, sizeof(stereo)},
MMAL_STEREOSCOPIC_MODE_NONE, MMAL_FALSE, MMAL_FAL MMAL_STEREOSCOPIC_MODE_NONE, MMAL_FALSE, MMAL_FALSE
SE }; };
if (stereo_mode->mode != MMAL_STEREOSCOPIC_MODE_NONE) if (stereo_mode->mode != MMAL_STEREOSCOPIC_MODE_NONE)
{ {
stereo.mode = stereo_mode->mode; stereo.mode = stereo_mode->mode;
stereo.decimate = stereo_mode->decimate; stereo.decimate = stereo_mode->decimate;
stereo.swap_eyes = stereo_mode->swap_eyes; stereo.swap_eyes = stereo_mode->swap_eyes;
} }
return mmal_status_to_int(mmal_port_parameter_set(port, &stereo.hdr)); return mmal_status_to_int(mmal_port_parameter_set(port, &stereo.hdr));
} }
int raspicamcontrol_set_gains(MMAL_COMPONENT_T *camera, float analog, float digi
tal)
{
MMAL_RATIONAL_T rational = {0,65536};
MMAL_STATUS_T status;
if (!camera)
return 1;
rational.num = (unsigned int)(analog * 65536);
status = mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_ANA
LOG_GAIN, rational);
if (status != MMAL_SUCCESS)
return mmal_status_to_int(status);
rational.num = (unsigned int)(digital * 65536);
status = mmal_port_parameter_set_rational(camera->control, MMAL_PARAMETER_DIG
ITAL_GAIN, rational);
return mmal_status_to_int(status);
}
/** /**
* Asked GPU how much memory it has allocated * Asked GPU how much memory it has allocated
* *
* @return amount of memory in MB * @return amount of memory in MB
*/ */
static int raspicamcontrol_get_mem_gpu(void) static int raspicamcontrol_get_mem_gpu(void)
{ {
char response[80] = ""; char response[80] = "";
int gpu_mem = 0; int gpu_mem = 0;
if (vc_gencmd(response, sizeof response, "get_mem gpu") == 0) if (vc_gencmd(response, sizeof response, "get_mem gpu") == 0)
skipping to change at line 1539 skipping to change at line 1842
if (vc_gencmd(response, sizeof response, "get_camera") == 0) if (vc_gencmd(response, sizeof response, "get_camera") == 0)
{ {
if (supported) if (supported)
vc_gencmd_number_property(response, "supported", supported); vc_gencmd_number_property(response, "supported", supported);
if (detected) if (detected)
vc_gencmd_number_property(response, "detected", detected); vc_gencmd_number_property(response, "detected", detected);
} }
} }
/** /**
* Check to see if camera is supported, and we have allocated enough meooryAsk G * Check to see if camera is supported, and we have allocated enough memory
PU about its camera abilities * Ask GPU about its camera abilities
* @param supported None-zero if software supports the camera * @param supported None-zero if software supports the camera
* @param detected None-zero if a camera has been detected * @param detected None-zero if a camera has been detected
*/ */
void raspicamcontrol_check_configuration(int min_gpu_mem) void raspicamcontrol_check_configuration(int min_gpu_mem)
{ {
int gpu_mem = raspicamcontrol_get_mem_gpu(); int gpu_mem = raspicamcontrol_get_mem_gpu();
int supported = 0, detected = 0; int supported = 0, detected = 0;
raspicamcontrol_get_camera(&supported, &detected); raspicamcontrol_get_camera(&supported, &detected);
if (!supported) if (!supported)
vcos_log_error("Camera is not enabled in this build. Try running \"sudo ra spi-config\" and ensure that \"camera\" has been enabled\n"); vcos_log_error("Camera is not enabled in this build. Try running \"sudo ra spi-config\" and ensure that \"camera\" has been enabled\n");
else if (gpu_mem < min_gpu_mem) else if (gpu_mem < min_gpu_mem)
vcos_log_error("Only %dM of gpu_mem is configured. Try running \"sudo rasp i-config\" and ensure that \"memory_split\" has a value of %d or greater\n", gpu _mem, min_gpu_mem); vcos_log_error("Only %dM of gpu_mem is configured. Try running \"sudo rasp i-config\" and ensure that \"memory_split\" has a value of %d or greater\n", gpu _mem, min_gpu_mem);
else if (!detected) else if (!detected)
vcos_log_error("Camera is not detected. Please check carefully the camera module is installed correctly\n"); vcos_log_error("Camera is not detected. Please check carefully the camera module is installed correctly\n");
else else
vcos_log_error("Failed to run camera app. Please check for firmware update s\n"); vcos_log_error("Failed to run camera app. Please check for firmware update s\n");
} }
/** Default camera callback function
* Handles the --settings
* @param port
* @param Callback data
*/
void default_camera_control_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *bu
ffer)
{
fprintf(stderr, "Camera control callback cmd=0x%08x", buffer->cmd);
if (buffer->cmd == MMAL_EVENT_PARAMETER_CHANGED)
{
MMAL_EVENT_PARAMETER_CHANGED_T *param = (MMAL_EVENT_PARAMETER_CHANGED_T *)
buffer->data;
switch (param->hdr.id)
{
case MMAL_PARAMETER_CAMERA_SETTINGS:
{
MMAL_PARAMETER_CAMERA_SETTINGS_T *settings = (MMAL_PARAMETER_CAMERA_SET
TINGS_T*)param;
vcos_log_error("Exposure now %u, analog gain %u/%u, digital gain %u/%u"
,
settings->exposure,
settings->analog_gain.num, settings->analog_gain.den,
settings->digital_gain.num, settings->digital_gain.den);
vcos_log_error("AWB R=%u/%u, B=%u/%u",
settings->awb_red_gain.num, settings->awb_red_gain.den,
settings->awb_blue_gain.num, settings->awb_blue_gain.den
);
}
break;
}
}
else if (buffer->cmd == MMAL_EVENT_ERROR)
{
vcos_log_error("No data received from sensor. Check all connections, inclu
ding the Sunny one on the camera board");
}
else
{
vcos_log_error("Received unexpected camera control callback event, 0x%08x"
, buffer->cmd);
}
mmal_buffer_header_release(buffer);
}
 End of changes. 63 change blocks. 
135 lines changed or deleted 460 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)