Documentation
¶
Overview ¶
Package gogige is a pure-Go GigE Vision client.
Happy path (Phase 4):
cam, err := gogige.OpenDevice(ctx, "192.168.1.10")
defer cam.Close()
_ = cam.SetInteger("Width", 1920)
_ = cam.SetEnum("PixelFormat", "Mono8")
stream, err := cam.StartStream(ctx)
defer stream.Stop()
for frame := range stream.Frames() {
// use frame.Data
frame.Release()
}
Sample/JPEG path (Huaray BSCF): Device.StartGrabber → Grabber.Grab.
Protocol packages:
- gvcp — GigE Vision Control Protocol
- genapi — GenICam GenApi XML / node map
- gvsp — GigE Vision Streaming Protocol
Device discovery (broadcast) lives on this root package: Discover. Preview sinks are app-owned (see examples/websocket-stream).
Index ¶
- Constants
- Variables
- func ApplyControlPair(c *Camera, pair string) error
- func GrabJPEG(ctx context.Context, ip string, opts ...Option) ([]byte, error)
- type Camera
- func (c *Camera) BooleanFeature(name string) (bool, error)
- func (c *Camera) Close()
- func (c *Camera) Execute(name string) error
- func (c *Camera) ExecuteCommand(name string) error
- func (c *Camera) GVCP() *gvcp.GVCP
- func (c *Camera) Has(name string) bool
- func (c *Camera) Logger() Logger
- func (c *Camera) NodeMap() *genapi.NodeMap
- func (c *Camera) SetBooleanFeature(name string, v bool) error
- func (c *Camera) SetFloatFeature(name string, v float64) error
- func (c *Camera) SetIntFeature(name string, v int64) error
- func (c *Camera) SetStringFeature(name, v string) error
- type Component
- type Device
- type DeviceInfo
- type Features
- type Frame
- type FrameSink
- type GVCP
- type GrabOption
- type Grabber
- type JPEGFunc
- type Live
- func (l *Live) Component() Component
- func (l *Live) LatestJPEG() []byte
- func (l *Live) LatestSample() Sample
- func (l *Live) Pause()
- func (l *Live) Restart(ctx context.Context)
- func (l *Live) Resume()
- func (l *Live) SetComponent(c Component)
- func (l *Live) Start(ctx context.Context)
- func (l *Live) Stop()
- type LiveOption
- type Logger
- type NodeMap
- type NopLogger
- type Option
- type Port
- type Sample
- type Session
- func (s *Session) Close() error
- func (s *Session) Grab(ctx context.Context) (Sample, error)
- func (s *Session) GrabAll(ctx context.Context) ([]Sample, error)
- func (s *Session) GrabComponents(ctx context.Context) ([]Sample, error)
- func (s *Session) Open(ip string) error
- func (s *Session) Opened() bool
- func (s *Session) Pause(ctx context.Context) error
- func (s *Session) PauseStreaming() error
- func (s *Session) Resume(ctx context.Context) error
- func (s *Session) ResumeStreaming() error
- func (s *Session) SetComponent(c Component)
- type Stream
Constants ¶
const ( ComponentUnknown = gvsp.ComponentUnknown ComponentMono = gvsp.ComponentMono ComponentDepth = gvsp.ComponentDepth ComponentColor = gvsp.ComponentColor )
SFNC-style imaging components (BSCF ImageType wire values).
const Version = "0.7.0"
Version is the library semver (no leading "v").
Variables ¶
var ( DialGVCP = gvcp.DialGVCP ParseNodeMap = genapi.ParseNodeMap FetchXML = genapi.FetchXML ListenStream = gvsp.ListenStream SampleFromBSCF = gvsp.SampleFromBSCF SampleFromBSCFComponent = gvsp.SampleFromBSCFComponent SampleAllFromBSCF = gvsp.SampleAllFromBSCF ParseBSCF = gvsp.ParseBSCF ParseComponent = gvsp.ParseComponent IsBSCF = gvsp.IsBSCF EncodeJPEG = color.EncodeJPEG StartAcquisition = gvcp.StartAcquisition StopAcquisition = gvcp.StopAcquisition )
Re-exports of common constructors / parsers.
Functions ¶
func ApplyControlPair ¶
ApplyControlPair sets one GenICam feature from "Name=value" string.
Types ¶
type Camera ¶
type Camera struct {
IP string
// contains filtered or unexported fields
}
Camera is a connected GigE Vision device with GenICam feature access.
func (*Camera) BooleanFeature ¶ added in v0.7.0
BooleanFeature reads the current value of a boolean GenICam feature.
func (*Camera) ExecuteCommand ¶
ExecuteCommand executes a GenICam command node.
func (*Camera) SetBooleanFeature ¶
SetBooleanFeature sets a boolean GenICam feature.
func (*Camera) SetFloatFeature ¶
SetFloatFeature sets a float GenICam feature.
func (*Camera) SetIntFeature ¶
SetIntFeature sets an integer GenICam feature.
func (*Camera) SetStringFeature ¶
SetStringFeature sets a string or enumeration GenICam feature.
type Component ¶ added in v0.5.0
Type aliases keep the root consumer API ergonomic for protocol types.
type Device ¶
type Device interface {
IP() string
Features() Features
StartGrabber(ctx context.Context, opts ...GrabOption) (Grabber, error)
Close() error
}
Device is a connected camera handle (control + ability to start streaming).
type DeviceInfo ¶
type DeviceInfo struct {
IP string
MAC string
Manufacturer string
Model string
Serial string
UserName string
}
DeviceInfo is a camera found via GigE Vision discovery (root API).
type Features ¶
type Features interface {
SetBool(name string, v bool) error
SetInt(name string, v int64) error
SetFloat(name string, v float64) error
SetString(name, v string) error
Execute(name string) error
Has(name string) bool
}
Features is GenICam feature access without exposing NodeMap.
type FrameSink ¶
type FrameSink interface {
SendJPEG(jpeg []byte)
Freeze()
Resume()
}
FrameSink receives JPEG frames from Live for preview (WebSocket, MJPEG, etc.). Implement this in application code — the library does not ship a WebSocket server.
type GrabOption ¶ added in v0.4.0
type GrabOption func(*Session)
GrabOption configures StartGrabber / Session.
func GrabComponent ¶ added in v0.5.0
func GrabComponent(comp Component) GrabOption
GrabComponent selects which BSCF/SFNC component Session.Grab decodes.
type Grabber ¶
type Grabber interface {
Grab(ctx context.Context) (Sample, error)
GrabAll(ctx context.Context) ([]Sample, error)
SetComponent(Component)
Pause(ctx context.Context) error
Resume(ctx context.Context) error
Close() error
}
Grabber is a live GVSP acquisition stream.
type JPEGFunc ¶
type JPEGFunc func([]byte)
JPEGFunc adapts a callback into a FrameSink (Freeze/Resume are no-ops). Handy for wiring Live to an existing broadcast function:
live := live.NewLive(dev, live.WithSink(JPEGFunc(hub.Broadcast)))
type Live ¶
type Live struct {
// contains filtered or unexported fields
}
Live keeps a Grabber open and publishes Samples (optionally to a FrameSink).
func NewLive ¶
func NewLive(dev Device, opts ...LiveOption) *Live
NewLive builds a Live preview/capture loop over an already-opened Device.
func (*Live) Component ¶ added in v0.5.0
Component returns the BSCF/SFNC component Live is decoding.
func (*Live) LatestJPEG ¶
LatestJPEG returns a copy of the most recent JPEG, or nil.
func (*Live) LatestSample ¶
LatestSample returns a copy of the most recent Sample.
func (*Live) Pause ¶
func (l *Live) Pause()
Pause freezes publishing and pauses the underlying Grabber when possible.
func (*Live) SetComponent ¶ added in v0.5.0
SetComponent switches the BSCF/SFNC component for subsequent grabs (no reconnect).
type LiveOption ¶
type LiveOption func(*Live)
LiveOption configures NewLive.
func WithLiveComponent ¶ added in v0.5.0
func WithLiveComponent(c Component) LiveOption
WithLiveComponent selects which BSCF/SFNC component Live grabs (color/depth/mono).
func WithOnSample ¶
func WithOnSample(fn func(Sample)) LiveOption
WithOnSample registers a callback after each published sample.
func WithSink ¶
func WithSink(s FrameSink) LiveOption
WithSink attaches a FrameSink for preview JPEG delivery.
type Logger ¶
type Logger interface {
Debug(msg string, kv ...any)
Info(msg string, kv ...any)
Warn(msg string, kv ...any)
Error(msg string, kv ...any)
}
Logger is a minimal structured logger. Default is a no-op.
type Option ¶
type Option func(*openConfig)
Option configures Open / device connection.
func WithComponent ¶ added in v0.5.0
WithComponent selects which BSCF/SFNC component GrabJPEG uses (color/depth/mono). Default: ComponentColor.
func WithLogger ¶
WithLogger sets the logger used by this device (default: NopLogger).
func WithTimeout ¶
WithTimeout sets the GVCP dial / control timeout (default: 2s).
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a persistent GVSP stream session. It implements Grabber.
func NewFromCamera ¶
NewFromCamera returns a Session that streams using cam without taking ownership.
func NewSession ¶
func NewSession() *Session
NewSession returns an empty GVSP session (Connects on Open if no camera set).
func (*Session) Close ¶
Close stops acquisition and releases stream resources. The Camera is closed only when the Session owns it (not when Device owns it).
func (*Session) Grab ¶
Grab implements Grabber: receives one GVSP frame, parses BSCF, returns JPEG Sample.
func (*Session) GrabAll ¶ added in v0.4.0
GrabAll receives one GVSP frame and returns a JPEG Sample for every BSCF component (color, depth, mono, …). Non-BSCF payloads yield a single sample.
func (*Session) GrabComponents ¶ added in v0.7.0
GrabComponents receives one GVSP frame and returns its BSCF components without JPEG encoding (raw Data, dimensions, pixel format). Non-BSCF payloads yield a single Sample with ComponentUnknown and no JPEG. Useful to probe what a camera is actually streaming beyond the JPEG color path.
func (*Session) PauseStreaming ¶
PauseStreaming stops image transfer but keeps CCP, heartbeat, and GVSP socket.
func (*Session) ResumeStreaming ¶
ResumeStreaming re-programs the stream channel and starts acquisition again.
func (*Session) SetComponent ¶ added in v0.5.0
SetComponent selects which BSCF/SFNC component Grab returns (color/depth/mono).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gogige-discover
command
gogige-discover broadcasts GigE Vision DISCOVERY_CMD and prints peers.
|
gogige-discover broadcasts GigE Vision DISCOVERY_CMD and prints peers. |
|
gogige-stream
command
gogige-stream captures N frames (JPEG + BSCF measurements) from a GigE camera.
|
gogige-stream captures N frames (JPEG + BSCF measurements) from a GigE camera. |
|
internal
|
|