LabTalk Object Type:
The vr object reads a video file and imports frame (or frames) of video to matrix object/matrixbook.
Method | Description |
---|---|
vr.Open(fname) |
Open a video with the specified file name (include the complete file path)
Return value:
|
vr.SeekFrame(frameOffset, nOrigin) |
Move the pointer associated with the video to a new location that is framesOffset frames from nOrigin.
nOrigin values:
|
vr.SeekTime(msecOffset, nOrigin) |
Move the pointer associated with the video to a frame that locates msecOffset milliseconds after nOrigin.
nOrigin values
|
vr.ReadFrame([dataset]) | Import a frame to the specified dataset. If the dataset is not given then the active one is used. |
vr.ReadFrame(MBookName, layerIndex, objectIndex) | Import a frame to the specified matrix object [MBookName]LayerIndex!"ojectIndex". |
vr.ReadFrames(MBookName, frameCount, skipFrames) | Import frameCount frames to the first matrixsheet of MBookName, skipping every skipFrames frames. Each frame is imported into a matrix object. |
vr.Close( ) |
Close the video.
Return value:
|
All Vr properties are read-only.
Property | Access | Description |
---|---|---|
Vr.FourCC |
Read only
numeric |
A number corresponding to the video's four character code. |
Vr.FourCC$ |
Read only
string |
Four character code used to identify the video codec. |
Vr.Format |
Read only
numeric |
OpenCV format code. See below Channel properties for extracted info:
Channels: number of channels per frame ChannelBits: bits per channel ChannelInt: channel data integer values ChannelSigned: channel data signed values Note: the format and channel properties are based on the lastly read frame. |
Vr.Channels |
Read only
numeric |
Number of channels per frame |
Vr.ChannelBits |
Read only
numeric |
Bits per channel |
Vr.ChannelInt |
Read only
numeric |
Channel data integer values |
Vr.ChannelSigned |
Read only
numeric |
Channel data signed values |
Vr.FPS |
Read only
numeric |
Frames per second |
Vr.FrameCount |
Read only
numeric |
Number of frames in the video file |
Vr.Width |
Read only
numeric |
Video width in pixels |
Vr.Height |
Read only
numeric |
Video height in pixels |
Vr.PosFrames |
Read only
numeric |
Current position in frame |
Vr.PosMSec |
Read only
numeric |
Current position in millisecond |
This script shows how to import 1 out of every 15 frames into the active matrixbook, each frame to a matrix object.
string vfilename$ = "C:\test.mp4"; int StepSize = 15; // skip every 15 frames int err = vr.Open(%(vfilename$));// Open the video file. if( 0 == err ) { int TotalFrames = vr.FrameCount/StepSize; // Read from beginning to the end of the file into matrix. vr.ReadFrames(%h, TotalFrames, StepSize); vr.Close();// Close the video file. };
There is also a full example of how to import 100 frames from a video into a new matrixbook.