mirror of https://bitbucket.org/ausocean/av.git
revid: completed addition of exposure, awb, saturation and brightness options
This commit is contained in:
parent
9a510f5c31
commit
9d5771fcbf
|
@ -128,12 +128,10 @@ func handleFlags() revid.Config {
|
||||||
logPathPtr = flag.String("LogPath", defaultLogPath, "The log path")
|
logPathPtr = flag.String("LogPath", defaultLogPath, "The log path")
|
||||||
configFilePtr = flag.String("ConfigFile", "", "NetSender config file")
|
configFilePtr = flag.String("ConfigFile", "", "NetSender config file")
|
||||||
sendRetryPtr = flag.Bool("retry", false, "Specify whether a failed send should be retried.")
|
sendRetryPtr = flag.Bool("retry", false, "Specify whether a failed send should be retried.")
|
||||||
|
brightnessPtr = flag.Uint("Brightness", 50, "Set Brightness: 0-100 ")
|
||||||
brightnessPtr = flag.Uint("Brightness", -1, "Set Brightness: 0-100 ")
|
saturationPtr = flag.Int("Saturation", 0, "Set Saturation: -100:100")
|
||||||
saturationPtr = flag.Uint("Saturation", 0, "Set Saturation: -100:100")
|
exposurePtr = flag.String("Exposure", "", "Set exposure mode: "+strings.Join(revid.ExposureModes[:], ","))
|
||||||
exposurePtr = flag.String("Exposure", "", "Set Exposure Mode: Auto/Night/Spotlight")
|
autoWhiteBalancePtr = flag.String("Awb", "", "Set automatic white balance mode: "+strings.Join(revid.AwbModes[:], ","))
|
||||||
autoWhiteBalancePtr = flag.String("AutoWhiteBalance", "", "Set Automatic White Balance mode")
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var outputs flagStrings
|
var outputs flagStrings
|
||||||
|
@ -240,7 +238,6 @@ func handleFlags() revid.Config {
|
||||||
log.Log(logger.Error, pkg+"bad packetization argument")
|
log.Log(logger.Error, pkg+"bad packetization argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if *configFilePtr != "" {
|
if *configFilePtr != "" {
|
||||||
netsender.ConfigFile = *configFilePtr
|
netsender.ConfigFile = *configFilePtr
|
||||||
}
|
}
|
||||||
|
@ -261,11 +258,10 @@ func handleFlags() revid.Config {
|
||||||
cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr
|
cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr
|
||||||
cfg.RtpAddress = *rtpAddrPtr
|
cfg.RtpAddress = *rtpAddrPtr
|
||||||
cfg.SendRetry = *sendRetryPtr
|
cfg.SendRetry = *sendRetryPtr
|
||||||
|
|
||||||
cfg.Brightness = *brightnessPtr
|
cfg.Brightness = *brightnessPtr
|
||||||
cfg.Saturation = *saturationPtr
|
cfg.Saturation = *saturationPtr
|
||||||
cfg.Exposure = *exposurePtr
|
cfg.Exposure = *exposurePtr
|
||||||
cfg.AutoWhiteBalance = *autoWhiteBalancePtr
|
cfg.Awb = *autoWhiteBalancePtr
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,11 +69,38 @@ type Config struct {
|
||||||
Logger Logger
|
Logger Logger
|
||||||
SendRetry bool
|
SendRetry bool
|
||||||
BurstPeriod uint
|
BurstPeriod uint
|
||||||
|
|
||||||
Brightness uint
|
Brightness uint
|
||||||
Saturation uint
|
Saturation int
|
||||||
Exposure string
|
Exposure string
|
||||||
AutoWhiteBalance string
|
Awb string
|
||||||
|
}
|
||||||
|
|
||||||
|
var ExposureModes = [...]string{
|
||||||
|
"auto",
|
||||||
|
"night",
|
||||||
|
"nightpreview",
|
||||||
|
"backlight",
|
||||||
|
"spotlight",
|
||||||
|
"sports",
|
||||||
|
"snow",
|
||||||
|
"beach",
|
||||||
|
"verylong",
|
||||||
|
"fixedfps",
|
||||||
|
"antishake",
|
||||||
|
"fireworks",
|
||||||
|
}
|
||||||
|
|
||||||
|
var AwbModes = [...]string{
|
||||||
|
"off",
|
||||||
|
"auto",
|
||||||
|
"sun",
|
||||||
|
"cloud",
|
||||||
|
"shade",
|
||||||
|
"tungsten",
|
||||||
|
"fluorescent",
|
||||||
|
"incandescent",
|
||||||
|
"flash",
|
||||||
|
"horizon",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enums for config struct
|
// Enums for config struct
|
||||||
|
@ -121,10 +148,6 @@ const (
|
||||||
defaultVerbosity = No // FIXME(kortschak): This makes no sense whatsoever. No is currently 15.
|
defaultVerbosity = No // FIXME(kortschak): This makes no sense whatsoever. No is currently 15.
|
||||||
defaultRtpAddr = "localhost:6970"
|
defaultRtpAddr = "localhost:6970"
|
||||||
defaultBurstPeriod = 10 // Seconds
|
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
|
// Validate checks for any errors in the config fields and defaults settings
|
||||||
|
@ -259,5 +282,31 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
if c.RtpAddress == "" {
|
if c.RtpAddress == "" {
|
||||||
c.RtpAddress = defaultRtpAddr
|
c.RtpAddress = defaultRtpAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Brightness < 0 || c.Brightness > 100 {
|
||||||
|
return errors.New("bad brightness setting in config")
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Saturation < -100 || c.Saturation > 100 {
|
||||||
|
return errors.New("bad saturation setting in config")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !stringInSlice(c.Exposure, ExposureModes[:]) {
|
||||||
|
return errors.New("bad exposure setting in config")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !stringInSlice(c.Awb, AwbModes[:]) {
|
||||||
|
return errors.New("bad awb setting in config")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stringInSlice(want string, slice []string) bool {
|
||||||
|
for _, s := range slice {
|
||||||
|
if s == want {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -386,6 +386,22 @@ func (r *Revid) Update(vars map[string]string) error {
|
||||||
//look through the vars and update revid where needed
|
//look through the vars and update revid where needed
|
||||||
for key, value := range vars {
|
for key, value := range vars {
|
||||||
switch key {
|
switch key {
|
||||||
|
case "Saturation":
|
||||||
|
s, err := strconv.ParseInt(value, 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
r.config.Logger.Log(logger.Warning, pkg+"invalid saturation param", "value", value)
|
||||||
|
}
|
||||||
|
r.config.Saturation = int(s)
|
||||||
|
case "Brightness":
|
||||||
|
b, err := strconv.ParseUint(value, 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
r.config.Logger.Log(logger.Warning, pkg+"invalid brightness param", "value", value)
|
||||||
|
}
|
||||||
|
r.config.Brightness = uint(b)
|
||||||
|
case "Exposure":
|
||||||
|
r.config.Exposure = value
|
||||||
|
case "Awb":
|
||||||
|
r.config.Awb = value
|
||||||
case "Output":
|
case "Output":
|
||||||
r.config.Outputs = make([]uint8, 1)
|
r.config.Outputs = make([]uint8, 1)
|
||||||
// FIXME(kortschak): There can be only one!
|
// FIXME(kortschak): There can be only one!
|
||||||
|
@ -609,18 +625,12 @@ func (r *Revid) startRaspivid() error {
|
||||||
"--height", fmt.Sprint(r.config.Height),
|
"--height", fmt.Sprint(r.config.Height),
|
||||||
"--bitrate", fmt.Sprint(r.config.Bitrate),
|
"--bitrate", fmt.Sprint(r.config.Bitrate),
|
||||||
"--framerate", fmt.Sprint(r.config.FrameRate),
|
"--framerate", fmt.Sprint(r.config.FrameRate),
|
||||||
|
|
||||||
"--brightness", fmt.Sprint(r.config.Brightness),
|
"--brightness", fmt.Sprint(r.config.Brightness),
|
||||||
"--saturation", fmt.Sprint(r.config.Saturation),
|
"--saturation", fmt.Sprint(r.config.Saturation),
|
||||||
"--exposure", fmt.Sprint(r.config.Exposure),
|
"--exposure", fmt.Sprint(r.config.Exposure),
|
||||||
"--awb", fmt.Sprint(r.config.AutoWhiteBalance),
|
"--awb", fmt.Sprint(r.config.Awb),
|
||||||
}
|
|
||||||
if cfg.Brightness != notDefinedBrightness {
|
|
||||||
args = append(args, "--brightness")
|
|
||||||
}
|
|
||||||
if cfg.Saturation != notDefinedSaturation {
|
|
||||||
args = append(args, "--saturation")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.config.FlipHorizontal {
|
if r.config.FlipHorizontal {
|
||||||
args = append(args, "--hflip")
|
args = append(args, "--hflip")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue