Download Target Tracking For Robot Collaboration

Transcript
C++ Code for image grabbing
CaptureVideoSimple.cpp
// CaptureVideo.cpp : implementation file
///--------------------------------------------------------------------------//
// Copyright DILLIP KUMAR KARA 2004
// You may do whatever you want with this code, as long as you include this
// copyright notice in your implementation files.
// Comments and bug Reports: codeguru_bank@yahoo.com
//--------------------------------------------------------------------------//
#include "stdafx.h"
#include "CaptureVideoSimple.h"
#include "header.h"
#include <math.h>
#include <SYS/timeb.h>
#include <wingdi.h>
#include <windows.h>
#include <winuser.h>
#include <time.h>
#include <AFXWIN.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define REGISTER_FILTERGRAPH
// define the ratio of focal length over pixel size
#define k3 (0.0521488*768/(32.0*1.e-3))
#define k4 (0.0521488*576/(26.6*1.e-3))
#define OutOfBorders(x,y,width1,width2,height1,height2) ((x)<(width1) || (y)<(height1) ||
(x)>=(width2) || (y)>=(height2))
long pBufferSize;
unsigned char* pBuffer;
unsigned int gWidth=0;
unsigned int gHeight=0;
unsigned int gChannels=0;
VIDEOINFOHEADER *pVih;
/////////////////////////////////////////////////////////////////////////////
// CCaptureVideo
CCaptureVideo::CCaptureVideo()
{
// Initialization
m_hApp=NULL;
m_dwGraphRegister=0;
nAnalogCount =0; // Counting Analog devices
m_pMC = NULL;
m_pME = NULL;
m_pGraph = NULL; // IFilterGraph2 provides AddSourceFileForMoniker()
m_pCapture = NULL;
pSrcF = NULL ;
60