bcameraset.cpp

来自「该程序实现FIRE足球机器人竞赛中的3:3比赛源码」· C++ 代码 · 共 148 行

CPP
148
字号
// BCameraSet.cpp: implementation of the CBCameraSet class.
//
//////////////////////////////////////////////////////////////////////

//#include "stdafx.h"
//#include "A101Viewer.h"
//#include "BCameraSet.h"

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


#include "stdafx.h"
//#include "mainfrm.h"
#include "BCameraSet.h"
//#include "CameraManager.h"
//#include "ChildFrm.h"
//#include "utility.h"
#include "ColorConversion.h"
//#include "CreateCorrectionTable.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CBCameraSet::CBCameraSet()
{
	// initialize LUTs for Bayer to RGB conversion
	m_GainR = 1.0 ;
	m_GainB = 1.0 ;
	SetRGain(m_GainR);
	SetBGain(m_GainB);
	for ( int i = 0; i < 256; i++ )
	{
		m_pLutG[i] = i;
	}

	m_ColorCode = DCSColor_Mono8;//DCSColor_Raw8;//
	//m_ColorCode = DCSColor_Raw8;
	m_ConvertMono8ToRGB = 4;
}

CBCameraSet::~CBCameraSet()
{

}




//------------------------------------------------------------------------------
// void CCamera::SetBGain(double gain)
// Author: 
//------------------------------------------------------------------------------
/**
* Set the gain for the blue channel and recalculate the according LUT for the conversion
* routine
*
* \param     gain
* \return    
*
*/
//------------------------------------------------------------------------------

void CBCameraSet::SetBGain(double gain)
{
  assert ( gain > 0 );
  for ( int i = 0; i < 256; i++ )
  {
    m_pLutB[i] = min(255, i * gain ) ;
  }
  m_GainB = gain;

}

//------------------------------------------------------------------------------
// void CCamera::SetRGain(double gain)
// Author: 
//------------------------------------------------------------------------------
/**
* Set the gain for the red channel and recalculate the according LUT for the conversion
* routine
*
* \param     gain
* \return    
*
*/
//------------------------------------------------------------------------------


void CBCameraSet::SetRGain(double gain)
{
  assert ( gain > 0 );
  for ( int i = 0; i < 256; i++ )
  {
    m_pLutR[i] = min(255, i * gain ) ;
  }
  m_GainR = gain;
}


//------------------------------------------------------------------------------
// void CCamera::ConvertBitmap(CBcamBitmap* *ppDest, CBcamBitmap* *ppSource)
// Author: 
//------------------------------------------------------------------------------
/**
* If required, convert raw Bayer8 or YUV422 data into a 24 bit RGB bitmap
*
* \param     *ppDest
* \param     *ppSource
* \return    
*
* <type Return description here>
* 
* \see       <delete line if not used>
* \todo      
*/
//------------------------------------------------------------------------------

void CBCameraSet::ConvertBitmap(PBYTE pDest, PBYTE pSource, CSize &size)
{
  switch ( m_ColorCode )
  {
  case DCSColor_Mono8 :
    if ( m_ConvertMono8ToRGB )
    {
      // Bayer -> RGB conversion Raw8->24Bit
      CColorConversion::ConvertMono8ToRGB(pDest, pSource, size, (CColorConversion::PatternOrigin_t) m_ConvertMono8ToRGB, m_pLutR, m_pLutG, m_pLutB);
    }
    else
    {
      // Nothing to be done ( mono8 image data). Let the bitmap point to the raw data
      memcpy(pDest, pSource, size.cx*size.cy);
    }
    break;
  case DCSColor_YUV8_4_2_2 :
    CColorConversion::ConvertYUV422ToRGB(pDest, pSource, size);
    break;
  default:
    throw BcamException(BCAM_E_UNSUPPORTED_COLOR_CODE, "CCamera::ConvertBitmap", &BcamUtility::ColorCodeName(m_ColorCode) );
  }
}
//------------------------------------------------------------------------------

⌨️ 快捷键说明

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