示例#1
0
int CameraApi::openCamera()
{
	int is_init = IS_NO_SUCCESS;
	int is_mode = IS_NO_SUCCESS;
	int is_alcM = IS_NO_SUCCESS;
	int isLoad = IS_NO_SUCCESS;

	is_init = is_InitCamera(&mhCam, 0);

	if(is_init == IS_SUCCESS)
	{
		is_mode = is_SetDisplayMode(mhCam, IS_SET_DM_DIB);
	}

	if(is_mode == IS_SUCCESS)
	{
		ringbuffer = new char* [ringbufferSize];
		ringbufferId = new int [ringbufferSize];

		IS_SIZE_2D maxAoi;
		is_AOI(mhCam, IS_AOI_IMAGE_GET_SIZE_MAX, &maxAoi, sizeof(maxAoi));

		for(int i=0; i<ringbufferSize; i++)
		{
			is_AllocImageMem(mhCam, maxAoi.s32Width, maxAoi.s32Height, bitspixel(), &ringbuffer[i], &ringbufferId[i]); 
			is_AddToSequence(mhCam, ringbuffer[i], ringbufferId[i]);
		}

		isLoad = is_LoadParameters(mhCam, "cameraParameter.ini");
		setAoi(0, 0, width(), height());

		is_SetExternalTrigger(mhCam, IS_SET_TRIGGER_OFF);
		is_CaptureVideo(mhCam, IS_WAIT);
	}

	if(isLoad == IS_SUCCESS)
		return IS_SUCCESS;
	else
		return IS_NO_SUCCESS;
}
示例#2
0
//Open our camera
bool IDSCamera::OpenCamera()
{
	if (m_hCam!=0)
	{
        //free old image mem.
        is_FreeImageMem(m_hCam,m_pcImageMemory,m_lMemoryId);
        is_ExitCamera(m_hCam);
    }

    // init camera
    m_hCam = (HIDS) 0;    // open next camera
    m_Ret = is_InitCamera(&m_hCam,NULL);    // init camera
    
    if( m_Ret == IS_SUCCESS ){    
        // retrieve original image size
        SENSORINFO sInfo;
        is_GetSensorInfo(m_hCam,&sInfo);
        m_nSizeX = sInfo.nMaxWidth;
        m_nSizeY = sInfo.nMaxHeight;

        // setup the color depth to the current windows setting
        //is_GetColorDepth(m_hCam,&m_nBitsPerPixel,&m_nColorMode);
        is_SetColorMode(m_hCam, IS_SET_CM_Y8);

        //printf("m_nBitsPerPixel=%i  m_nColorMode=%i\n",m_nBitsPerPixel,IS_SET_CM_Y8);

        // memory initialization
        is_AllocImageMem(m_hCam, m_nSizeX, m_nSizeY, m_nBitsPerPixel, &m_pcImageMemory, &m_lMemoryId);
        //set memory active
        is_SetImageMem( m_hCam, m_pcImageMemory,m_lMemoryId ); 
        // display initialization
        is_SetImageSize( m_hCam, m_nSizeX, m_nSizeY );
        is_SetDisplayMode( m_hCam, IS_SET_DM_DIB);
  // Reinit with slower frame rate for testing on vmWare with USB 1.1        
      if( is_LoadParameters( m_hCam, config_file ) == IS_SUCCESS )
		  {
			  // realloc image mem with actual sizes and depth.
			  is_FreeImageMem( m_hCam, m_pcImageMemory, m_lMemoryId );
			  m_nSizeX = is_SetImageSize( m_hCam, IS_GET_IMAGE_SIZE_X, 0 );
			  m_nSizeY = is_SetImageSize( m_hCam, IS_GET_IMAGE_SIZE_Y, 0 );
			  switch( is_SetColorMode( m_hCam, IS_GET_COLOR_MODE ) )
			  {
			  case IS_SET_CM_RGB32:
				  m_nBitsPerPixel = 32;
				  break;
			  case IS_SET_CM_RGB24:
				  m_nBitsPerPixel = 24;
				  break;
			  case IS_SET_CM_RGB16:
			  case IS_SET_CM_UYVY:
				  m_nBitsPerPixel = 16;
				  break;
			  case IS_SET_CM_RGB15:
				  m_nBitsPerPixel = 15;
				  break;
			  case IS_SET_CM_Y8:
			  case IS_SET_CM_RGB8:
			  case IS_SET_CM_BAYER:
			  default:
				  m_nBitsPerPixel = 8;
				  break;
			  }

			  // memory initialization
			  is_AllocImageMem( m_hCam,
							  m_nSizeX,
							  m_nSizeY,
							  m_nBitsPerPixel,
							  &m_pcImageMemory,
							  &m_lMemoryId);
			  is_SetImageMem(m_hCam, m_pcImageMemory, m_lMemoryId );	// set memory active

			  // display initialization
			  is_SetImageSize(m_hCam, m_nSizeX, m_nSizeY );
		  }
    }
  return true;
}