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