github.com/blackjack/webcam@v0.0.0-20230509180125-87693b3f29dc/examples/getcontrols/getcontrols.go (about) 1 // Example program that reads the list of available controls and prints them. 2 package main 3 4 import ( 5 "flag" 6 "fmt" 7 8 "github.com/blackjack/webcam" 9 ) 10 11 var device = flag.String("input", "/dev/video0", "Input video device") 12 13 func main() { 14 flag.Parse() 15 cam, err := webcam.Open(*device) 16 if err != nil { 17 panic(err.Error()) 18 } 19 defer cam.Close() 20 21 fmap := cam.GetSupportedFormats() 22 fmt.Println("Available Formats: ") 23 for p, s := range fmap { 24 var pix []byte 25 for i := 0; i < 4; i++ { 26 pix = append(pix, byte(p>>uint(i*8))) 27 } 28 fmt.Printf("ID:%08x ('%s') %s\n ", p, pix, s) 29 for _, fs := range cam.GetSupportedFrameSizes(p) { 30 fmt.Printf(" %s", fs.GetString()) 31 } 32 fmt.Printf("\n") 33 } 34 35 cmap := cam.GetControls() 36 fmt.Println("Available controls: ") 37 for id, c := range cmap { 38 fmt.Printf("ID:%08x %-32s Type: %1d Min: %6d Max: %6d Step: %6d\n", id, c.Name, c.Type, c.Min, c.Max, c.Step) 39 } 40 }