This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

closePreview

Close webcam preview window

Syntax

closePreview(cam)

Description

example

closePreview(cam) closes the webcam preview window for the webcam object cam. You can close the preview at any time using the closePreview function. If you do not explicitly close the preview, it closes when you clear the webcam object.

Examples

collapse all

You can open or close the webcam preview window any time after creating the webcam object.

Find the name of your camera using the webcamlist function to ensure that MATLAB® is discovering your camera(s).

webcamlist
ans = 2×1 cell array
    {'Logitech Webcam 250'          }
    {'Microsoft® LifeCam Cinema(TM)'}

Use the webcam function with the name of the camera as the input argument to create the object and connect it to the camera with that name. You can use the exact name from the output of webcamlist, which is 'Logitech Webcam 250' in this example. Or you can also use a shortened version of the name, for example, the brand of the camera, which in this case is 'Logitech'. Use cam as the name of the object.

cam = webcam('Logitech')
cam = 
  webcam with properties:

                     Name: 'Logitech Webcam 250'
               Resolution: '640x480'
     AvailableResolutions: {'640x480'  '160x90'  '160x100'  '160x120'  '176x144'  '320x180'  '320x200'  '320x240'  '352x288'  '640x360'  '640x400'}
                 Contrast: 32
             ExposureMode: 'auto'
                     Gain: 63
             WhiteBalance: 0
               Brightness: 128
                Sharpness: 48
                 Exposure: -6
    BacklightCompensation: 1
               Saturation: 32

It creates the object and connects it to the Logitech® webcam.

Preview the image from the webcam.

preview(cam)

The preview window opens and displays live video stream from your camera. The preview dynamically updates, so if you change a property while previewing, the image changes to reflect the property change.

Close the preview.

closePreview(cam)

The preview window closes.

After you preview the image, the next steps are optionally changing any properties you need to set, and then acquiring images using the snapshot function. For more information on these steps, see the topics listed below.

Input Arguments

collapse all

Webcam hardware connection created using webcam, specified as a webcam object.

Introduced in R2014a