Publish video frames
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"flag"
|
||||
"github.com/cyrilix/robocar-base/cli"
|
||||
"github.com/cyrilix/robocar-display/part"
|
||||
"github.com/cyrilix/robocar-display/video"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
@ -14,6 +15,8 @@ const (
|
||||
|
||||
func main() {
|
||||
var mqttBroker, username, password, clientId string
|
||||
var framePath string
|
||||
var fps int
|
||||
var frameTopic, objectsTopic, roadTopic string
|
||||
var withObjects, withRoad bool
|
||||
|
||||
@ -23,6 +26,8 @@ func main() {
|
||||
cli.InitMqttFlags(DefaultClientId, &mqttBroker, &username, &password, &clientId, &mqttQos, &mqttRetain)
|
||||
|
||||
flag.StringVar(&frameTopic, "mqtt-topic-frame", os.Getenv("MQTT_TOPIC_FRAME"), "Mqtt topic that contains frame to display, use MQTT_TOPIC_FRAME if args not set")
|
||||
flag.StringVar(&framePath, "frame-path", "", "Directory path where to read jpeg frame to inject in frame topic")
|
||||
flag.IntVar(&fps, "frame-per-second", 25, "Video frame per second of frame to publish")
|
||||
|
||||
flag.StringVar(&objectsTopic, "mqtt-topic-objects", os.Getenv("MQTT_TOPIC_OBJECTS"), "Mqtt topic that contains detected objects, use MQTT_TOPIC_OBJECTS if args not set")
|
||||
flag.BoolVar(&withObjects, "with-objects", false, "Display detected objects")
|
||||
@ -42,6 +47,17 @@ func main() {
|
||||
}
|
||||
defer client.Disconnect(50)
|
||||
|
||||
if framePath != "" {
|
||||
camera, err := video.NewCameraFake(client, frameTopic, framePath, fps)
|
||||
if err != nil {
|
||||
log.Fatalf("unable to load fake camera: %v", err)
|
||||
}
|
||||
if err = camera.Start(); err != nil {
|
||||
log.Fatalf("unable to start fake camera: %v", err)
|
||||
}
|
||||
defer camera.Stop()
|
||||
}
|
||||
|
||||
p := part.NewPart(client, frameTopic,
|
||||
objectsTopic, roadTopic,
|
||||
withObjects, withRoad )
|
||||
|
Reference in New Issue
Block a user