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

📄 bcam.cpp

📁 BCAM 1394 Driver
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        case 5:
            BytePerPacket = 10240 >> shiftval;
            break;
        case 6:
            BytePerPacket = 2*10240 >> shiftval;
            break;
        default: 
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::BytePerPacket()" ), &VideoMode);
        }
        if ( BytePerPacket>8192 || BytePerPacket<40)
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
      break;
    case 1:
        switch ( VideoMode ) 
        {
        case 0:
            if ( VideoFramerate == DCS_1_875fps )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*16000 >> shiftval;
            break;
        case 1:
            if ( VideoFramerate < DCS_7_5fps || VideoFramerate > DCS_120fps )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 3*16000 >> shiftval;
            break;
        case 2:
            if ( VideoFramerate < DCS_7_5fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 16000 >> shiftval;
            break;
        case 3:
            if ( VideoFramerate > DCS_120fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*24576 >> shiftval;
            break;
        case 4:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 3*24576 >> shiftval;
            break;
        case 5:
            BytePerPacket = 24576 >> shiftval;
            break;
        case 6:
            if ( VideoFramerate == DCS_1_875fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*16000 >> shiftval;
            break;
        case 7:
            if ( VideoFramerate > DCS_120fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*24576 >> shiftval;
            break;
        default: 
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::BytePerPacket()" ), &VideoMode);
        }
        if ( BytePerPacket>8192 || BytePerPacket<192)
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
        break;
    case 2:
        switch ( VideoMode )
        {
        case 0:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*40960 >> shiftval;
            break;
        case 1:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 3*40960 >> shiftval;
            break;
        case 2:
            if ( VideoFramerate > DCS_120fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 40960 >> shiftval;
            break;
        case 3:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*64000 >> shiftval;
            break;
        case 4:
            if ( VideoFramerate > DCS_30fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 3*64000 >> shiftval;
            break;
        case 5:
            if ( VideoFramerate > DCS_120fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 64000 >> shiftval;
            break;
        case 6:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*40960 >> shiftval;
            break;
        case 7:
            if ( VideoFramerate > DCS_60fps  )
                throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
            BytePerPacket = 2*64000 >> shiftval;
            break;
        default: 
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::BytePerPacket()" ), &VideoMode);
        }
        if ( BytePerPacket>8192 )
            throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::BytePerPacket()" ), &VideoFormat);
        break;
    default:
        throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::BytePerPacket()" ), &VideoMode);
    }

    return BytePerPacket;
}


//------------------------------------------------------------------------------
// CSize BcamUtility::ImageSize(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode)
// Author: A.Happe
//------------------------------------------------------------------------------
/**
* \brief Looks up the image size.
*
* \param     VideoFormat The code of the video format
* \param     VideoMode   The code of the video mode
* \return    
*
* Returns the image size of the combination of video format and mode
* 
* \see       DCAM
*/
//------------------------------------------------------------------------------
CSize BcamUtility::ImageSize(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode)
{
  switch (VideoFormat)
  {
  case 0:
    switch (VideoMode)
    {
    case 0: return CSize(160, 120);
    case 1: return CSize(320, 240);
    case 2: 
    case 3: 
    case 4:
    case 5:
    case 6: return CSize(640, 480);
    default: throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ImageSize" ), &VideoMode);
    }
    case 1:
      switch (VideoMode)
      {
      case 0:
      case 1:
      case 2: return CSize(800, 600);
      case 3: 
      case 4:
      case 5: return CSize(1024, 768);
      case 6: return CSize(800, 600);
      case 7: return CSize(1024, 768);
      default: throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ImageSize" ), &VideoMode);
      }
      
      case 2:
        switch (VideoMode)
        {
        case 0:   
        case 1:
        case 2: return CSize(1280, 960);
        case 3:
        case 4:
        case 5: return CSize(1600, 1200);
        case 6: return CSize(1280, 960);
        case 7: return CSize(1600, 1200);
        default: throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ImageSize" ), &VideoMode);
        }
        default:
          throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::ImageSize" ), &VideoFormat);
          
  }
}

//------------------------------------------------------------------------------
// DCSColorCode BcamUtility::ColorCode(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode)
// Author: 
//------------------------------------------------------------------------------
/**
* \brief Look up the color code.
*
* \param     VideoFormat
* The code of the video format.
* \param     VideoMode
* The code of the video mode.
* \return    
*
* Returns the color code of the combination of video format and video mode.
* 
* \see       DCAM 2.1.2
* \todo      
*/
//------------------------------------------------------------------------------
DCSColorCode BcamUtility::ColorCode(DCSVideoFormat VideoFormat, DCSVideoMode VideoMode)
{
  switch (VideoFormat)
  {
  case 0:
    switch (VideoMode)
    {
    case 0:
      return DCSColor_YUV8_4_4_4;
    case 1:
      return DCSColor_YUV8_4_2_2;
    case 2:
      return DCSColor_YUV8_4_1_1;
    case 3:
      return DCSColor_YUV8_4_2_2;
    case 4:
      return DCSColor_RGB8;
    case 5:
      return DCSColor_Mono8;
    case 6:
      return DCSColor_Mono16;
    default: throw BcamException(BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ColorMode" ), &VideoMode);
    }
    
    case 1:
      switch (VideoMode)
      {
      case 0: return DCSColor_YUV8_4_2_2;
      case 1: return DCSColor_RGB8;
      case 2: return DCSColor_Mono8;
      case 3: return DCSColor_YUV8_4_2_2;
      case 4: return DCSColor_RGB8;
      case 5: return DCSColor_Mono8;
      case 6:
      case 7: return DCSColor_Mono16;
      default: throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ColorMode" ), &VideoMode);
      }
      case 2:
        switch (VideoMode)
        {
        case 0: return DCSColor_YUV8_4_2_2;
        case 1: return DCSColor_RGB8;
        case 2: return DCSColor_Mono8;
        case 3: return DCSColor_YUV8_4_2_2;
        case 4: return DCSColor_RGB8;
        case 5: return DCSColor_Mono8;
        case 6: return DCSColor_Mono16;
        case 7: return DCSColor_Mono16;
        default: throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "BcamUtility::ColorMode" ), &VideoMode);
        }
        default:
          throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_FORMAT, _T( "BcamUtility::ColorMode" ), &VideoFormat);
  }
}

//------------------------------------------------------------------------------
// CString BcamUtility::ColorCodeName(DCSColorCode ColorCode)
// Author: A.Happe
//------------------------------------------------------------------------------
/**
* \brief Get a string representation of the color code.
*
* \param     ColorCode
* \return    
*
* Returns a string representation of the color code.
*
* \throw BcamException BCAM_E_UNSUPPORTED_COLOR_CODE when passing an invalid color code to the function
* 
*/
//------------------------------------------------------------------------------
CString BcamUtility::ColorCodeName(DCSColorCode ColorCode)
{
  switch ( ColorCode )
  {
  case DCSColor_Mono8       : return _T( "Mono8" );
  case DCSColor_YUV8_4_1_1  : return _T( "YUV(4:1:1)" );
  case DCSColor_YUV8_4_2_2  : return _T( "YUV(4:2:2)" );
  case DCSColor_YUV8_4_4_4  : return _T( "YUV(4:4:4)" );
  case DCSColor_Mono16      : return _T( "Mono16(unsigned)" );
  case DCSColor_SMono16     : return _T( "Mono16(signed)" );
  case DCSColor_RGB8        : return _T( "RGB8" );
  case DCSColor_RGB16       : return _T( "RGB16(unsigned)" );
  case DCSColor_SRGB16      : return _T( "RGB16(signed)" );
  case DCSColor_Raw8        : return _T( "Raw8" );
  case DCSColor_Raw16       : return _T( "Raw16" );
  default:  
    if (DCSColor_VendorSpecific0 <= ColorCode && DCSColor_VendorSpecific127 >= ColorCode)
    {
      int i = ColorCode - DCSColor_VendorSpecific0;
      CString codename;
      codename.Format( _T("Vendor Specific Color Code %i" ), i );
      
      return codename;
    }
    else
      throw BcamException( BCAM_E_UNSUPPORTED_COLOR_CODE, _T( "BcamUtility::ColorCodeName" ), &ColorCode);
  }
}

//------------------------------------------------------------------------------
// unsigned short BcamUtility::BitsPerPixel(DCSColorCode ColorCode)
// Author: A.Happpe
//------------------------------------------------------------------------------
/**
* \brief Looks up the pixel size of a color code
*
* \param     ColorCode
* \return    
*
* Returns the number of bits used for a pixel.
* If the color code is vendor specific zero is returned.
*
* \throw BcamException BCAM_E_UNSUPPORTED_COLOR_CODE when passing an invalid color code to the function
*
* 
* \see       DCAM
*/
//------------------------------------------------------------------------------
unsigned short BcamUtility::BitsPerPixel(DCSColorCode ColorCode)
{
  switch ( ColorCode )
  {
  case DCSColor_Mono8       : return 8;
  case DCSColor_YUV8_4_1_1  : return 12;
  case DCSColor_YUV8_4_2_2  : return 16;
  case DCSColor_YUV8_4_4_4  : return 24;
  case DCSColor_Mono16      : return 16;
  case DCSColor_SMono16     : return 16;
  case DCSColor_RGB8        : return 24;
  case DCSColor_RGB16       : return 48;
  case DCSColor_SRGB16      : return 48;
  case DCSColor_Raw8        : return 8;
  case DCSColor_Raw16       : return 16;
  default:                    
    if (DCSColor_VendorSpecific0 <= ColorCode && DCSColor_VendorSpecific127 >= ColorCode)
      return 0;
    else
      throw BcamException( BCAM_E_UNSUPPORTED_COLOR_CODE, _T( "BcamUtility::BitsPerPixel" ), &ColorCode);
  }
}


//------------------------------------------------------------------------------
// bool BcamUtility::IsFullDeviceName(CString DeviceName)
// Author: 
// Date: 26.10.2002
//------------------------------------------------------------------------------
/**
 * \brief is a given device name a "full" device name, i.e. does it contain the driver interface GUID?
 * 
 * Check if a given device name is a full device name (as it is passed in by the plug and play manager) 
 * or if it is a friendly device name not containing the driver interface GUID
 *
 * \param     DeviceName device name to check
 * \return    true, if the device name is not a friendly device name
 *
 */
//------------------------------------------------------------------------------
bool BcamUtility::IsFullDeviceName(CString DeviceName)
{
  int first = DeviceName.Find('#');
  assert(first > 0);
  int l = DeviceName.GetLength();
  int second  = DeviceName.Right(l - (first+1)).Find('#') + first + 1;
  return(second > first);
}

//------------------------------------------------------------------------------
// CString BcamUtility::FullDeviceName(CString DeviceName)
// Author: 
// Date: 26.10.2002
//------------------------------------------------------------------------------

⌨️ 快捷键说明

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