added controls
This commit is contained in:
parent
9ef7d28c46
commit
45063b7d97
3 changed files with 167 additions and 3 deletions
|
|
@ -90,6 +90,14 @@ func check(c color.Color) bool {
|
|||
//}
|
||||
return false
|
||||
}
|
||||
func check2(c color.Color) bool {
|
||||
//r, g, b, _ := c.RGBA()
|
||||
r, g, b, _ := c.RGBA()
|
||||
if r < 10000 && g > 8000 && b > 8000 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func set(img *image.RGBA, x, y int) {
|
||||
img.Set(x, y, color.White)
|
||||
|
|
@ -102,6 +110,10 @@ func set(img *image.RGBA, x, y int) {
|
|||
//}
|
||||
}
|
||||
|
||||
func set2(img *image.RGBA, x, y int) {
|
||||
img.Set(x, y, color.RGBA{90, 90, 90, 0})
|
||||
}
|
||||
|
||||
func mark(img image.Image) {
|
||||
o := jpeg.Options{100}
|
||||
r := img.Bounds()
|
||||
|
|
@ -119,6 +131,9 @@ func mark(img image.Image) {
|
|||
if check(img.At(x, y)) {
|
||||
set(n, x, y)
|
||||
}
|
||||
if check2(img.At(x, y)) {
|
||||
set2(n, x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
//"encoding/hex"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"os"
|
||||
//"image/jpeg"
|
||||
//"net/http"
|
||||
"git.giftfish.de/ston1th/webcam"
|
||||
"time"
|
||||
|
|
@ -22,6 +22,20 @@ func main() {
|
|||
}
|
||||
defer cam.Close()
|
||||
|
||||
ctrl := cam.GetControls()
|
||||
for k, value := range ctrl {
|
||||
fmt.Fprintln(os.Stderr, k)
|
||||
for _, v := range value {
|
||||
fmt.Fprintln(os.Stderr, " "+v)
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html#control-ids
|
||||
err = cam.SetControl(webcam.V4L2_CID_CONTRAST, 0)
|
||||
if err != nil {
|
||||
panic(err.Error())
|
||||
}
|
||||
|
||||
formats := cam.GetPixelFormats()
|
||||
println("Available formats: ")
|
||||
for k, value := range formats {
|
||||
|
|
@ -65,10 +79,13 @@ func main() {
|
|||
default:
|
||||
panic(err.Error())
|
||||
}
|
||||
frm, err := cam.ReadFrame()
|
||||
//frm, err := cam.ReadFrame()
|
||||
o := jpeg.Options{100}
|
||||
img, err := cam.ReadJPEG()
|
||||
jpeg.Encode(os.Stdout, img, &o)
|
||||
if err == nil {
|
||||
//print(".")
|
||||
os.Stdout.Write(frm)
|
||||
//os.Stdout.Write(frm)
|
||||
os.Stdout.Sync()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue