Main Content

getsnapshot

Immediately return single image frame

Description

frame = getsnapshot(obj) immediately returns one single image frame, frame, from the video input object obj.

Note

If obj is running but not logging, and has been configured with a hardware trigger, a timeout error will occur.

To interrupt the getsnapshot function and return control to the MATLAB® command line, issue the ^C (Ctrl+C) command.

example

[frame,metadata] = getsnapshot(obj) returns additional information about the image frame.

Examples

collapse all

Create a video object using the videoinput function.

obj = videoinput('winvideo')
Summary of Video Input Object Using 'Microsoft® LifeCam Cinema(TM)'.

   Acquisition Source(s):  input1 is available.

  Acquisition Parameters:  'input1' is the current selected source.
                           10 frames per trigger using the selected source.
                           'YUY2_1280x720' video data to be logged upon START.
                           Grabbing first of every 1 frame(s).
                           Log data to 'memory' on trigger.

      Trigger Parameters:  1 'immediate' trigger(s) on START.

                  Status:  Waiting for START.
                           0 frames acquired since starting.
                           0 frames available for GETDATA.

Since the default video format of this camera is YUY2_1280x720, images are returned in the YCbCr color space. Change the color space to rgb by specifying the value of the ReturnedColorSpace property.

obj.ReturnedColorSpace = "rgb";

To acquire a single frame, use the getsnapshot function.

frame = getsnapshot(obj);

Display the frame in a figure window.

imagesc(frame)

Rubik's cube

Input Arguments

collapse all

Video input object, specified as the output of the videoinput function. obj must be a 1-by-1 video input object.

Example: videoinput("matrox")

Output Arguments

collapse all

Image data, returned as an H-by-W-by-B array, where:

H

Image height, as specified in the object's ROIPosition property

W

Image width, as specified in the object's ROIPosition property

B

Number of color bands, as specified in the NumberOfBands property

The frame of data returned is independent of the video input object FramesPerTrigger property and has no effect on the value of the FramesAvailable or FramesAcquired property.

frame is returned to the MATLAB workspace in its native data type using the color space specified by the ReturnedColorSpace property.

You can use the MATLAB image or imagesc functions to view the returned data. Use imaqmontage to view multiple frames at once.

Extra information about the frame in data, returned as a structure. The metadata structure contains the field AbsTime, which is the absolute time the frame was acquired, expressed as a time vector. In addition to that field, some adaptors might also add other adaptor-specific metadata.. For example, GenICam™ GenTL compliant cameras can have a ChunkData field returning chunk metadata according to the configuration viewed by the chunkDataInfo function.

Version History

Introduced before R2006a