3 Commits

2 changed files with 8 additions and 13 deletions

View File

@@ -21,8 +21,6 @@ func main() {
var modelPath string
var edgeVerbosity int
var imgWidth, imgHeight, horizon int
var debug bool
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
_, mqttRetain := os.LookupEnv("MQTT_RETAIN")
@@ -36,20 +34,16 @@ func main() {
flag.IntVar(&imgWidth, "img-width", 0, "image width expected by model (mandatory)")
flag.IntVar(&imgHeight, "img-height", 0, "image height expected by model (mandatory)")
flag.IntVar(&horizon, "horizon", 0, "upper zone to crop from image. Models expect size 'imgHeight - horizon'")
flag.BoolVar(&debug, "debug", false, "Display debug logs")
logLevel := zap.LevelFlag("log", zap.InfoLevel, "log level")
flag.Parse()
if len(os.Args) <= 1 {
flag.PrintDefaults()
os.Exit(1)
}
config := zap.NewDevelopmentConfig()
if debug {
config.Level = zap.NewAtomicLevelAt(zap.DebugLevel)
} else {
config.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
}
config.Level = zap.NewAtomicLevelAt(*logLevel)
lgr, err := config.Build()
if err != nil {
log.Fatalf("unable to init logger: %v", err)

View File

@@ -137,7 +137,6 @@ func (p *Part) onFrame(_ mqtt.Client, message mqtt.Message) {
frameAge := now - msg.Id.CreatedAt.AsTime().UnixMilli()
go metrics.FrameAge.Record(context.Background(), frameAge)
img, _, err := image.Decode(bytes.NewReader(msg.GetFrame()))
if err != nil {
zap.L().Error("unable to decode frame, skip frame", zap.Error(err))
@@ -197,9 +196,9 @@ func (p *Part) Value(img image.Image) (float32, float32, error) {
for y := 0; y < dy; y++ {
for x := 0; x < dx; x++ {
r, g, b, _ := img.At(x, y).RGBA()
bb[(y*dx+x)*3+0] = byte(float64(r) / 255.0)
bb[(y*dx+x)*3+1] = byte(float64(g) / 255.0)
bb[(y*dx+x)*3+2] = byte(float64(b) / 255.0)
bb[(y*dx+x)*3+0] = byte(float64(r) / 257.0)
bb[(y*dx+x)*3+1] = byte(float64(g) / 257.0)
bb[(y*dx+x)*3+2] = byte(float64(b) / 257.0)
}
}
status = input.CopyFromBuffer(bb)
@@ -238,6 +237,8 @@ func (p *Part) Value(img image.Image) (float32, float32, error) {
zap.L().Warn(fmt.Sprintf("none steering with score > %0.2f found", minScore))
return 0., 0., nil
}
zap.S().Debugf("raw result: %v", results)
sort.Slice(results, func(i, j int) bool {
return results[i].score > results[j].score
})