# Visual C++ & C++ Programming > C++ and WinAPI >  capture video from 2 webcams

## Vilnor

can you tell me how to make a program in c++ builder 5
which captures images from 2 or 3 webcams at the same time

----------


## salem_c

I'd start here and do lots of reading.
https://learn.microsoft.com/en-us/wi...-video-capture

Before you start with 2 or 3 cameras, what do you know about capturing one camera?

> c++ builder 5
https://winworldpc.com/product/borland-c-builder/5x
I'd say get a compiler that wasn't 20 years old.
Chances are, it's pretty clueless about all the new features in window 7,8,10,11.

----------


## Vilnor

LRESULT CALLBACK capErrorCallback(HWND hWnd,  int nID,  LPCSTR lpsz)
{  return 1;}

LRESULT PASCAL capOnFrameCallback(HWND hWnd, LPVIDEOHDR lpVHdr)
{ return OnFrame(lpVHdr);}

LRESULT CALLBACK capStatusCallback(HWND hWnd,  int nID,  LPCSTR lpsz)
{  return 1;}

LRESULT CALLBACK capVideoStreamCallback(HWND hWnd,  LPVIDEOHDR lpVHdr)
{  return 1;}

LRESULT CALLBACK capWaveStreamCallback(HWND hWnd,  LPWAVEHDR lpWHdr)
{  return 1;}


LRESULT CALLBACK capYieldCallback(HWND hWnd)
{  return 1;}

LRESULT CALLBACK capControlCallback(HWND hWnd,  int nState)
{  return 1;}

bool InstallCallback(HWND h)
{
  int res=1;
  res&=capSetCallbackOnCapControl (h, capControlCallback);
  res&=capSetCallbackOnError      (h, capErrorCallback);
  res&=capSetCallbackOnFrame      (h, capOnFrameCallback);
  res&=capSetCallbackOnStatus     (h, capStatusCallback);
  res&=capSetCallbackOnVideoStream(h, capVideoStreamCallback);
  res&=capSetCallbackOnWaveStream (h, capWaveStreamCallback);
  res&=capSetCallbackOnYield      (h, capYieldCallback);
  return res;
}

HWND ACaptureWindowCreate(void)
{
  for (int wIndex = 0; wIndex < 10; wIndex++)
  {
    res=capGetDriverDescription(wIndex, szDeviceName   [wIndex], 80,
                                        szDeviceVersion[wIndex], 80);
    if(res) NumberDrivers++, DriverNumber=wIndex;
  }
  res=1;
  if(NumberDrivers==0){ShowMessage("Capture driver not found.");}
  return capCreateCaptureWindow("VideoCap",WS_CHILD/*|WS_VISIBLE*/,
                                  0,0, 10, 10, Form1->Handle, 0);
}

----------


## Vilnor

int SetCaptureParameters(HWND VideoCap)
{
  res=1;
  Form1->Panel1->Caption=IntToStr(DriverNumber);
  res&=capDriverConnect(VideoCap, DriverNumber);
  res&=capDriverGetCaps(VideoCap, &CapDrvCaps, sizeof (CAPDRIVERCAPS));
  if(CapDrvCaps.fHasOverlay)capOverlay(VideoCap, 1);
  res&=capCaptureGetSetup(VideoCap, &cp, sizeof(CAPTUREPARMS));
  cp.dwRequestMicroSecPerFrame=40000;
  cp.fMakeUserHitOKToCapture=1;
  cp.fCaptureAudio=0;
  cp.fYield=1;
  cp.fAbortLeftMouse=0;
  cp.fAbortRightMouse=0;
  res&=capCaptureSetSetup(VideoCap, &cp, sizeof(CAPTUREPARMS));
  res&=InstallCallback(VideoCap);
  if(res==0){ShowMessage("Video camera not connected to the PC."); return 0; }
  else      {DevEnabled=1;                                         return 1; }
}

----------

