Table of Contents
Video Capture
Captures video images from a device, such as a camera, or a file or from a supplied matrix.
Library
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
qc_open_library('quarc_library/Multimedia')Description
The Video Capture block grabs video images from a device, such as a camera, or from a file or a supplied matrix value and outputs each frame as a colour image. The output is a three-dimensional matrix representing the red, green and blue components of each pixel in the image.
The Video Capture block may also be configured to output the image as a grayscale image. In that case, the output is a two-dimensional matrix where each element represents a shade of grey. A grayscale image takes less memory and is faster to process.
The output dimensions can be changed by using the Output format parameter to accomodate the image processing algorithm to be used on the iamge.
A variety of different output data types are supported that are compatible with The MathWorks'
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc vision;
When streaming from a device, such as a camera, the device is selected by device identifier. For example,
on the QDrone, the device identifier for the OV7251 camera is 2
.
For information about the cameras supported on particular devices, follow the link to the corresponding
device on the QUARC Data Acquisition Card Support
page.
Other parameters allow various camera settings to be tuned to accomodate the environment. Note however that not all cameras support tuning all available settings. In that case, the camera settings are simply ignored and no error is generated.
Helpful Hints
Video Formats
Cameras typically only support certain resolutions and frame rates. If the Video Capture block reports that the video format is not supported, try other resolutions and frame rates. Use the query (<<) button when the target is powered on to select from a list of cameras, resolutions and frame rates on the target.
Input Ports
brt
The brightness as a fraction between 0.0 and 1.0. This input is only present if the Brightness Override parameter is set to Override using input port.
con
The contrast as a fraction between 0.0 and 1.0. This input is only present if the Contrast Override parameter is set to Override using input port.
hue
The hue as a fraction between 0.0 and 1.0. This input is only present if the Hue Override parameter is set to Override using input port.
sat
The saturation as a fraction between 0.0 and 1.0. This input is only present if the Saturation Override parameter is set to Override using input port.
shp
The sharpness as a fraction between 0.0 and 1.0. This input is only present if the Sharpness Override parameter is set to Override using input port.
gam
The gamma as a fraction between 0.0 and 1.0. This input is only present if the Gamma Override parameter is set to Override using input port.
col
The color effect as an integer between 0 and 14 inclusive. This input is only present if the Color Effect Override parameter is set to Override using input port. The color effects corresponding to each integer value are:
Value |
Color Effect |
---|---|
0 |
None |
1 |
Black and White |
2 |
Sepia |
3 |
Negative |
4 |
Emboss |
5 |
Sketch |
6 |
Sky Blue |
7 |
Grass Green |
8 |
Skin Whiten |
9 |
Vivid |
10 |
Aqua |
11 |
Art Freeze |
12 |
Silhouette |
13 |
Solarization |
14 |
Antique |
wbl
The white balance as a fraction between 0.0 and 1.0. This input is only present if the White Balance Override parameter is set to White balance via input port.
bck
The backlight compensation as a fraction between 0.0 and 1.0. This input is only present if the Backlight Compensation Override parameter is set to Override using input port.
gain
The gain as a fraction between 0.0 and 1.0. This input is only present if the Gain Override parameter is set to Override using input port.
pan
The panning as a fraction between 0.0 and 1.0. This input is only present if the Pan Override parameter is set to Override using input port.
tilt
The tilt as a fraction between 0.0 and 1.0. This input is only present if the Tilt Override parameter is set to Override using input port.
roll
The roll as a fraction between 0.0 and 1.0. This input is only present if the Roll Override parameter is set to Override using input port.
zoom
The gain as a fraction between 0.0 and 1.0. This input is only present if the Zoom Override parameter is set to Override using input port.
exp
The exposure as a fraction between 0.0 and 1.0. This input is only present if the Exposure Override parameter is set to Exposure via input port.
iris
The iris opening as a fraction between 0.0 and 1.0. This input is only present if the Iris Override parameter is set to Override using input port.
focus
The focus as a fraction between 0.0 and 1.0. This input is only present if the Focus Override parameter is set to Override using input port.
mirror
The mirroring as an integer between 0 and 3. This input is only present if the Mirror Override parameter is set to Override using input port. The mirroring options corresponding to each integer value are:
Value |
Mirror |
---|---|
0 |
None |
1 |
Horizontally |
2 |
Vertically |
3 |
Rotate 180 degrees |
Output Ports
image
When the Output format is set to MATLAB RGB this output is a three-dimensional MxNx3 matrix where M is the image height and N is the image width. It contains the red, green and blue components for each pixel in the image.
When the Output format is set to MATLAB Greyscale this output is a two-dimensional MxN matrix where M is the image height and N is the image width. It contains the shade of grey for each pixel in the image.
The data type depends on the Output data type parameter. The matrix is compatible with The MathWorks'
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc vision;new
This output is true whenever a new frame is being output at the image port. Otherwise it is false.
Parameters and Dialog Box
Main Pane
The Main pane of the dialog appears as follows:
The Main tab contains the core settings affecting the output of the block, such as source of video, image resolution and output format.
Source
The source of the video. The source may be a device, such as a camera, attached to the target system. It may be a file or URL, or it may be a constant matrix value.
Device identifier
The number of the device from which to grab video or its identifier. This parameter is only visible when the Source parameter is set to device.
Use the query (<<) button beside the device identifier field when the target is powered up to connect to the target and get a list of cameras, resolutions and frame rates from which to select the camera or setting desired.
Filename
The filename or URL of the video. A relative or absolute path may be specified. This parameter is only visible when the Source parameter is set to file.
Video data as a matrix
The video data as a constant matrix expression. This parameter is only visible when the Source parameter is set to value.
The following table enumerates the matrix dimensions that are valid:
Dimensions |
Description |
---|---|
H x W x 3 x F |
A series of F RGB frames of height, H, and width, W. |
H x W x 1 x F |
A series of F grayscale frames of height, H, and width, W. |
H x W x 3 |
A single RGB frame of height, H, and width, W. |
H x W |
A single grayscale frame of height, H, and width, W. |
Take careful note of the fact that the height is the first dimension, not the width. Think of the rows being the vertical dimension and the columns being the horizontal dimension.
The matrix may be a double, single, uint8, uint16 or uint32 matrix.
Note that the matrix is interpreted according to its data type. For example, a double matrix should have elements in the range [0,1] while a uint8 matrix should have elements in the range [0,255]. |
The matrix will be converted to the output data type, with elements scaled appropriately.
Doing so allows code such as obj=VideoReader('movie.wmv');value=obj.read;
to be
used to generate the matrix 'value'.
It is recommended that only small matrices be used for this parameter because the matrix value is included in the generated code, resulting in very large executables. Code generation may be slow. |
Image resolution
The resolution of the video images to retrieve. A typical resolution is 640 x 480.
Output format
The format of the output image. The output format may be MATLAB RGB, in which the image output is a three-dimensional MxNx3 matrix, or MATLAB Greyscale, in which the image output is a two-dimensional MxN matrix.
Output data type
The data type to use for the image output. Both integral and floating-point data types are supported. The output data types are compatible with The MathWorks'
MATLAB Command Line
Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:
doc vision;Sample time
The sampling period (in seconds) of the Video Capture block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.
A sample time of -1 indicates that the block inherits its sample time. Since this is a source block, only inherent the sample time when it is placed in a conditionally executed subsystem, like a Triggered or Enabled Subsystem, or in a referenced model.
The default sample time is set to qc_get_step_size * ceil(0.033 / qc_get_step_size). The qc_get_step_size function is a QUARC function that returns the fundamental sampling time of the model. Hence, the default sample time is a discrete sample time which is a multiple of the fixed step size of the model and close to 1/30 of a second.
Image Properties Pane
The Image Properties pane of the dialog appears as follows:
The Image Properties tab contains the settings related to the image output. The settings in this tab is only visible when the Source parameter is set to device.
Not all properties can be adjusted for all cameras. Whether a property can be adjusted depends on the camera driver support. If there is no effect after a particular setting is adjusted, this means that setting is not supported by the camera.
Brightness Override
Set this option to Override using dialog to enable the video's brightness to be controlled via the Brightness parameter. Set this option to Override using input port to enable the video's brightness to be controlled via external input port, brt. If this option is set to Do not override then the video's brightness is not set.
Brightness (tunable online)
The brightness of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Brightness Override option is set to Override using dialog.
Contrast Override
Set this option to Override using dialog to enable the video's contrast to be controlled via the Contrast parameter. Set this option to Override using input port to enable the video's contrast to be controlled via external input port, con. If this option is set to Do not override then the video's contrast is not set.
Contrast (tunable online)
The contrast of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Contrast Override option is set to Override using dialog.
Hue Override
Set this option to Override using dialog to enable the video's hue to be controlled via the Hue parameter. Set this option to Override using input port to enable the video's hue to be controlled via external input port, hue. If this option is set to Do not override then the video's hue is not set.
Hue (tunable online)
The shade of colours of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Hue Override option is set to Override using dialog.
Saturation Override
Set this option to Override using dialog to enable the video's saturation to be controlled via the Saturation parameter. Set this option to Override using input port to enable the video's saturation to be controlled via external input port, sat. If this option is set to Do not override then the video's saturation is not set.
Saturation (tunable online)
The intensity of the colour relative to the brightness of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Saturation Override option is set to Override using dialog.
Sharpness Override
Set this option to Override using dialog to enable the video's sharpness to be controlled via the Sharpness parameter. Set this option to Override using input port to enable the video's sharpness to be controlled via external input port, shp. If this option is set to Do not override then the video's sharpness is not set.
Sharpness (tunable online)
The amount of details visible in the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Sharpness Override option is set to Override using dialog.
Gamma Override
Set this option to Override using dialog to enable the video's gamma to be controlled via the Gamma parameter. Set this option to Override using input port to enable the video's gamma to be controlled via external input port, gam. If this option is set to Do not override then the video's gamma is not set.
Gamma (tunable online)
The non-linear operation in coding luminance values of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Gamma Override option is set to Override using dialog.
Color Effect Override
Set this option to Override using dialog to enable the video's color effect to be controlled via the Color Effect parameter. Set this option to Override using input port to enable the video's color effect to be controlled via external input port, col. If this option is set to Do not override then the video's color effect is not set.
Color Effect (tunable online)
The color effect of the video, of various effects supported by the camera. This option is only enabled if the Color Effect Override option is set to Override using dialog.
White Balance Override
Set this option to Override using dialog to enable the video's white balance to be controlled via the White Balance parameter. Set this option to Override using input port to enable the video's white balance to be controlled via external input port, wbl. If this option is set to Do not override then the video's white balance is not set.
White Balance (tunable online)
The colour temperature of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the White Balance Override option is set to Override using dialog.
Backlight Compensation Override
Set this option to Override using dialog to enable the video's backlight compensation to be controlled via the Backlight Compensation parameter. Set this option to Override using input port to enable the video's backlight compensation to be controlled via external input port, bck. If this option is set to Do not override then the video's backlight compensation is not set.
Backlight Compensation (tunable online)
The backlight compensation of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Backlight Compensation Override option is set to Override using dialog.
Gain Override
Set this option to Override using dialog to enable the video's gain to be controlled via the Gain parameter. Set this option to Override using input port to enable the video's gain to be controlled via external input port, gain. If this option is set to Do not override then the video's gain is not set.
Gain (tunable online)
The multiplier to apply to the RGB colour values of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Gain Override option is set to Override using dialog.
Camera Properties Pane
The Camera Properties pane of the dialog appears as follows:
The Camera Properties tab contains the settings related to the camera hardware. The settings in this tab is only visible when the Source parameter is set to device.
Not all properties can be adjusted for all cameras. Whether a property can be adjusted depends on the camera driver support. If there is no effect after a particular setting is adjusted, this means that setting is not supported by the camera.
Pan Override
Set this option to Override using dialog to enable the video's pan to be controlled via the Pan parameter. Set this option to Override using input port to enable the video's pan to be controlled via external input port, pan. If this option is set to Do not override then the video's pan is not set.
Pan (tunable online)
The pan of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Pan Override option is set to Override using dialog.
Tilt Override
Set this option to Override using dialog to enable the video's tilt to be controlled via the Tilt parameter. Set this option to Override using input port to enable the video's tilt to be controlled via external input port, tilt. If this option is set to Do not override then the video's tilt is not set.
Tilt (tunable online)
The tilt of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Tilt Override option is set to Override using dialog.
Roll Override
Set this option to Override using dialog to enable the video's roll to be controlled via the Roll parameter. Set this option to Override using input port to enable the video's roll to be controlled via external input port, roll. If this option is set to Do not override then the video's roll is not set.
Roll (tunable online)
The roll of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Roll Override option is set to Override using dialog.
Zoom Override
Set this option to Override using dialog to enable the video's zoom to be controlled via the Zoom parameter. Set this option to Override using input port to enable the video's zoom to be controlled via external input port, zoom. If this option is set to Do not override then the video's zoom is not set.
Zoom (tunable online)
The zoom of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Zoom Override option is set to Override using dialog.
Exposure Override
Set this option to Override using dialog to enable the video's exposure to be controlled via the Exposure parameter. Set this option to Override using input port to enable the video's exposure to be controlled via external input port, exposure. If this option is set to Do not override then the video's exposure is not set.
Exposure (tunable online)
The exposure of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Exposure Override option is set to Override using dialog.
Iris Override
Set this option to Override using dialog to enable the video's iris to be controlled via the Iris parameter. Set this option to Override using input port to enable the video's iris to be controlled via external input port, iris. If this option is set to Do not override then the video's iris is not set.
Iris (tunable online)
The iris of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Iris Override option is set to Override using dialog.
Mirror Override (tunable offline)
Set this option to Override using dialog to enable the video's mirroring to be controlled via the Mirror parameter. Set this option to Override using input port to enable the video's mirroring to be controlled via external input port, mirroring. If this option is set to Do not override then the video's mirroring is not set.
Mirror (tunable online)
Use this option to mirror the image horizontally, vertically or both. Mirroring both horizontally and vertically is equivalent to rotating the image 180 degrees. This option is only enabled if the Mirror Override option is set to Override using dialog.
Focus Override (tunable offline)
Set this option to Override using dialog to enable the video's focus to be controlled via the Focus parameter. Set this option to Override using input port to enable the video's focus to be controlled via external input port, focus. If this option is set to Do not override then the video's focus is not set.
Focus (tunable online)
The focus of the video, from 0 to 100% of the full range supported by the camera. This option is only enabled if the Focus Override option is set to Override using dialog.
Targets
Target Name |
Compatible* |
Model Referencing |
Comments |
---|---|---|---|
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
Yes |
Yes |
||
No |
No |
Not currently supported. |
|
Yes |
Yes |
||
No |
No |
Not supported. |
|
No |
No |
Not supported. |
|
Rapid Simulation (RSIM) Target |
Yes |
Yes |
Fully supported. |
S-Function Target |
No |
N/A |
Old technology. Use model referencing instead. |
Normal simulation |
Yes |
Yes |
Fully supported. |
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.
Link to this page.