camera

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Overview

Package camera provides a high-level API for capturing frames from an Android camera via binder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultRequest

func CreateDefaultRequest(
	ctx context.Context,
	deviceUser fwkDevice.ICameraDeviceUser,
	templateId fwkDevice.TemplateId,
) ([]byte, error)

CreateDefaultRequest calls CreateDefaultRequest using raw parcel I/O.

func CreateStreamWithSurface

func CreateStreamWithSurface(
	ctx context.Context,
	deviceUser fwkDevice.ICameraDeviceUser,
	transport binder.Transport,
	igbpStub *binder.StubBinder,
	width int32,
	height int32,
) (int32, error)

CreateStreamWithSurface creates a camera stream with the given IGBP stub as the surface. Uses raw parcel I/O because the generated proxy does not handle the native Surface/IGBP binder embedding.

func SubmitRequest

func SubmitRequest(
	ctx context.Context,
	deviceUser fwkDevice.ICameraDeviceUser,
	captureReq fwkDevice.CaptureRequest,
	isRepeating bool,
) (fwkDevice.SubmitInfo, error)

SubmitRequest sends a SubmitRequestList using raw parcel I/O.

Types

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device represents a connected camera device with a configured capture stream. Use Connect to create, ConfigureStream to set up the stream, CaptureFrame to read frames, and Close to disconnect.

func Connect

func Connect(
	ctx context.Context,
	sm *servicemanager.ServiceManager,
	transport binder.Transport,
	cameraID string,
) (_ *Device, _err error)

Connect opens a connection to the camera device identified by cameraID (typically "0" for the back camera).

func (*Device) CaptureFrame

func (d *Device) CaptureFrame(
	ctx context.Context,
) ([]byte, error)

CaptureFrame captures a single frame and returns the raw pixel data. The caller should have called ConfigureStream first. This method submits a repeating capture request on the first call, then reads from the IGBP queue channel on subsequent calls.

func (*Device) Close

func (d *Device) Close(ctx context.Context) error

Close disconnects from the camera device and releases gralloc buffers.

func (*Device) ConfigureStream

func (d *Device) ConfigureStream(
	ctx context.Context,
	width int32,
	height int32,
	format Format,
) error

ConfigureStream sets up a capture stream with the given dimensions and pixel format. It allocates gralloc buffers, creates an IGBP surface stub, and configures the camera for streaming.

type Format

type Format = gfxCommon.PixelFormat

Format identifies a pixel format for camera capture.

const (
	FormatYCbCr420 Format = gfxCommon.PixelFormatYcbcr420888
)

Supported pixel formats for camera capture.

Directories

Path Synopsis
Package gralloc provides gralloc buffer allocation via the Android IAllocator HAL service.
Package gralloc provides gralloc buffer allocation via the Android IAllocator HAL service.
Package igbp provides a minimal IGraphicBufferProducer stub backed by gralloc-allocated buffers, suitable for receiving camera frames.
Package igbp provides a minimal IGraphicBufferProducer stub backed by gralloc-allocated buffers, suitable for receiving camera frames.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL