Main Content

visionhdl.MeasureTiming

Measure timing of pixel control structure input

Description

The visionhdl.MeasureTiming object measures the timing parameters of a video stream. The Vision HDL Toolbox™ streaming pixel protocol implements the timing of a video system, including inactive intervals between frames. These inactive intervals are called blanking intervals. Many Vision HDL Toolbox objects require minimum blanking intervals. You can use the timing parameter measurements from this object to check that your video stream meets these requirements. If you manipulate the control signals of your video stream, you can use this object to verify the resulting control signals. To determine the parameters of each frame, the object measures time steps between the control signals in the input structure.

For details on the pixel control bus and the dimensions of a video frame, see Streaming Pixel Interface.

Note

Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Construction

measure = visionhdl.MeasureTiming returns a System object, measure, that measures the average frame timing of a video stream.

Methods

stepMeasure timing of pixel control structure input
Common to All System Objects
release

Allow System object property value changes

Examples

collapse all

This example shows how to use the MeasureTiming object to observe the frame parameters in a custom video stream. The example creates customized padding around an image frame and converts the frame to streaming video. It uses the MeasureTiming object to confirm that the streaming video parameters match the custom settings.

Use a FrameToPixels object to specify a small custom-size frame with customized blanking intervals. To obtain a frame of this size, select a small section of the input image.

frm2pix = visionhdl.FrameToPixels(...
      'VideoFormat','custom',...
      'ActivePixelsPerLine',32,...
      'ActiveVideoLines',18,...
      'TotalPixelsPerLine',42,...
      'TotalVideoLines',26,...
      'StartingActiveLine',6,...     
      'FrontPorch',5);    
[actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);  

frmFull = imread('rice.png');
frmIn = frmFull(74:73+actLine,104:103+actPixPerLine);
imshow(frmIn)

Create a MeasureTiming object to observe the parameters of the serial pixel output from the FrameToPixels object.

measure = visionhdl.MeasureTiming;

Serialize the input frame.

[pixInVec,ctrlInVec] = frm2pix(frmIn);

Some parameters require measurements between frames, so you must simulate at least two frames before using the results. Because you serialized only one input frame, process that frame twice to measure all parameters correctly.

for f = 1:2
      for p = 1:numPixPerFrm
          [activePixels,activeLines,totalPixels,totalLines,...
              horizBlank,vertBlank] = measure(ctrlInVec(p));
      end
      fprintf('\nFrame %d:\n',f)
      fprintf('activePixels: %f\n',activePixels)
      fprintf('activeLines: %f\n',activeLines)
      fprintf('totalPixels: %f\n',totalPixels)
      fprintf('totalLines: %f\n',totalLines)
      fprintf('horizBlank: %f\n',horizBlank)
      fprintf('vertBlank: %f\n',vertBlank)
end
Frame 1:
activePixels: 32.000000
activeLines: 18.000000
totalPixels: 42.000000
totalLines: 22.880952
horizBlank: 10.000000
vertBlank: 4.880952
Frame 2:
activePixels: 32.000000
activeLines: 18.000000
totalPixels: 42.000000
totalLines: 26.000000
horizBlank: 10.000000
vertBlank: 8.000000

The measurements after the first frame are not accurate. However, after the second frame, the measurements match the parameters chosen in the FrameToPixels object.

Introduced in R2016b