How to configure face detection in Video Capture SDK .Net?

Related products
Video Capture SDK .Net

Sample code

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 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();
Please contact support to get help with this tutorial. Visit our GitHub page to get more code samples.
abstract 2abstract 1abstract 3
logo
VisioForge © 2006 - 2021