⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minigrabsamplemfc.cpp

📁 BCAM 1394 Driver
💻 CPP
字号:
//-----------------------------------------------------------------------------
//  (c) 2002 by Basler Vision Technologies
//  Section:  Vision Components
//  Project:  BCAM
//  $Header: MiniGrabSampleMfc.cpp, 2, 17.09.2002 17:06:20, Nebelung, H.$
//-----------------------------------------------------------------------------
/**
\file     MiniGrabSampleMfc.cpp
\brief    Defines the entry point for the console application.
*/

#include "stdafx.h"
#include "MiniGrabSampleMfc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
  int nRetCode = 0;
  
  // initialize MFC and print and error on failure
  if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  {
    cerr << _T("Fatal Error: MFC initialization failed") << endl;
    nRetCode = 1;
  }
  else if (CBcam::DeviceNames().size() == 0)
  {
    cerr << _T("No camera present!") << endl;
    nRetCode = 2;
  }
  else
  {
    // Get the devicename of the first camera
    CString DeviceName = *(CBcam::DeviceNames().begin());
    
    
    // Create the driver object and open the driver
    CBcam Bcam;
    Bcam.Open(DeviceName);
    
    // Setting VideoFormat=0, VideoMode=5 yields 640 x 480, Mono8
    Bcam.SetVideoMode(DCS_Format0, DCS_Mode5, DCS_15fps);
    
    // Create image buffer
    const int ImageSize = 640 * 480;
    char *pBuffer = new char[ImageSize];
    
    // Allocate Resources (MaxBuffers, MaxBufferSize)
    Bcam.AllocateResources(1, ImageSize);
    
    // Grab the image
    Bcam.GrabImage(pBuffer, ImageSize, 3000 );  // timeout 3 sec.
    
    // image processing...
    
    // clean up
    delete[] pBuffer;
    
  }
  
  return nRetCode;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -