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

VS2019 VC++ - How to use VideoCap Pro SDK ActiveX

Step 1: Install the VideoCap Pro SDK ActiveX, begin by launching the setup file (https://www.viscomsoft.com/demo/videocapprosetup.exe). Select the desired installation folder for the VideoCap Pro SDK ActiveX and continue with the installation on your development computer.

Step 2: Create New C++ MFC App, select Next button.

Step 3: Enter your project name and select project location, select Next button.

Step 4: Select Dialog based in Application type ,  select Next button.

Step 5: Select Solution Explorer, double click MFCApplication1.rc

Step 6: double click IDD_MFCAPPLICATION1_DIALOG in Dialog, then open the UI.  In Toolbox, Right Click Mouse and select Choose Item...

 

Step 7: Select COM Components Tab, select VideoCap Pro Control, click OK button to confirm.

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

Step 9: In Windows explorer, copy all files from C:Program Files (x86)VideoCap Pro ActiveX ControlVS2019VC-VideoCapProClass folder to your project folder.

 

Step 10: In Solution Explorer, select  Header Files folder, then add videocap.h



Step 11: In Solution Explorer, select  Source Files folder, then add videocap.cpp


 

Step 12: add #include "videocap.h"  and CVideoCap  m_VideoCap in MFCApplication1Dlg.h

Step 13: add DDX_Control(pDX, IDC_VIDEOCAPCTRL1,m_VideoCap);
to DoDataExchange method in MFCApplication1Dlg.cpp


Step 14: add button on form and remove another button


Step 15: double click the Preview button and add the following code in this handler. It will preview the first video device
m_VideoCap.Start();


Step 16:  double click IDD_MFCAPPLICATION1_DIALOG in Dialog, add two combo box on form.
set Combo Box Type property to Drop List and set Sort property to False

 
Step 17:  In Solution Explorer, select  Header Files folder, then add devices.h, videoformats.h


Step 18:  In Solution Explorer, select Source Files folder, then add devices.cpp, videoformats.cpp


Step 19:  In MFCApplication1Dlg.h, add the following code
#include "devices.h"
#include "videoformats.h"


Step 20:  double click  IDD_MFCAPPLICATION1_DIALOG in Resource View, select Video Device combo box, right click mouse, select Class Wizard...


Step 21:  select Member Variables tab, make sure selected IDC_CBOVIDEODEVICE, click Add Variable..., enter m_CboVideoDevice in Name field, then click Finish button.

 

Step 22:   make sure selected IDC_CBOVIDEOFORMAT, click Add Variable...


Step 23:  enter m_CboVideoFormat in Name field, then click Finish button.


Step 24:  In Class Wizard, select Virutal Functions tab, select OnInitDialog, click Add Function, then click Edit code.

Step 25:  add the following code in OnInitDialog()

int iDeviceCount = m_VideoCap.GetDevices().GetCount();
CString strDeviceName;
for (int i = 0; i < iDeviceCount; i )
{
strDeviceName = m_VideoCap.GetDevices().FindDeviceName(i);
m_CboVideoDevice.AddString(strDeviceName);
}
if (m_CboVideoDevice.GetCount() > 0)
m_CboVideoDevice.SetCurSel(0);

Step 26:  add the following code in OnInitDialog()

////////////////////video format
int iVideoFormatCount = m_VideoCap.GetVideoFormats().GetCount();
CString strVideoFormat;
for (int i = 0; i < iVideoFormatCount; i )
{
strVideoFormat = m_VideoCap.GetVideoFormats().FindVideoFormatName(i);
m_CboVideoFormat.AddString(strVideoFormat);
}
if (m_CboVideoFormat.GetCount() > 0)
m_CboVideoFormat.SetCurSel(0);


Step 27:  update the following code  of Preview button click handler

int iDeviceIndex = m_CboVideoDevice.GetCurSel();
int iVideoFormatIndex = m_CboVideoFormat.GetCurSel();
if (iDeviceIndex != -1)
m_VideoCap.SetDevice(iDeviceIndex);
if (iVideoFormatIndex != -1)
m_VideoCap.SetVideoFormat(iVideoFormatIndex);
m_VideoCap.Start();

Step 28:  In Class Wizard, selected IDC_VIDEODEVICE, selected CBN_SELCHANGE, click Add Handler... , then click Edit Code, add the followint code , it can refresh the video format combo box when you changed the video device combo box item.




int iVideoFormatCount = m_CboVideoFormat.GetCount();
for (int i = 0; i < iVideoFormatCount; i )
m_CboVideoFormat.DeleteString(0);
m_VideoCap.RefreshVideoDevice(m_CboDevice.GetCurSel());
iVideoFormatCount = m_VideoCap.GetVideoFormats().GetCount();
CString strVideoFormat;
for (int i = 0; i < iVideoFormatCount; i )
{
strVideoFormat = m_VideoCap.GetVideoFormats().FindVideoFormatName(i);
m_CboVideoFormat.AddString(strVideoFormat);
}
if (m_CboVideoFormat.GetCount() > 0)
m_CboVideoFormat.SetCurSel(0);



Step 29:  Finally you can run the project. Preview the video from video device.

 


Step 30:  Download this project sample source code. Select compile in X86.