webcam

Golang webcam library for Linux

  • 所有者: blackjack/webcam
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

go-webcam

Build Status GoDoc

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.

Installation

$ go get github.com/blackjack/webcam

Usage

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)

Roadmap

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.

License

See LICENSE file

主要指标

概览
名称与所有者blackjack/webcam
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2013-09-30 10:26:41
推送于2024-04-30 21:17:20
最后一次提交2024-04-30 17:16:33
发布数7
最新版本名称v0.6.1 (发布于 )
第一版名称v0.2 (发布于 2015-10-20 00:54:31)
用户参与
星数423
关注者数17
派生数91
提交数62
已启用问题?
问题数35
打开的问题数13
拉请求数19
打开的拉请求数14
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?