cmd/revid-cli & revid: adding raspivid exposure and brightness parameters

Started working on adding exposure, brightness, saturation and awb flags to revid-cli so that we can control raspivid parameters.
Updated revid logic to give these to raspivid and updated config to consider these parameters in config validation.
This commit is contained in:
Matthew Michael 2019-03-15 12:44:13 +10:30
parent 300b55548b
commit 9a510f5c31
3 changed files with 32 additions and 0 deletions

View File

@ -128,6 +128,12 @@ func handleFlags() revid.Config {
logPathPtr = flag.String("LogPath", defaultLogPath, "The log path")
configFilePtr = flag.String("ConfigFile", "", "NetSender config file")
sendRetryPtr = flag.Bool("retry", false, "Specify whether a failed send should be retried.")
brightnessPtr = flag.Uint("Brightness", -1, "Set Brightness: 0-100 ")
saturationPtr = flag.Uint("Saturation", 0, "Set Saturation: -100:100")
exposurePtr = flag.String("Exposure", "", "Set Exposure Mode: Auto/Night/Spotlight")
autoWhiteBalancePtr = flag.String("AutoWhiteBalance", "", "Set Automatic White Balance mode")
)
var outputs flagStrings
@ -234,6 +240,7 @@ func handleFlags() revid.Config {
log.Log(logger.Error, pkg+"bad packetization argument")
}
if *configFilePtr != "" {
netsender.ConfigFile = *configFilePtr
}
@ -255,6 +262,11 @@ func handleFlags() revid.Config {
cfg.RtpAddress = *rtpAddrPtr
cfg.SendRetry = *sendRetryPtr
cfg.Brightness = *brightnessPtr
cfg.Saturation = *saturationPtr
cfg.Exposure = *exposurePtr
cfg.AutoWhiteBalance = *autoWhiteBalancePtr
return cfg
}

View File

@ -69,6 +69,11 @@ type Config struct {
Logger Logger
SendRetry bool
BurstPeriod uint
Brightness uint
Saturation uint
Exposure string
AutoWhiteBalance string
}
// Enums for config struct
@ -116,6 +121,10 @@ const (
defaultVerbosity = No // FIXME(kortschak): This makes no sense whatsoever. No is currently 15.
defaultRtpAddr = "localhost:6970"
defaultBurstPeriod = 10 // Seconds
notDefinedBrightness =-1 //outside range (0-100)
notDefinedSaturation =-101 //outside range (-100-(100))
)
// Validate checks for any errors in the config fields and defaults settings

View File

@ -609,6 +609,17 @@ func (r *Revid) startRaspivid() error {
"--height", fmt.Sprint(r.config.Height),
"--bitrate", fmt.Sprint(r.config.Bitrate),
"--framerate", fmt.Sprint(r.config.FrameRate),
"--brightness", fmt.Sprint(r.config.Brightness),
"--saturation", fmt.Sprint(r.config.Saturation),
"--exposure", fmt.Sprint(r.config.Exposure),
"--awb", fmt.Sprint(r.config.AutoWhiteBalance),
}
if cfg.Brightness != notDefinedBrightness {
args = append(args, "--brightness")
}
if cfg.Saturation != notDefinedSaturation {
args = append(args, "--saturation")
}
if r.config.FlipHorizontal {
args = append(args, "--hflip")