rename webcam to gocvwebcam so I can try with mediadevices

This commit is contained in:
Martyn 2021-12-12 22:43:17 +01:00
parent f08e523f86
commit 9425c6c747
3 changed files with 51 additions and 51 deletions

View File

@ -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()
}

View File

@ -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()
}