ImageCapture Class

Takes photos and grabs frames of a video track (https://w3c.github.io/mediacapture-image/#imagecaptureapi). The photos are the current frame of the track, encoded as PNG at the size of the track: the capture backend has no photo mode.

public sealed class ImageCapture

Constructors

NameDescription
ImageCapture(MediaStreamTrack)Creates the image capture of a video track.

ImageCapture(MediaStreamTrack)

ImageCapture.cs

Creates the image capture of a video track.

public ImageCapture(MediaStreamTrack videoTrack)

Parameters

videoTrack MediaStreamTrack
The video track.

Exceptions

DomException
A NotSupportedError: the track is not a video track.

See also

Properties

NameDescription
TrackGets the video track.

Gets the video track.

public MediaStreamTrack Track { get; }

Methods

NameDescription
GetPhotoCapabilities()Returns the capabilities of the photos: their size is the size of the track (https://w3c.github.io/mediacapture-image/#dom-imagecapture-getphotocapabilities).
GetPhotoSettings()Returns the settings of the photos (https://w3c.github.io/mediacapture-image/#dom-imagecapture-getphotosettings).
GrabFrame()Grabs the current frame of the track (https://w3c.github.io/mediacapture-image/#dom-imagecapture-grabframe). The task fails with an InvalidStateError when the track is not live, is disabled or is muted, and with an UnknownError when the track has no frame.
TakePhoto(PhotoSettings?)Takes a photo (https://w3c.github.io/mediacapture-image/#dom-imagecapture-takephoto): the current frame of the track, as a PNG image. The task fails with an InvalidStateError when the track is not live, with an OverconstrainedError when the settings are not in the photo capabilities (the size of the photos is the size of the track, there is no flash and no red-eye reduction), and with an UnknownError when the track has no frame.

GetPhotoCapabilities()

ImageCapture.cs

Returns the capabilities of the photos: their size is the size of the track (https://w3c.github.io/mediacapture-image/#dom-imagecapture-getphotocapabilities).

public Task<PhotoCapabilities> GetPhotoCapabilities()

GetPhotoSettings()

ImageCapture.cs

Returns the settings of the photos (https://w3c.github.io/mediacapture-image/#dom-imagecapture-getphotosettings).

public Task<PhotoSettings> GetPhotoSettings()

GrabFrame()

ImageCapture.cs

Grabs the current frame of the track (https://w3c.github.io/mediacapture-image/#dom-imagecapture-grabframe). The task fails with an InvalidStateError when the track is not live, is disabled or is muted, and with an UnknownError when the track has no frame.

public Task<ImageBitmap> GrabFrame()

TakePhoto(PhotoSettings?)

ImageCapture.cs

Takes a photo (https://w3c.github.io/mediacapture-image/#dom-imagecapture-takephoto): the current frame of the track, as a PNG image. The task fails with an InvalidStateError when the track is not live, with an OverconstrainedError when the settings are not in the photo capabilities (the size of the photos is the size of the track, there is no flash and no red-eye reduction), and with an UnknownError when the track has no frame.

public Task<Blob> TakePhoto(PhotoSettings? photoSettings = null)

Parameters

photoSettings PhotoSettings?
The settings of the photo.

Returns

Task<Blob>

See also