Select region of interest (ROI) from pixel stream
The visionhdl.ROISelector
System object™ selects a portion of the active frame from a video stream. The total size
of the frame remains the same. The output control signals indicate a new active region
of the frame. This diagram shows the inactive pixel regions in blue and the requested
output region outlined in orange.
You can specify a fixed size and location for the ROI, or you can select the frame location dynamically by using an input argument. You can select more than one region. Define each region by specifying its upper-left corner coordinates and dimensions. The object returns one set of pixels and control signals for each region you specify. The object sets the inactive pixels in the output frame to zero.
Regions are independent from each other, so they can overlap. If you specify a region that includes the edge of the active frame, the object returns only the active portion of the region. This diagram shows the output frames for three requested regions. The second output region does not include the inactive region above the frame.
The object also provides a mode for vertical reuse. In this mode, you must specify
regions that have no vertical overlap and are aligned in columns. Each column of regions
shares one output pixel stream. The control signals define each region in the stream.
This arrangement enables parallel processing of each column, and the reuse of downstream
processing logic for each region in a column. To use this mode, set the
VerticalReuse
property to true
. Use the
visionhdlframetoregions
function to divide a frame into tiled regions
for vertical reuse.
To select regions of interest (ROIs) from a pixel stream:
Create the visionhdl.ROISelector
object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
ROI = visionhdl.ROISelector(Name,Value)
creates a System object that selects regions of the active frame from an input stream. Set
properties using one or more name-value pairs. Enclose each property name in single
quotes. For example,.ROI
= visionhdl.ROISelector(Name
,Value
)'Regions',[1 1 32 24]
configures the object
to select a 32-by-24 pixel region in the top-left corner of the frame.
[pixel1,ctrl1] = ROI(pixelIn,ctrlIn)
[pixel1,ctrl1,...,pixelN,ctrlN] = ROI(pixelIn,ctrlIn)
[pixel1,ctrl1,...,pixelN,ctrlN] = ROI(pixelIn,ctrlIn,region1,...,regionN)
[pixel1,ctrl1] = ROI(pixelIn,ctrlIn)
returns the next pixel
value, pixel1
, and control signals, ctrl1
,
resulting from masking the active image frame into a single new region. Define the
region by setting the Regions
property to a four-element row
vector, [hPos
vPos
hSize
vSize]
.
[pixel1,ctrl1,...,pixelN,ctrlN] = ROI(pixelIn,ctrlIn)
returns
the next pixel values, pixel1,...,pixelN
, and control signals,
ctrl1,...,ctrlN
, of each stream resulting from masking the
active image frame. When you set the VerticalReuse
property to
false
, each output stream contains one active region, and the
number of streams is the NumberOfRegions
property value or the
number of rows in the Regions
matrix. When you set the
VerticalReuse
property to true
, each
output stream contains a set of vertically-aligned regions. In both cases, define
the regions by setting the Regions
property to an
N-by-4 matrix of ROI coordinates.
[pixel1,ctrl1,...,pixelN,ctrlN] = ROI(pixelIn,ctrlIn,region1,...,regionN)
returns the next pixel values of each stream,
pixel1,...,pixelN
, resulting from masking the active image
frame into 1 to N new regions, as directed by the
region1,...,regionN
arguments. Each
region
input is a four-element row vector of ROI coordinates.
Use this syntax when you set the RegionsSource
property to
'Input Port'
, and the NumberOfRegions
property to N.
This object uses a streaming pixel interface with a structure
for frame control signals. This interface enables the object to operate independently of image
size and format, and to connect with other Vision HDL Toolbox™ objects. The object accepts and returns a scalar pixel value and control signals
as a structure containing five signals. The control signals indicate the validity of each pixel
and its location in the frame. To convert a pixel matrix into a pixel stream and control
signals, use the visionhdl.FrameToPixels
object. For a full
description of the interface, see Streaming Pixel Interface.
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)