https://github.com/dhowden/raspicam
Go package for controlling Raspberry Pi Camera Module
https://github.com/dhowden/raspicam
go raspberry-pi raspicam
Last synced: 6 months ago
JSON representation
Go package for controlling Raspberry Pi Camera Module
- Host: GitHub
- URL: https://github.com/dhowden/raspicam
- Owner: dhowden
- License: bsd-2-clause
- Created: 2013-08-28T06:04:26.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-03-23T05:20:02.000Z (almost 7 years ago)
- Last Synced: 2025-04-13T16:45:39.803Z (9 months ago)
- Topics: go, raspberry-pi, raspicam
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 67
- Watchers: 3
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raspicam Go API
[](https://travis-ci.org/dhowden/raspicam)
[](https://godoc.org/github.com/dhowden/raspicam)
Provides a simple Go interface to the [Raspberry Pi Camera board](http://www.raspberrypi.org/archives/tag/camera-board).
For the moment we call the existing command line tools, though eventually hope to hook directly into the C API.
We aim to create an idiomatic Go API whilst mirroring the functionality of the existing command line tools to allow for the best interoperability.
## Status
Implemented:
- Interface to raspistill
- Interface to raspiyuv
- Interface to raspivid
Todo:
- More tests!
## Installation
go get github.com/dhowden/raspicam
## Getting Started
### Write to a file
package main
import (
"fmt"
"log"
"os"
"github.com/dhowden/raspicam"
)
func main() {
f, err := os.Create(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "create file: %v", err)
return
}
defer f.Close()
s := raspicam.NewStill()
errCh := make(chan error)
go func() {
for x := range errCh {
fmt.Fprintf(os.Stderr, "%v\n", x)
}
}()
log.Println("Capturing image...")
raspicam.Capture(s, f, errCh)
}
### Simple Raspicam TCP Server
package main
import (
"log"
"fmt"
"net"
"os"
"github.com/dhowden/raspicam"
)
func main() {
listener, err := net.Listen("tcp", "0.0.0.0:6666")
if err != nil {
fmt.Fprintf(os.Stderr, "listen: %v", err)
return
}
log.Println("Listening on 0.0.0.0:6666")
for {
conn, err := listener.Accept()
if err != nil {
fmt.Fprintf(os.Stderr, "accept: %v", err)
return
}
log.Printf("Accepted connection from: %v\n", conn.RemoteAddr())
go func() {
s := raspicam.NewStill()
errCh := make(chan error)
go func() {
for x := range errCh {
fmt.Fprintf(os.Stderr, "%v\n", x)
}
}()
log.Println("Capturing image...")
raspicam.Capture(s, conn, errCh)
log.Println("Done")
conn.Close()
}()
}
}