Documentation
¶
Overview ¶
Package camera defines an image capturing device. For more information, see the camera component docs.
Index ¶
- Constants
- Variables
- func DecodeImageFromCamera(ctx context.Context, cam Camera, filterSourceNames []string, ...) (image.Image, error)
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewPinholeModelWithBrownConradyDistortion(pinholeCameraIntrinsics *transform.PinholeCameraIntrinsics, ...) transform.PinholeCameraModel
- func NewPropertiesError(cameraIdentifier string) error
- func NewRPCServiceServer(coll resource.APIResourceGetter[Camera], logger logging.Logger) interface{}
- func NewUnsupportedImageTypeError(s ImageType) error
- func ReadImage(ctx context.Context, src gostream.VideoSource) (image.Image, func(), error)
- type Camera
- func FromDependencies(deps resource.Dependencies, name string) (Camera, error)deprecated
- func FromProvider(provider resource.Provider, name string) (Camera, error)
- func FromRobot(r robot.Robot, name string) (Camera, error)deprecated
- func NewClientFromConn(ctx context.Context, conn rpc.ClientConn, remoteName string, ...) (Camera, error)
- type ExtrinsicParams
- type ImageType
- type ImagesSource
- type NamedImage
- type PointCloudSource
- type Properties
- type VideoSource
Constants ¶
const ( UnspecifiedStream = ImageType("") ColorStream = ImageType("color") DepthStream = ImageType("depth") )
The allowed types of streams that can come from a VideoSource.
const SubtypeName = "camera"
SubtypeName is a constant that identifies the camera resource subtype string.
Variables ¶
var ( // ErrNoPeerConnection indicates there was no peer connection. ErrNoPeerConnection = errors.New("no PeerConnection") ErrNoSharedPeerConnection = errors.New("no Shared PeerConnection") // ErrUnknownSubscriptionID indicates that a SubscriptionID is unknown. ErrUnknownSubscriptionID = errors.New("subscriptionID Unknown") )
var API = resource.APINamespaceRDK.WithComponentType(SubtypeName)
API is a variable that identifies the camera resource API.
var ErrMIMETypeBytesMismatch = errors.New("mime_type does not match the image bytes")
ErrMIMETypeBytesMismatch indicates that the NamedImage's mimeType does not match the image bytes header.
For example, if the image bytes are JPEG, but the mimeType is PNG, this error will be returned. This likely means there is a bug in the code that created the GetImages response.
However, there may still be valid, decodeable underlying JPEG image bytes. If you want to decode the image bytes as a JPEG regardless of the mismatch, you can recover from this error, call the .Bytes() method, then decode the image bytes as JPEG manually with image.Decode().
Functions ¶
func DecodeImageFromCamera ¶ added in v0.53.0
func DecodeImageFromCamera(ctx context.Context, cam Camera, filterSourceNames []string, extra map[string]interface{}) (image.Image, error)
DecodeImageFromCamera gets images from a camera resource and returns the first image as a decoded image.Image.
func NamesFromRobot ¶
NamesFromRobot is a helper for getting all camera names from the given Robot.
func NewPinholeModelWithBrownConradyDistortion ¶ added in v0.2.13
func NewPinholeModelWithBrownConradyDistortion(pinholeCameraIntrinsics *transform.PinholeCameraIntrinsics, distortion *transform.BrownConrady, ) transform.PinholeCameraModel
NewPinholeModelWithBrownConradyDistortion is DEPRECATED!!! Please implement cameras according to the camera.Camera interface. NewPinholeModelWithBrownConradyDistortion creates a transform.PinholeCameraModel from a *transform.PinholeCameraIntrinsics and a *transform.BrownConrady. If *transform.BrownConrady is `nil`, transform.PinholeCameraModel.Distortion is not set & remains nil, to prevent https://go.dev/doc/faq#nil_error.
func NewPropertiesError ¶
NewPropertiesError returns an error specific to a failure in Properties.
func NewRPCServiceServer ¶ added in v0.2.36
func NewRPCServiceServer(coll resource.APIResourceGetter[Camera], logger logging.Logger) interface{}
NewRPCServiceServer constructs an camera gRPC service server. It is intentionally untyped to prevent use outside of tests.
func NewUnsupportedImageTypeError ¶ added in v0.2.4
NewUnsupportedImageTypeError is when the stream type is unknown.
Types ¶
type Camera ¶
type Camera interface {
resource.Resource
resource.Shaped
// Images is used for getting simultaneous images from different imagers from 3D cameras along with associated metadata,
// and single images from non-3D cameras e.g. webcams, RTSP cameras etc. in the NamedImage list response.
// It is not for getting a time series of images from the same imager.
//
// The filterSourceNames parameter can be used to filter only the images from the specified source names, and
// when unspecified, all images are returned.
//
// The extra parameter can be used to pass additional options to the camera resource.
Images(ctx context.Context, filterSourceNames []string, extra map[string]interface{}) ([]NamedImage, resource.ResponseMetadata, error)
// NextPointCloud returns the next immediately available point cloud, not necessarily one
// a part of a sequence. In the future, there could be streaming of point clouds.
NextPointCloud(ctx context.Context, extra map[string]interface{}) (pointcloud.PointCloud, error)
// Properties returns properties that are intrinsic to the particular
// implementation of a camera.
Properties(ctx context.Context) (Properties, error)
}
A Camera is a resource that can capture frames. For more information, see the camera component docs.
Images example:
myCamera, err := camera.FromProvider(machine, "my_camera") images, metadata, err := myCamera.Images(context.Background(), nil, nil)
For more information, see the Images method docs.
NextPointCloud example:
myCamera, err := camera.FromProvider(machine, "my_camera") // gets the next point cloud from a camera pointCloud, err := myCamera.NextPointCloud(context.Background(), nil)
For more information, see the NextPointCloud method docs.
Close example:
myCamera, err := camera.FromProvider(machine, "my_camera") err = myCamera.Close(context.Background())
For more information, see the Close method docs.
func FromDependencies
deprecated
func FromDependencies(deps resource.Dependencies, name string) (Camera, error)
Deprecated: FromDependencies is a helper for getting the named camera from a collection of dependencies. Use FromProvider instead.
func FromProvider ¶ added in v0.98.0
FromProvider is a helper for getting the named Camera from a resource Provider (collection of Dependencies or a Robot).
type ExtrinsicParams ¶ added in v0.116.0
type ExtrinsicParams struct {
Translation r3.Vector
Orientation spatialmath.Orientation
}
ExtrinsicParams define the position and orientation of the camera relative to a reference frame (the world or another sensor).
type ImageType ¶ added in v0.2.4
type ImageType string
ImageType specifies what kind of image stream is coming from the camera.
type ImagesSource ¶ added in v0.5.0
type ImagesSource interface {
Images(ctx context.Context, filterSourceNames []string, extra map[string]interface{}) ([]NamedImage, resource.ResponseMetadata, error)
}
A ImagesSource is a source that can return a list of images with timestamp.
type NamedImage ¶ added in v0.7.3
type NamedImage struct {
SourceName string
Annotations data.Annotations
// contains filtered or unexported fields
}
NamedImage is a struct that associates the source from where the image came from to the Image.
func NamedImageFromBytes ¶ added in v0.91.0
func NamedImageFromBytes(data []byte, sourceName, mimeType string, annotations data.Annotations, ) (NamedImage, error)
NamedImageFromBytes constructs a NamedImage from a byte slice, source name, mime type, and annotations.
func NamedImageFromImage ¶ added in v0.91.0
func NamedImageFromImage(img image.Image, sourceName, mimeType string, annotations data.Annotations, ) (NamedImage, error)
NamedImageFromImage constructs a NamedImage from an image.Image, source name, mime type, and annotations.
func (*NamedImage) Bounds ¶ added in v0.125.0
func (ni *NamedImage) Bounds() (image.Rectangle, error)
Bounds returns the image bounds. If the NamedImage is backed by a decoded image, its bounds are returned directly; if it is byte-backed, only the format header is parsed (via image.DecodeConfig) so the pixels are not decoded.
func (*NamedImage) Bytes ¶ added in v0.91.0
func (ni *NamedImage) Bytes(ctx context.Context) ([]byte, error)
Bytes returns the byte slice of the NamedImage.
func (*NamedImage) MimeType ¶ added in v0.91.0
func (ni *NamedImage) MimeType() string
MimeType returns the mime type of the NamedImage.
type PointCloudSource ¶
type PointCloudSource interface {
NextPointCloud(ctx context.Context, extra map[string]interface{}) (pointcloud.PointCloud, error)
}
A PointCloudSource is a source that can generate pointclouds.
type Properties ¶
type Properties struct {
// SupportsPCD indicates that the Camera supports a valid
// implementation of NextPointCloud
SupportsPCD bool
ImageType ImageType
IntrinsicParams *transform.PinholeCameraIntrinsics
DistortionParams transform.Distorter
ExtrinsicParams *ExtrinsicParams
MimeTypes []string
FrameRate float32
}
Properties is a lookup for a camera's features and settings.
func (*Properties) PointToPixel ¶ added in v0.116.0
PointToPixel projects a 3D point to a 2D pixel coordinate. If extrinsic parameters are set, the point is first transformed from the depth/reference frame into the camera's coordinate frame, then projected to a pixel using intrinsics.
type VideoSource ¶ added in v0.2.36
type VideoSource interface {
Camera
Stream(ctx context.Context, errHandlers ...gostream.ErrorHandler) (gostream.VideoStream, error)
}
VideoSource is a camera that has `Stream` embedded to directly integrate with gostream. Note that generally, when writing camera components from scratch, embedding `Stream` is an anti-pattern.
func FromVideoSource ¶ added in v0.2.36
func FromVideoSource(name resource.Name, src VideoSource) VideoSource
FromVideoSource is DEPRECATED!!! Please implement cameras according to the camera.Camera interface. FromVideoSource creates a Camera resource from a VideoSource. Note: this strips away Reconfiguration and DoCommand abilities. If needed, implement the Camera another way. For example, a webcam implements a Camera manually so that it can atomically reconfigure itself.
func NewVideoSourceFromReader ¶ added in v0.2.36
func NewVideoSourceFromReader( ctx context.Context, reader gostream.VideoReader, syst *transform.PinholeCameraModel, imageType ImageType, ) (VideoSource, error)
NewVideoSourceFromReader is DEPRECATED!!! Please implement cameras according to the camera.Camera interface. NewVideoSourceFromReader creates a VideoSource either with or without a projector. The stream type argument is for detecting whether or not the resulting camera supports return of pointcloud data in the absence of an implemented NextPointCloud function. If this is unknown or not applicable, a value of camera.Unspecified stream can be supplied.
func WrapVideoSourceWithProjector ¶ added in v0.2.36
func WrapVideoSourceWithProjector( ctx context.Context, source gostream.VideoSource, syst *transform.PinholeCameraModel, imageType ImageType, ) (VideoSource, error)
WrapVideoSourceWithProjector is DEPRECATED!!! Please implement cameras according to the camera.Camera interface. WrapVideoSourceWithProjector creates a Camera either with or without a projector. The stream type argument is for detecting whether or not the resulting camera supports return of pointcloud data in the absence of an implemented NextPointCloud function. If this is unknown or not applicable, a value of camera.Unspecified stream can be supplied.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fake implements a fake camera which always returns the same image with a user specified resolution.
|
Package fake implements a fake camera which always returns the same image with a user specified resolution. |
|
Package ffmpeg provides an implementation for an ffmpeg based camera
|
Package ffmpeg provides an implementation for an ffmpeg based camera |
|
Package register registers all relevant cameras and also API specific functions
|
Package register registers all relevant cameras and also API specific functions |
|
Package replaypcd implements a replay camera that can return point cloud data.
|
Package replaypcd implements a replay camera that can return point cloud data. |
|
Package rtppassthrough defines a Source of RTP packets
|
Package rtppassthrough defines a Source of RTP packets |
|
Package transformpipeline defines image sources that apply transforms on images, and can be composed into an image transformation pipeline.
|
Package transformpipeline defines image sources that apply transforms on images, and can be composed into an image transformation pipeline. |
|
Package videosource implements webcam.
|
Package videosource implements webcam. |