feat(object): use bbox values as percent
This commit is contained in:
parent
653ee95311
commit
3d12e00bfc
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)
|
||||
}
|
||||
}
|
||||
|
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