2020-11-02 02:14:40 +00:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/juju/gnuflag"
|
|
|
|
|
|
2020-11-02 08:29:11 +00:00
|
|
|
|
"range-gen/output"
|
|
|
|
|
|
2020-11-02 02:14:40 +00:00
|
|
|
|
"errors"
|
2020-11-02 08:29:11 +00:00
|
|
|
|
"os"
|
2020-11-02 02:14:40 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
ArgInput string
|
|
|
|
|
ArgInputIsSet bool = false
|
|
|
|
|
ArgOutput string
|
|
|
|
|
ArgOutputIsSet bool = false
|
|
|
|
|
ArgThreshold string
|
|
|
|
|
ArgThresholdIsSet bool = false
|
|
|
|
|
|
|
|
|
|
ArgJobs int = 0
|
|
|
|
|
ArgDefaultNoiseLevel int = 0
|
2020-11-02 08:29:11 +00:00
|
|
|
|
|
|
|
|
|
ArgVersion bool = false
|
|
|
|
|
ArgHelp bool = false
|
2020-11-02 02:14:40 +00:00
|
|
|
|
)
|
|
|
|
|
|
2020-11-02 08:29:11 +00:00
|
|
|
|
func printHelp() {
|
|
|
|
|
output.Println("Сreates a list of scene ranges based on a set of frames from the video")
|
|
|
|
|
output.Println("")
|
|
|
|
|
output.Println("Usage: range-gen [option]... <input_dir> <output_file> <threshold>")
|
|
|
|
|
output.Println("input_dir Directory with png images")
|
|
|
|
|
output.Println("output_file Range list file")
|
|
|
|
|
output.Println("threshold Image similarity threshold (0-1024)")
|
|
|
|
|
output.Println("")
|
|
|
|
|
output.Println("Options:")
|
|
|
|
|
output.Println(" -j, --jobs N Allow N jobs at once")
|
|
|
|
|
output.Println(" -n, --noise Default noise level for each range")
|
|
|
|
|
output.Println(" -h, --help Show this page")
|
|
|
|
|
output.Println(" -v, --version Show version")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func printVersion() {
|
|
|
|
|
output.Println("multini ", Version)
|
2020-11-02 02:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
gnuflag.IntVar(&ArgJobs, "jobs", 0, "")
|
|
|
|
|
gnuflag.IntVar(&ArgJobs, "j", 0, "")
|
|
|
|
|
gnuflag.IntVar(&ArgDefaultNoiseLevel, "noise", -1, "")
|
|
|
|
|
gnuflag.IntVar(&ArgDefaultNoiseLevel, "n", -1, "")
|
2020-11-02 08:29:11 +00:00
|
|
|
|
gnuflag.BoolVar(&ArgVersion, "version", false, "")
|
|
|
|
|
gnuflag.BoolVar(&ArgVersion, "v", false, "")
|
|
|
|
|
gnuflag.BoolVar(&ArgHelp, "help", false, "")
|
|
|
|
|
gnuflag.BoolVar(&ArgHelp, "h", false, "")
|
2020-11-02 02:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func parseArgs() error {
|
|
|
|
|
gnuflag.Parse(false)
|
|
|
|
|
|
2020-11-02 08:29:11 +00:00
|
|
|
|
switch {
|
|
|
|
|
case ArgHelp:
|
|
|
|
|
printHelp()
|
|
|
|
|
os.Exit(EXIT_SUCCESS)
|
|
|
|
|
case ArgVersion:
|
|
|
|
|
printVersion()
|
|
|
|
|
os.Exit(EXIT_SUCCESS)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 02:14:40 +00:00
|
|
|
|
for i := 0; i < 3 && i < gnuflag.NArg(); i++ {
|
|
|
|
|
switch i {
|
|
|
|
|
case 0:
|
|
|
|
|
ArgInput = gnuflag.Arg(0)
|
|
|
|
|
ArgInputIsSet = true
|
|
|
|
|
case 1:
|
|
|
|
|
ArgOutput = gnuflag.Arg(1)
|
|
|
|
|
ArgOutputIsSet = true
|
|
|
|
|
case 2:
|
|
|
|
|
ArgThreshold = gnuflag.Arg(2)
|
|
|
|
|
ArgThresholdIsSet = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !ArgInputIsSet {
|
|
|
|
|
return errors.New("Input directory not specified")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !ArgOutputIsSet {
|
|
|
|
|
return errors.New("Output file not specified")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !ArgThresholdIsSet {
|
|
|
|
|
return errors.New("Threshold not specified")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|