Class GPUVideoEffectContour
- Namespace
- VisioForge.Core.Types.VideoEffects
- Assembly
- VisioForge.Core.dll
Represents a GPU-accelerated contour detection video effect that identifies and highlights edges and boundaries in video frames.
public class GPUVideoEffectContour : GPUVideoEffect, IGPUVideoEffectContour, IGPUVideoEffectInheritance
Implements
Inherited Members
Remarks
The VisioForge.Core.Types.VideoEffects.GPUVideoEffectContour effect applies edge detection algorithms to identify areas of rapid intensity change in video frames, creating a line-drawing or sketch-like appearance. This effect is commonly referred to as edge detection, contour extraction, or outline detection. The algorithm analyzes luminance gradients to detect boundaries between objects, producing a stylized representation that emphasizes shapes and structures while removing texture and color information.
SDK Availability
- Video Capture SDK .Net: Yes
- Video Edit SDK .Net: Yes
- Media Player SDK .Net: Yes
- Media Blocks SDK .Net: Yes
GPU Acceleration
This effect utilizes GPU shader programs to perform convolution-based edge detection in real-time. The shader applies edge detection kernels (such as Sobel, Prewitt, or Laplacian operators) to compute gradient magnitudes across the image. Parallel processing on the GPU enables simultaneous edge detection for all pixels, maintaining real-time frame rates even at 4K resolution. The implementation leverages texture sampling hardware for efficient neighbor pixel access.
Technical Details
- Computes luminance gradients using convolution kernels
- Detects horizontal and vertical edges simultaneously
- Typically uses Sobel, Prewitt, or similar edge detection operators
- Results in white edges on black background (or inverted)
- Emphasizes areas of high contrast and rapid intensity change
- Removes color information, producing monochrome edge map
- Real-time GPU processing with hardware-accelerated convolution
Common Use Cases
- Creating artistic sketch or line-drawing effects from video
- Preprocessing for computer vision and object recognition tasks
- Generating stylized content for animations and motion graphics
- Creating rotoscoping guides for animation workflows
- Producing comic book or cel-shaded art styles
- Emphasizing shapes and structures in technical or educational videos
- Creating outline overlays for creative video compositions
Performance Characteristics
The contour effect is computationally efficient despite requiring multiple texture samples per pixel for convolution. GPU texture cache and parallel processing ensure real-time performance at high resolutions. The effect can be applied to multiple video streams simultaneously without performance degradation. Memory overhead is minimal as the effect operates on a single input frame without requiring temporal buffers.
Edge Detection Algorithm
The effect typically employs Sobel or similar gradient-based edge detection. The algorithm computes first-order derivatives of image intensity using 3x3 convolution kernels in horizontal and vertical directions. The gradient magnitude is calculated from these directional derivatives, producing edge strength values. Pixels with high gradient magnitudes are classified as edges and rendered as white (or foreground color), while low-gradient areas are rendered as black (or background color).
Visual Characteristics
- Monochrome output (typically white edges on black background)
- Strong emphasis on object boundaries and silhouettes
- Fine detail preservation in high-contrast areas
- Removal of texture and color information
- Continuous edge lines following object contours
- Sensitivity to lighting and contrast in source video
Integration Tips
For best results, apply this effect to video with good lighting and clear subject separation. The contour detection is most effective on footage with distinct edges and moderate-to-high contrast. For creative applications, combine with VisioForge.Core.Types.VideoEffects.GPUVideoEffectInvert to create black lines on white background for coloring book effects. Use VisioForge.Core.Types.VideoEffects.GPUVideoEffectContrast adjustment before contour detection to enhance edge visibility in low-contrast source material. The effect can be used as a mask or overlay layer when compositing with original footage.
Artistic Applications
- Combine with original footage for partial edge overlay effects
- Invert colors for pen-and-ink drawing aesthetics
- Use as mask for selective color application (cel-shading)
- Create animated coloring book or storyboard effects
- Generate rotoscope guides for traditional animation
Computer Vision Applications
Beyond artistic use, the contour effect serves as preprocessing for computer vision tasks. Edge maps facilitate object detection, shape analysis, and feature extraction. When used in vision pipelines, consider that GPU-based edge detection provides immediate feedback for real-time analysis but may differ slightly from CPU-based OpenCV implementations due to algorithm variations and precision differences.
Related Effects
- VisioForge.Core.Types.VideoEffects.GPUVideoEffectEmboss: Creates 3D relief effect using similar gradient computation
- VisioForge.Core.Types.VideoEffects.GPUVideoEffectSharpen: Enhances edges while preserving color information
- VisioForge.Core.Types.VideoEffects.GPUVideoEffectGrayscale: Converts to monochrome without edge detection
- VisioForge.Core.Types.VideoEffects.GPUVideoEffectInvert: Inverts contour colors for different aesthetic
- VisioForge.Core.Types.VideoEffects.GPUVideoEffectContrast: Preprocessor to enhance edge detection quality
Constructors
GPUVideoEffectContour(bool, string, TimeSpan, TimeSpan)
Initializes a new instance of the VisioForge.Core.Types.VideoEffects.GPUVideoEffectContour class with specified timing parameters.
public GPUVideoEffectContour(bool enabled, string name = "Contour", TimeSpan startTime = default, TimeSpan stopTime = default)Parameters
enabledbool-
true to enable the contour effect immediately; false to create the effect in a disabled state. The effect can be enabled or disabled later using the VisioForge.Core.Types.VideoEffects.GPUVideoEffect.Enabled property.
namestring-
A unique identifier for this effect instance. Defaults to "Contour". This name can be used to retrieve the effect interface from the effect collection for runtime control and modification. Use descriptive names when applying multiple instances (e.g., "EdgeDetect", "SketchEffect", "OutlineOverlay").
startTimeTimeSpan-
The time position in the video timeline when this effect should become active. Use Zero (the default) to apply the effect from the beginning of the video. This enables time-based effect control for creating sequences that transition between photorealistic and sketch-like appearances.
stopTimeTimeSpan-
The time position in the video timeline when this effect should become inactive. Use Zero (the default) to apply the effect until the end of the video. When combined with
startTime, this creates time-windowed effects that automatically activate and deactivate at specific timestamps.
Remarks
The contour effect applies GPU-accelerated edge detection to create a line-drawing or sketch-like appearance. The algorithm computes luminance gradients using convolution kernels to identify areas of rapid intensity change, producing white edges on a black background. All processing occurs on the GPU for real-time performance. Time-based activation enables dynamic transitions between normal video and contour-detected output.
Methods
GetEffectType()
Gets the specific GPU video effect type identifier for this contour detection effect.
public GPUVideoEffectType GetEffectType()Returns
- GPUVideoEffectType
-
Returns VisioForge.Core.Types.VideoEffects.GPUVideoEffectType.Contour, which uniquely identifies this effect as an edge detection/contour extraction effect in the GPU video effects pipeline.
Remarks
This method is used internally by the video processing pipeline to identify and route effects to the appropriate GPU shader implementations. The effect type determines which edge detection shader program is executed for computing gradient-based contours.