Documentation
¶
Overview ¶
Package gogige is a pure-Go GigE Vision client.
Controlled access: OpenDevice returns a *Camera. Use Camera.SetInteger / SetEnum / SetFloat / SetBoolean / SetString to write features and their matching getter (Integer / Enum / Float / Boolean / String) to read them.
cam, err := gogige.OpenDevice(ctx, "192.168.1.10")
defer cam.Close()
_ = cam.SetInteger("Width", 1920)
_ = cam.SetEnum("PixelFormat", "Mono8")
_ = cam.SetBoolean("AcquisitionStart", true)
Live frames (Phase 4): Camera.StartStream → stream.Frames() of pooled frames; Release() each frame back to the buffer pool.
stream, err := cam.StartStream(ctx)
defer stream.Stop()
for frame := range stream.Frames() {
// use frame.Data
frame.Release()
}
One-shot samples (Huaray BSCF): Camera.GrabSample / GrabAllSamples / GrabJPEG grab a single frame directly from the Camera. For continuous preview use a Device (Open → StartGrabber → Grabber.Grab) or live.NewLive.
dev, _ := gogige.Open(ctx, ip) g, _ := dev.StartGrabber(ctx) sample, _ := g.Grab(ctx) // sample.JPEG + mm measurements
Protocol packages:
- gvcp — GigE Vision Control Protocol (GenCP)
- genapi — GenICam GenApi XML / node map
- gvsp — GigE Vision Streaming Protocol
- gentl — GenTL constants (no CGO)
References
- GigE Vision for Realtime MV (2010)
- GenICam GenCP Standard v1.3.1
- GenICam Standard v2.1.1
- GenICam GenApi Standard v2.1.1
- GenICam GenTL Standard v1.6
- GenICam GenDC Standard v1.1
- GenICam SFNC v2.7
- https://www.emva.org/standards-technical-documents/
Index ¶
- Constants
- Variables
- func ApplyControlPair(c *Camera, pair string) error
- type Camera
- func (c *Camera) Boolean(name string) (bool, error)
- func (c *Camera) BooleanFeature(name string) (bool, error)
- func (c *Camera) Close()
- func (c *Camera) Enum(name string) (string, error)
- func (c *Camera) Execute(name string) error
- func (c *Camera) ExecuteCommand(name string) error
- func (c *Camera) Features() Features
- func (c *Camera) Float(name string) (float64, error)
- func (c *Camera) GVCP() *gvcp.GVCP
- func (c *Camera) GrabAllSamples(ctx context.Context) ([]Sample, error)
- func (c *Camera) GrabComponents(ctx context.Context) ([]Sample, error)
- func (c *Camera) GrabJPEG(ctx context.Context, comp Component) ([]byte, error)
- func (c *Camera) GrabSample(ctx context.Context, comp Component) (Sample, error)
- func (c *Camera) Has(name string) bool
- func (c *Camera) Integer(name string) (int64, error)
- func (c *Camera) Logger() Logger
- func (c *Camera) NodeMap() *genapi.NodeMap
- func (c *Camera) SetBoolean(name string, v bool) error
- func (c *Camera) SetBooleanFeature(name string, v bool) error
- func (c *Camera) SetEnum(name, value string) error
- func (c *Camera) SetFloat(name string, v float64) error
- func (c *Camera) SetFloatFeature(name string, v float64) error
- func (c *Camera) SetIntFeature(name string, v int64) error
- func (c *Camera) SetInteger(name string, v int64) error
- func (c *Camera) SetString(name, v string) error
- func (c *Camera) SetStringFeature(name, v string) error
- func (c *Camera) StartStream(ctx context.Context) (*Stream, error)
- func (c *Camera) String(name string) (string, error)
- type Component
- type Device
- type DeviceInfo
- type Features
- type Frame
- type FrameSink
- type GVCP
- type GVSPStream
- type GrabOption
- type Grabber
- type JPEGFunc
- 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
- type Throttler
Constants ¶
const ( ComponentUnknown = gvsp.ComponentUnknown ComponentMono = gvsp.ComponentMono ComponentDepth = gvsp.ComponentDepth ComponentColor = gvsp.ComponentColor )
SFNC-style imaging components (BSCF ImageType wire values).
const Version = "1.5.0"
Version is the library version.
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 OpenDevice ¶ added in v0.9.0
OpenDevice connects to a GigE Vision camera and returns the Camera directly (Phase 4 surface). Use Camera.SetInteger / SetEnum for control and Camera.StartStream for live frames.
func (*Camera) Boolean ¶ added in v1.5.0
Boolean reads the current value of a boolean GenICam feature.
func (*Camera) BooleanFeature ¶ added in v0.7.0
BooleanFeature reads a boolean GenICam feature (alias for Boolean).
func (*Camera) Enum ¶ added in v1.5.0
Enum reads the current enumeration symbol of an enumeration GenICam feature.
func (*Camera) ExecuteCommand ¶
ExecuteCommand executes a GenICam command node.
func (*Camera) Features ¶ added in v1.5.0
Features returns a Features view backed by this Camera, so callers that already hold a *Camera can use the same feature accessors as a Device.
func (*Camera) GrabAllSamples ¶ added in v1.5.0
GrabAllSamples opens a transient GVSP stream on the camera, picks one frame, and returns a Sample for every BSCF component (color, depth, mono, …).
func (*Camera) GrabComponents ¶ added in v1.5.0
GrabComponents opens a transient GVSP stream on the camera and returns one frame's BSCF components without JPEG encoding (raw Data, dimensions, pixel format).
func (*Camera) GrabJPEG ¶ added in v1.5.0
GrabJPEG opens a transient GVSP stream on the camera, picks one frame, and returns the JPEG bytes for the requested component (default color).
func (*Camera) GrabSample ¶ added in v1.5.0
GrabSample opens a transient GVSP stream on the camera, picks one frame, and returns it as a Sample with a JPEG for the requested component. comp of ComponentUnknown selects ComponentColor. Closes the stream before returning. Prefer StartStream for continuous capture; this is for one-off grabs from a Camera you already hold.
func (*Camera) Integer ¶ added in v1.5.0
Integer reads the current value of an integer GenICam feature.
func (*Camera) SetBoolean ¶ added in v1.5.0
SetBoolean sets a boolean GenICam feature.
func (*Camera) SetBooleanFeature ¶
SetBooleanFeature sets a boolean GenICam feature (alias for SetBoolean).
func (*Camera) SetFloatFeature ¶
SetFloatFeature sets a float GenICam feature (alias for SetFloat).
func (*Camera) SetIntFeature ¶
SetIntFeature sets an integer GenICam feature (alias for SetInteger).
func (*Camera) SetInteger ¶ added in v0.9.0
SetInteger sets an integer GenICam feature.
func (*Camera) SetStringFeature ¶
SetStringFeature sets a string or enumeration GenICam feature (alias for SetString/SetEnum).
func (*Camera) StartStream ¶ added in v0.9.0
StartStream opens a GVSP channel on c and begins acquisition. Frames are delivered over Stream.Frames() until the context is cancelled or Stop is called. The Camera stays open; close it separately when done.
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
Bool(name string) (bool, error)
SetInt(name string, v int64) error
Int(name string) (int64, error)
SetFloat(name string, v float64) error
Float(name string) (float64, error)
SetString(name, v string) error
String(name string) (string, error)
Enum(name string) (string, error)
Execute(name string) error
Has(name string) bool
}
Features is GenICam feature access without exposing NodeMap. It mirrors the short forms on Camera (SetInteger/Integer, SetEnum/Enum, …) so a Device and a Camera share one consistent vocabulary.
type FrameSink ¶
type FrameSink interface {
SendJPEG(jpeg []byte)
}
FrameSink receives JPEG frames from Live for preview (WebSocket, MJPEG, etc.). Implement this in application code — the library does not ship a WebSocket server. Flow control is optional: implement Throttler separately if the sink supports it.
type GVSPStream ¶ added in v0.9.0
Type aliases keep the root consumer API ergonomic for protocol types.
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. It is stateless and therefore does not implement Throttler. Handy for wiring live to an existing broadcast function:
l := live.NewLive(dev, live.WithSink(JPEGFunc(hub.Broadcast)))
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).
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is a live GVSP acquisition channel (Phase 4). Create one via Camera.StartStream, consume pooled frames from Frames(), and Release() each frame back to the pre-allocated buffer pool.
func (*Stream) Frames ¶ added in v0.9.0
Frames returns the channel of pooled frames. The channel closes when the stream ends (context cancelled, Stop called, or the session goes away).
func (*Stream) Pause ¶ added in v0.9.0
Pause stops image transfer but keeps the control channel and socket open.
type Throttler ¶ added in v1.5.0
type Throttler interface {
Throttle()
Unthrottle()
}
Throttler is optional flow control for a FrameSink. Live asserts this and calls Throttle/Unthrottle only when the sink opts in, so simple stateless sinks (e.g. JPEGFunc) need no stub methods. Unlike Grabber.Pause/Resume (which throttle camera acquisition), this throttles delivery to the consumer.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package calib converts between camera-frame 3D coordinates (millimetres) and image pixel coordinates using pinhole intrinsics.
|
Package calib converts between camera-frame 3D coordinates (millimetres) and image pixel coordinates using pinhole intrinsics. |
|
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. |
|
Package genapi provides GenICam GenApi XML parser and node map implementation.
|
Package genapi provides GenICam GenApi XML parser and node map implementation. |
|
Package gentl provides GenTL (GenICam Transport Layer) definitions.
|
Package gentl provides GenTL (GenICam Transport Layer) definitions. |
|
Package gvcp provides GigE Vision Control Protocol (GVCP) implementation.
|
Package gvcp provides GigE Vision Control Protocol (GVCP) implementation. |
|
Package gvsp provides GigE Vision Streaming Protocol (GVSP) implementation.
|
Package gvsp provides GigE Vision Streaming Protocol (GVSP) implementation. |
|
internal
|
|