From 9425c6c747fe32e62d530179d1139c178f906991 Mon Sep 17 00:00:00 2001 From: Martyn Date: Sun, 12 Dec 2021 22:43:17 +0100 Subject: [PATCH] rename webcam to gocvwebcam so I can try with mediadevices --- examples/gocvwebcam/main.go | 51 +++++++++++++++++++ examples/webcam/main.go | 51 ------------------- .../webcam.go => gocvwebcam/gocvwebcam.go} | 0 3 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 examples/gocvwebcam/main.go delete mode 100644 examples/webcam/main.go rename pkg/{webcam/webcam.go => gocvwebcam/gocvwebcam.go} (100%) diff --git a/examples/gocvwebcam/main.go b/examples/gocvwebcam/main.go new file mode 100644 index 0000000..48afeda --- /dev/null +++ b/examples/gocvwebcam/main.go @@ -0,0 +1,51 @@ +package main + +import ( + "strconv" + + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/app" + "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/widget" + "git.martyn.berlin/martyn/fyne-widgets/pkg/gocvwebcam" + "git.martyn.berlin/martyn/fyne-widgets/pkg/layouts" +) + +var gocvWebcamID int +var gocvWebcamLabel *widget.Label +var gocvWebcamWidget *gocvwebcam.GocvWebcam + +func switchGocvWebcam(id int) { + gocvWebcamLabel.Text = "GocvWebcam: " + strconv.Itoa(id) + gocvWebcamLabel.Refresh() + gocvWebcamWidget.GocvWebcamID = int64(id) + gocvWebcamWidget.Refresh() +} + +func incWebCamID() { + gocvWebcamID = gocvWebcamID + 1 + switchGocvWebcam(gocvWebcamID) +} + +func decWebCamID() { + gocvWebcamID = gocvWebcamID - 1 + switchGocvWebcam(gocvWebcamID) +} + +func main() { + a := app.New() + w := a.NewWindow("GocvWebcam") + + gocvWebcamWidget = gocvwebcam.NewGocvWebcam() + layout := layouts.NewFloatingControlsLayout() + layout.FloatingControlsLocation = layouts.FloatingControlsCenter + gocvWebcamID = 0 + gocvWebcamWidget.UpdateFPS = 50 + + gocvWebcamLabel = widget.NewLabel("Webcam: 0") + buttons := container.NewHBox(gocvWebcamLabel, widget.NewButton("-", decWebCamID), widget.NewButton("+", incWebCamID)) + + w.SetContent(container.New(&layout, gocvWebcamWidget, buttons)) + w.Resize(fyne.NewSize(640, 480)) + w.ShowAndRun() +} diff --git a/examples/webcam/main.go b/examples/webcam/main.go deleted file mode 100644 index d298989..0000000 --- a/examples/webcam/main.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "strconv" - - "fyne.io/fyne/v2" - "fyne.io/fyne/v2/app" - "fyne.io/fyne/v2/container" - "fyne.io/fyne/v2/widget" - "git.martyn.berlin/martyn/fyne-widgets/pkg/layouts" - "git.martyn.berlin/martyn/fyne-widgets/pkg/webcam" -) - -var webcamID int -var webcamLabel *widget.Label -var webcamWidget *webcam.Webcam - -func switchWebcam(id int) { - webcamLabel.Text = "Webcam: " + strconv.Itoa(id) - webcamLabel.Refresh() - webcamWidget.WebcamID = int64(id) - webcamWidget.Refresh() -} - -func incWebCamID() { - webcamID = webcamID + 1 - switchWebcam(webcamID) -} - -func decWebCamID() { - webcamID = webcamID - 1 - switchWebcam(webcamID) -} - -func main() { - a := app.New() - w := a.NewWindow("Webcam") - - webcamWidget = webcam.NewWebcam() - layout := layouts.NewFloatingControlsLayout() - layout.FloatingControlsLocation = layouts.FloatingControlsCenter - webcamID = 0 - webcamWidget.UpdateFPS = 50 - - webcamLabel = widget.NewLabel("Webcam: 0") - buttons := container.NewHBox(webcamLabel, widget.NewButton("-", decWebCamID), widget.NewButton("+", incWebCamID)) - - w.SetContent(container.New(&layout, webcamWidget, buttons)) - w.Resize(fyne.NewSize(640, 480)) - w.ShowAndRun() -} diff --git a/pkg/webcam/webcam.go b/pkg/gocvwebcam/gocvwebcam.go similarity index 100% rename from pkg/webcam/webcam.go rename to pkg/gocvwebcam/gocvwebcam.go