Skip to content

Graphic overlays

Frame overlay When the frame grabber is enabled, it is possible to perform graphics or text overlay over uncompressed RGB video frames during preview, recording or playback.

For the graphics and text overlays to be applied over the video frames recored in the AVI during recording, the RecordingInNativeFormat property must be disabled.

Getting direct access to the current video frame bitmap

It is possible to get direct access to each video frame by using the OnFrameBitmap event, that occurs for each video frame. Click here for more information about this event.

The sample code is available in the "MainForm" of the MainDemo project included in te package -> search for "FrameBitmap"

From this event do not perform any actions with the potential to block:

  1. do not hold a critical section or wait on another thread,

  2. do not call any GDI or USER32.DLL APIs that might cause a window to move,

  3. do not invoke component properties that send messages, e.g. do not read the ItemIndex property of a ListBox component.

To read a such property, set an intermediary variable when the property changes, and then read the intermediary variable from the OnFrameOverlay... event.

Restrictions

a. when the video is recorded in "native" format (RecordingInNativeFormat = true), drawing over video frames will be visible on the preview stream but not on the AVI stream (native means "unmodified"),

b. during preview or recording of video capture boards having a video port (e.g. like ATI Radeon), drawing over video frames will not be visible on the preview stream when the video port is enabled.

Therefore:

  1. for the overlays to be visible on the preview window, disable the video port (but depending of the video capture device the preview could be jerky when previewing large video sizes (or in full screen mode),

  2. in order to include the frame overlay in the recorded stream, disable RecordingInNativeFormat (however this requires higher CPU consumption during recording, because the video stream can have to be uncompressed before applying the overlays).

Drawing bitmaps over video frames

Bitmaps can be drawn "as is" or stretched over video frames by invoking the DrawBitmapOverFrame function.

This function includes the transparency and alpha blending features.

It MUST be called only from the OnFrameBitmap event, that occurs for each video frame.

Drawing a shape over the video frames **(not available in the OCX versions) To draw a shape over video frames:

  • put a TShape component on the form,

  • assign the TShape component to the ShapeOverlay property,

  • disable the TShape's visible property to avoid the shape being visible at runtime,

  • enable ShapeOverlayEnabled to activate drawing shapes over video frames,

  • at runtime, define the TShape's Left, Top, Width and Height properties, that will be used used by TVideoGrabber to position and resize the shape over video frames.

Drawing several shapes over video frames **(not available in the OCX versions) To draw several shapes over video frames:

  • put TShape components on the form (e.g. Shape1 and Shape2),

  • call VideoGrabber1.ShapeOverlayList (Shape1, true) to add the 1st shape to the TVideoGrabber's shape list,

  • call VideoGrabber1.ShapeOverlayList (Shape2, true) to add the 2nd shape to the TVideoGrabber's shape list,

  • disable the Shape1 and Shape2 visible properties to avoid the shape being visible at runtime,

  • enable ShapeOverlayEnabled to activate drawing shapes over video frames,

  • at runtime, define the Shape1 and Shape2's Left, Top, Width and Height properties, that will be used used by TVideoGrabber to position and resize the shapes over video frames.

Note: Shapes are not drawn if their Enabled property is disabled.