Compare commits
3 Commits
v0.2.0
...
05a0af6b74
| Author | SHA1 | Date | |
|---|---|---|---|
| 05a0af6b74 | |||
| 4c3954ec76 | |||
| 67d1a1d8e5 |
@@ -21,8 +21,6 @@ func main() {
|
|||||||
var modelPath string
|
var modelPath string
|
||||||
var edgeVerbosity int
|
var edgeVerbosity int
|
||||||
var imgWidth, imgHeight, horizon int
|
var imgWidth, imgHeight, horizon int
|
||||||
var debug bool
|
|
||||||
|
|
||||||
|
|
||||||
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
|
mqttQos := cli.InitIntFlag("MQTT_QOS", 0)
|
||||||
_, mqttRetain := os.LookupEnv("MQTT_RETAIN")
|
_, 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(&imgWidth, "img-width", 0, "image width expected by model (mandatory)")
|
||||||
flag.IntVar(&imgHeight, "img-height", 0, "image height 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.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()
|
flag.Parse()
|
||||||
|
|
||||||
if len(os.Args) <= 1 {
|
if len(os.Args) <= 1 {
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
config := zap.NewDevelopmentConfig()
|
config := zap.NewDevelopmentConfig()
|
||||||
if debug {
|
config.Level = zap.NewAtomicLevelAt(*logLevel)
|
||||||
config.Level = zap.NewAtomicLevelAt(zap.DebugLevel)
|
|
||||||
} else {
|
|
||||||
config.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
|
|
||||||
}
|
|
||||||
lgr, err := config.Build()
|
lgr, err := config.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("unable to init logger: %v", err)
|
log.Fatalf("unable to init logger: %v", err)
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ func (p *Part) onFrame(_ mqtt.Client, message mqtt.Message) {
|
|||||||
frameAge := now - msg.Id.CreatedAt.AsTime().UnixMilli()
|
frameAge := now - msg.Id.CreatedAt.AsTime().UnixMilli()
|
||||||
go metrics.FrameAge.Record(context.Background(), frameAge)
|
go metrics.FrameAge.Record(context.Background(), frameAge)
|
||||||
|
|
||||||
|
|
||||||
img, _, err := image.Decode(bytes.NewReader(msg.GetFrame()))
|
img, _, err := image.Decode(bytes.NewReader(msg.GetFrame()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.L().Error("unable to decode frame, skip frame", zap.Error(err))
|
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 y := 0; y < dy; y++ {
|
||||||
for x := 0; x < dx; x++ {
|
for x := 0; x < dx; x++ {
|
||||||
r, g, b, _ := img.At(x, y).RGBA()
|
r, g, b, _ := img.At(x, y).RGBA()
|
||||||
bb[(y*dx+x)*3+0] = byte(float64(r) / 255.0)
|
bb[(y*dx+x)*3+0] = byte(float64(r) / 257.0)
|
||||||
bb[(y*dx+x)*3+1] = byte(float64(g) / 255.0)
|
bb[(y*dx+x)*3+1] = byte(float64(g) / 257.0)
|
||||||
bb[(y*dx+x)*3+2] = byte(float64(b) / 255.0)
|
bb[(y*dx+x)*3+2] = byte(float64(b) / 257.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = input.CopyFromBuffer(bb)
|
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))
|
zap.L().Warn(fmt.Sprintf("none steering with score > %0.2f found", minScore))
|
||||||
return 0., 0., nil
|
return 0., 0., nil
|
||||||
}
|
}
|
||||||
|
zap.S().Debugf("raw result: %v", results)
|
||||||
|
|
||||||
sort.Slice(results, func(i, j int) bool {
|
sort.Slice(results, func(i, j int) bool {
|
||||||
return results[i].score > results[j].score
|
return results[i].score > results[j].score
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user