-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved Controls support (closes: #21)
- Loading branch information
Showing
3 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters