Compare commits
2 Commits
988abb715f
...
3d12e00bfc
Author | SHA1 | Date | |
---|---|---|---|
3d12e00bfc | |||
653ee95311 |
@ -65,3 +65,10 @@ Usage of record:
|
||||
-record-json-path string
|
||||
Path where to write json files, use RECORD_JSON_PATH if args not set
|
||||
```
|
||||
|
||||
## Useful
|
||||
|
||||
Debug record:
|
||||
|
||||
go run ./cmd/rc-tools display record -mqtt-broker tcp://diabolo.local:1883 -mqtt-username satanas -mqtt-password satanas -mqtt-client-id display-record -mqtt-topic-records car/satanas/part/records
|
||||
|
||||
|
@ -55,7 +55,6 @@ func main() {
|
||||
cli.SetDefaultValueFromEnv(&ociImage, "TRAIN_OCI_IMAGE", "")
|
||||
cli.SetDefaultValueFromEnv(&bucket, "TRAIN_BUCKET", "")
|
||||
|
||||
|
||||
flag.BoolVar(&debug, "debug", false, "Display debug logs")
|
||||
|
||||
displayFlags := flag.NewFlagSet("display", flag.ExitOnError)
|
||||
@ -87,13 +86,11 @@ func main() {
|
||||
recordFlags.StringVar(&recordTopic, "mqtt-topic-records", os.Getenv("MQTT_TOPIC_RECORDS"), "Mqtt topic that contains record data for training, use MQTT_TOPIC_RECORDS if args not set")
|
||||
recordFlags.StringVar(&recordsPath, "record-path", os.Getenv("RECORD_PATH"), "Path where to write records files, use RECORD_PATH if args not set")
|
||||
|
||||
|
||||
var basedir, destdir string
|
||||
impdkFlags := flag.NewFlagSet("import-donkey-records", flag.ExitOnError)
|
||||
impdkFlags.StringVar(&basedir, "from", "", "source directory")
|
||||
impdkFlags.StringVar(&destdir, "to", "", "destination directory")
|
||||
|
||||
|
||||
trainingFlags := flag.NewFlagSet("training", flag.ExitOnError)
|
||||
trainingFlags.Usage = func() {
|
||||
fmt.Printf("Usage of %s %s:\n", os.Args[0], trainingFlags.Name())
|
||||
@ -133,7 +130,6 @@ func main() {
|
||||
trainArchiveFlags.IntVar(&horizon, "horizon", 0, "Upper zone image to crop (in pixels)")
|
||||
trainArchiveFlags.BoolVar(&withFlipImage, "with-flip-image", withFlipImage, "Flip horiontal image and reverse steering to increase data into training archive")
|
||||
|
||||
|
||||
modelsFlags := flag.NewFlagSet("models", flag.ExitOnError)
|
||||
modelsFlags.Usage = func() {
|
||||
fmt.Printf("Usage of %s %s:\n", os.Args[0], modelsFlags.Name())
|
||||
@ -249,7 +245,6 @@ func main() {
|
||||
trainingFlags.PrintDefaults()
|
||||
os.Exit(0)
|
||||
|
||||
|
||||
}
|
||||
case modelsFlags.Name():
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -8,7 +8,7 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.11
|
||||
github.com/aws/aws-sdk-go-v2/service/sagemaker v1.32.1
|
||||
github.com/cyrilix/robocar-base v0.1.7
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.5
|
||||
github.com/cyrilix/robocar-protobuf/go v1.1.0
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/eclipse/paho.mqtt.golang v1.4.1
|
||||
github.com/golang/protobuf v1.5.2
|
||||
|
4
go.sum
4
go.sum
@ -38,8 +38,8 @@ github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLj
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/cyrilix/robocar-base v0.1.7 h1:EVzZ0KjigSFpke5f3A/PybEH3WFUEIrYSc3z/dhOZ48=
|
||||
github.com/cyrilix/robocar-base v0.1.7/go.mod h1:4E11HQSNy2NT8e7MW188y6ST9C0RzarKyn7sK/3V/Lk=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.5 h1:PX1At+pf6G7gJwT4LzJLQu3/LPFTTNNlZmZSYtnSELY=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.5/go.mod h1:Y3AE28K5V7EZxMXp/6A8RhkRz15VOfFy4CjST35FbtQ=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.1.0 h1:txIjGnnCF3UzedpsWu+sL7nMA+pNjSnX6HZlAmuReH4=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.1.0/go.mod h1:Y3AE28K5V7EZxMXp/6A8RhkRz15VOfFy4CjST35FbtQ=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
17
part/part.go
17
part/part.go
@ -11,6 +11,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewPart(client mqtt.Client, frameTopic, objectsTopic, roadTopic string, withObjects, withRoad bool) *FramePart {
|
||||
@ -52,9 +53,11 @@ func (p *FramePart) Start() error {
|
||||
var img = gocv.NewMat()
|
||||
var objectsMsg events.ObjectsMessage
|
||||
var roadMsg events.RoadMessage
|
||||
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
img = gocv.NewMatWithSize(120, 120, gocv.MatTypeCV8S)
|
||||
case newImg := <-p.imgChan:
|
||||
img.Close()
|
||||
img = newImg
|
||||
@ -67,6 +70,7 @@ func (p *FramePart) Start() error {
|
||||
return nil
|
||||
}
|
||||
p.drawFrame(&img, &objectsMsg, &roadMsg)
|
||||
ticker.Reset(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +109,7 @@ func (p *FramePart) onObjects(_ mqtt.Client, message mqtt.Message) {
|
||||
return
|
||||
}
|
||||
|
||||
zap.S().Infow("new objects", zap.String("topic", message.Topic()), zap.String("object", msg.Objects[0].String()))
|
||||
p.objectsChan <- msg
|
||||
}
|
||||
|
||||
@ -156,11 +161,17 @@ func (p *FramePart) drawFrame(img *gocv.Mat, objects *events.ObjectsMessage, roa
|
||||
}
|
||||
|
||||
func (p *FramePart) drawObjects(img *gocv.Mat, objects *events.ObjectsMessage) {
|
||||
zap.S().Debugf("draw object %v", objects)
|
||||
for _, obj := range objects.GetObjects() {
|
||||
gocv.Rectangle(
|
||||
img,
|
||||
image.Rect(int(obj.GetLeft()), int(obj.GetTop()), int(obj.GetRight()), int(obj.GetBottom())),
|
||||
color.RGBA{0, 255, 0, 0},
|
||||
image.Rect(
|
||||
int(obj.GetLeft()*float32(img.Cols())),
|
||||
int(obj.GetTop()*float32(img.Rows())),
|
||||
int(obj.GetRight()*float32(img.Cols())),
|
||||
int(obj.GetBottom()*float32(img.Rows())),
|
||||
),
|
||||
color.RGBA{R: 0, G: 255, B: 0, A: 0},
|
||||
2)
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,6 @@ func (r *Record) drawRecord(rec *events.RecordMessage, objects *events.ObjectsMe
|
||||
r.window.WaitKey(1)
|
||||
}
|
||||
|
||||
|
||||
func (r *Record) drawSteering(img *gocv.Mat, steering float32) {
|
||||
gocv.PutText(
|
||||
img,
|
||||
|
@ -3,4 +3,3 @@ package train
|
||||
const (
|
||||
prefixInput = "input/data/train/"
|
||||
)
|
||||
|
||||
|
@ -6,8 +6,8 @@ set +x
|
||||
RECORDS_PATH=~/robocar/record-sim4-2
|
||||
#TRAINING_OPTS="--horizon=20"
|
||||
TRAINING_OPTS=""
|
||||
#MODEL_TYPE="categorical"
|
||||
MODEL_TYPE="linear"
|
||||
MODEL_TYPE="categorical"
|
||||
#MODEL_TYPE="linear"
|
||||
IMG_WIDTH=160
|
||||
IMG_HEIGHT=120
|
||||
HORIZON=20
|
||||
|
30
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
30
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.12.4
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.21.4
|
||||
// source: events/events.proto
|
||||
|
||||
package events
|
||||
@ -468,17 +468,17 @@ func (x *ObjectsMessage) GetFrameRef() *FrameRef {
|
||||
return nil
|
||||
}
|
||||
|
||||
// BoundingBox that contains an object
|
||||
// BoundingBox that contains an object, coordinates as percent
|
||||
type Object struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type TypeObject `protobuf:"varint,1,opt,name=type,proto3,enum=robocar.events.TypeObject" json:"type,omitempty"`
|
||||
Left int32 `protobuf:"varint,2,opt,name=left,proto3" json:"left,omitempty"`
|
||||
Top int32 `protobuf:"varint,3,opt,name=top,proto3" json:"top,omitempty"`
|
||||
Right int32 `protobuf:"varint,4,opt,name=right,proto3" json:"right,omitempty"`
|
||||
Bottom int32 `protobuf:"varint,5,opt,name=bottom,proto3" json:"bottom,omitempty"`
|
||||
Left float32 `protobuf:"fixed32,2,opt,name=left,proto3" json:"left,omitempty"`
|
||||
Top float32 `protobuf:"fixed32,3,opt,name=top,proto3" json:"top,omitempty"`
|
||||
Right float32 `protobuf:"fixed32,4,opt,name=right,proto3" json:"right,omitempty"`
|
||||
Bottom float32 `protobuf:"fixed32,5,opt,name=bottom,proto3" json:"bottom,omitempty"`
|
||||
Confidence float32 `protobuf:"fixed32,6,opt,name=confidence,proto3" json:"confidence,omitempty"`
|
||||
}
|
||||
|
||||
@ -521,28 +521,28 @@ func (x *Object) GetType() TypeObject {
|
||||
return TypeObject_ANY
|
||||
}
|
||||
|
||||
func (x *Object) GetLeft() int32 {
|
||||
func (x *Object) GetLeft() float32 {
|
||||
if x != nil {
|
||||
return x.Left
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Object) GetTop() int32 {
|
||||
func (x *Object) GetTop() float32 {
|
||||
if x != nil {
|
||||
return x.Top
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Object) GetRight() int32 {
|
||||
func (x *Object) GetRight() float32 {
|
||||
if x != nil {
|
||||
return x.Right
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Object) GetBottom() int32 {
|
||||
func (x *Object) GetBottom() float32 {
|
||||
if x != nil {
|
||||
return x.Bottom
|
||||
}
|
||||
@ -918,10 +918,10 @@ var file_events_events_proto_rawDesc = []byte{
|
||||
0x0e, 0x32, 0x1a, 0x2e, 0x72, 0x6f, 0x62, 0x6f, 0x63, 0x61, 0x72, 0x2e, 0x65, 0x76, 0x65, 0x6e,
|
||||
0x74, 0x73, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x65, 0x66, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x04, 0x6c, 0x65, 0x66, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6f, 0x70, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x6f, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x69, 0x67, 0x68, 0x74, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x02, 0x52, 0x04, 0x6c, 0x65, 0x66, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x6f, 0x70, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x02, 0x52, 0x03, 0x74, 0x6f, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x69, 0x67,
|
||||
0x68, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x72, 0x69, 0x67, 0x68, 0x74, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52,
|
||||
0x06, 0x62, 0x6f, 0x74, 0x74, 0x6f, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x63, 0x6f, 0x6e,
|
||||
0x66, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x2f, 0x0a, 0x13, 0x53, 0x77, 0x69, 0x74, 0x63,
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -111,7 +111,7 @@ github.com/aws/smithy-go/waiter
|
||||
## explicit; go 1.18
|
||||
github.com/cyrilix/robocar-base/cli
|
||||
github.com/cyrilix/robocar-base/service
|
||||
# github.com/cyrilix/robocar-protobuf/go v1.0.5
|
||||
# github.com/cyrilix/robocar-protobuf/go v1.1.0
|
||||
## explicit; go 1.18
|
||||
github.com/cyrilix/robocar-protobuf/go/events
|
||||
# github.com/disintegration/imaging v1.6.2
|
||||
|
Loading…
Reference in New Issue
Block a user