Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
github.com/blackjack/webcam
This is a go library for working with webcams and other video capturing devices. It depends entirely on V4L2 framework, thus will compile and work only on Linux machine.
$ go get github.com/blackjack/webcam
import "github.com/blackjack/webcam"
// ...
cam, err := webcam.Open("/dev/video0") // Open webcam
if err != nil { panic(err.Error()) }
defer cam.Close()
// ...
// Setup webcam image format and frame size here (see examples or documentation)
// ...
err = cam.StartStreaming()
if err != nil { panic(err.Error()) }
for {
err = cam.WaitForFrame(timeout)
switch err.(type) {
case nil:
case *webcam.Timeout:
fmt.Fprint(os.Stderr, err.Error())
continue
default:
panic(err.Error())
}
frame, err := cam.ReadFrame()
if len(frame) != 0 {
// Process frame
} else if err != nil {
panic(err.Error())
}
}
For more detailed example see examples folder The number of frame buffers used may be set as:
// If already streaming, stop streaming.
if streaming_on {
cam.StopStreaming()
}
err = cam.SetBufferCount(64)
The library is still under development so API changes can happen. Currently library supports streaming using only MMAP method, which should be sufficient for most of devices available on the market. Other streaming methods can be added in future (please create issue if you need this).
Also currently image format is defined by 4-byte code received from V4L2, which is good in terms of compatibility with different versions of Linux kernel, but not very handy if you want to do some image manipulations. Plans are to aligh V4L2 image format codes with Image package from Go library.
See LICENSE file
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.