VideoCap Pro SDK ActiveX

VideoCap Pro SDK ActiveX

Platform : Windows 10, Windows 8, Vista, Windows 7, XP

For Windows Developers who need to view IP Camera, add video capture with overlay text, image, chroma key effect, face detection, motion detection with C++ , C#, VB.NET , VB, Delphi, Vfp, Ms Access, Labview.

Popular Solution Go   Back

C# - How to Face Detection using C#

Step 1: To install the VideoCap Pro ActiveX Control, begin by launching the setup file (videocapproetup.exe). Select the desired installation folder for the VideoCap Pro ActiveX and continue with the installation on your development computer.

Step 2: Create New Visual C# Project, select Windows Application. 


 Step 3: The next step is to install VideoCap Pro ActiveX in ToolBox. Select Toolbox, select Components item, right click mouse button, select Choose Items...

 
 
 
Step 4: Select COM Components tab, select VideoCap Pro ActiveX Control , click OK.
 

Step 5: Now you will see the VideoCap Pro ActiveX's icon on toolbox, drag it to form. 

 Step 6: Design the UI same as following
 
 
Step 7: Later you will call EffectFaceTemplateFile method, it need face template file. Now you need add face template to project.  You may download from haarcascade_frontalface_alt.zip . Unzip the file and right-click the project in the Solution Explorer and select Add - Existing Item... , Select All Files (*.*) in combo box, select haarcascade_frontalface_alt.xml.
It will added to project.

 
 Step 8: select haarcascade_frontalface_alt.xml in Solution Explorer, In Properties windows, select Copy to Output Directory = Copy always

 Step 9: When pressing "Preview" button. Our sample code will call
 axVideoCap1.EffectType =  VIDEOCAPLib.MYVIDEOCAPEFFECTTYPE.VIDEOFX;
 axVideoCap1.EffectFxType = 4;
 axVideoCap1.EffectFaceTemplateFile("haarcascade_frontalface_alt.xml");
 axVideoCap1.Start();

 you must set EffectType and EffectFxType to correct value if you want to use Face Detection.
 EffectFaceTemplateFile must point to correct location of haarcascade_frontalface_alt.xml file. 
 If haarcascade_frontalface_alt.xml in another folder. You may  call  axVideoCap1.EffectFaceTemplateFile("c:\yourfolder\haarcascade_frontalface_alt.xml");
 Otherwise you will not see the track box on video and FaceDetected event will not fired.
 
Step 10: If face detected, it will fired FaceDetected event. Now show you how to add FaceDetected event.
double click the VideoCap Pro ActiveX Control on your form.  It will enter Capturing event handler 
 
Step 11: In Solution Explorer, select Form1.cs - Form1.Designer.cs , It will open Form1.Designer.cs
click [plus] icon in InitializeComponent section


Step 12: Find the "this.axVideoCap1.Capturing" string and add the following code

this.axVideoCap1.FaceDetected = new AxVIDEOCAPLib._DVideoCapEvents_FaceDetectedEventHandler(this.axVideoCap1_FaceDetected);
 

Step 13: Open Form1.cs and add following function

private void axVideoCap1_FaceDetected(object sender, AxVIDEOCAPLib._DVideoCapEvents_FaceDetectedEvent e)
 {

            listBox1.Items.Add("Face Detected");

  }
 

Step 14: Now if the face detected, it will fired  FaceDetected Event and add Face Detected item on listbox
 

Step 15: Download the sample source code from face_detectioncsharip.zip