Skip to main content

How to configure face detection?

Products: Video Capture SDK .Net

1. Configure your video source: webcam, IP camera, or something else. Set preview or capture mode to use

2. Set face tracking settings

VideoCapture1.Face_Tracking = new FaceTrackingSettings
{
ColorMode = CamshiftMode.RGB,
Highlight = true,
MinimumWindowSize = 25,
ScalingMode = ObjectDetectorScalingMode.GreaterToSmaller,
SearchMode = ObjectDetectorSearchMode.Single
};

3. Add the OnFaceDetected event to catch faces and fill the text box with coordinates

public delegate void FaceDelegate(AFFaceDetectionEventArgs e);

public void FaceDelegateMethod(AFFaceDetectionEventArgs e)
{
edFaceTrackingFaces.Text = string.Empty;

foreach (var faceRectangle in e.FaceRectangles)
{
edFaceTrackingFaces.Text += "(" + faceRectangle.Left + ", " + faceRectangle.Top + "), ("
+ faceRectangle.Width + ", " + faceRectangle.Height + ")" + Environment.NewLine;
}
}

4. Start preview or capture, depending on step 1

async VideoCapture1.StartAsync();

Required redists

How to install the required redists or deploy them to the user's PC?


Visit our GitHub page to get more code samples.