Graphic overlays

Prev

Next

Example

 





































































































Graphics and text overlays.

Description

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

You can 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.
You will find the sample code in the "MainForm" of the MainDemo project included in te package -> search for "FrameBitmap"
From this event you should 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.
If you need 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.



See Also
TCardinalDirection TOnFrameOverlayUsingDC TOnFrameOverlayUsingDIB TTextOverlayAlign AdjustOverlayAspectRatio DrawBitmapOverFrame GetFrameInfoString ImageOverlay_StretchToVideoSize MouseWheelEventEnabled OnFrameBitmap OnFrameBitmapEventSynchrone OnFrameOverlayUsingDC OnFrameOverlayUsingDIB OnFrameOverlayUsingVIDEOHDR OnMouseDown OnMouseMove OnMouseUp OnMouseWheel OverlayAfterTransform RefreshPlayerOverlays SetImageOverlay_AlphaBlend SetImageOverlay_AlphaBlendValue SetImageOverlay_ChromaKey SetImageOverlay_ChromaKeyLeewayPercent SetImageOverlay_ChromaKeyRGBColor SetImageOverlay_Enabled SetImageOverlay_Height SetImageOverlay_LeftLocation SetImageOverlay_RotationAngle SetImageOverlay_StretchToVideoSize SetImageOverlay_TargetDisplay SetImageOverlay_TopLocation SetImageOverlay_Transparent SetImageOverlay_TransparentColorValue SetImageOverlay_UseTransparentColor SetImageOverlay_Width SetImageOverlayFromBMPFile SetImageOverlayFromHBitmap SetImageOverlayFromHBitmap2 SetImageOverlayFromImageFile SetImageOverlayFromImageFile2 SetImageOverlayFromJPEGFile SetImageOverlayFromTBitmap SetImageOverlayFromTBitmap2 SetImageOverlayFromTImage SetImageOverlayFromTImage2 SetTextOverlay_Align SetTextOverlay_BkColor SetTextOverlay_CustomVar SetTextOverlay_Enabled SetTextOverlay_Font SetTextOverlay_FontColor SetTextOverlay_GradientColor SetTextOverlay_GradientMode SetTextOverlay_HighResFont SetTextOverlay_Left SetTextOverlay_Right SetTextOverlay_Scrolling SetTextOverlay_ScrollingSpeed SetTextOverlay_Shadow SetTextOverlay_ShadowColor SetTextOverlay_ShadowDirection SetTextOverlay_String SetTextOverlay_TargetDisplay SetTextOverlay_Top SetTextOverlay_Transparent ShapeOverlay ShapeOverlayEnabled ShapeOverlayList TextOverlay_Align TextOverlay_BkColor TextOverlay_CreateCustomFont TextOverlay_CreateCustomFont2 TextOverlay_Enabled TextOverlay_Font TextOverlay_FontColor TextOverlay_Left TextOverlay_Right TextOverlay_Scrolling TextOverlay_ScrollingSpeed TextOverlay_Selector TextOverlay_Shadow TextOverlay_ShadowColor TextOverlay_ShadowDirection TextOverlay_String TextOverlay_Top TextOverlay_Transparent TranslateMouseCoordinates