Raspicam
Go package for controlling Raspberry Pi Camera Module
Install / Use
/learn @dhowden/RaspicamREADME
raspicam Go API
Provides a simple Go interface to the Raspberry Pi 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()
}()
}
}
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
