52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
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()
|
|
}
|