示例#1
0
MdispQtApp::MdispQtApp( int& argc, char** argv )
    : QApplication( argc, argv )
    , m_isCurrentlyHookedOnErrors(false)
    , m_ErrorEventSemaphore(1)
    , m_CreatorThread( QThread::currentThreadId() )
{
    // Set semaphore to initial state (no error event available).
    m_ErrorEventSemaphore.acquire();

    // Allocate an application and system [CALL TO MIL]
    MappAllocDefault(M_DEFAULT, &m_MilApplication, &m_MilSystem, M_NULL, M_NULL, M_NULL);

    // Hook MIL error on function DisplayError() [CALL TO MIL]
    MappHookFunction(M_ERROR_CURRENT,DisplayErrorExt,M_NULL);

    m_isCurrentlyHookedOnErrors = true;

    // Disable MIL error message to be displayed as the usual way [CALL TO MIL]
    MappControl(M_ERROR,M_PRINT_DISABLE);

    // Inquire number of digitizers available on the system [CALL TO MIL]
    MsysInquire(m_MilSystem,M_DIGITIZER_NUM,&m_numberOfDigitizer);

    // Digitizer is available
    if (m_numberOfDigitizer)
    {
        // Allocate a digitizer [CALL TO MIL]
        MdigAlloc(m_MilSystem,M_DEFAULT,M_CAMERA_SETUP,M_DEFAULT,&m_MilDigitizer);

        // Stop live grab when window is disable [CALL TO MIL]
        //TBM MIL 8.0 MsysControl(MilSystem,M_STOP_LIVE_GRAB_WHEN_DISABLED,M_ENABLE);

        // Inquire digitizer informations [CALL TO MIL]
        MdigInquire(m_MilDigitizer,M_SIZE_X,&m_digitizerSizeX);
        MdigInquire(m_MilDigitizer,M_SIZE_Y,&m_digitizerSizeY);
        MdigInquire(m_MilDigitizer,M_SIZE_BAND,&m_digitizerNbBands);

        if (m_digitizerSizeX > M_DEF_IMAGE_SIZE_X_MAX)
            m_digitizerSizeX = M_DEF_IMAGE_SIZE_X_MAX;
        if (m_digitizerSizeY > M_DEF_IMAGE_SIZE_Y_MAX)
            m_digitizerSizeY = M_DEF_IMAGE_SIZE_Y_MAX;
    }
    // Digitizer is not available
    else
    {
        m_MilDigitizer = 0;
        m_digitizerNbBands  =   M_DEF_IMAGE_NUMBANDS_MIN;
    }


    // Initialize the state of the grab
    m_isGrabStarted = FALSE;

    // Initialize GUI
    MainFrame* mf = new MainFrame();
    //setMainWidget(mf);

    mf->show();

}
示例#2
0
bool MdispGtkView::IsNetworkedSystem()
   {
   bool NetworkedSystem = false;
   MIL_ID SystemId = ((MdispGtkApp*)dispGtkApp())->m_MilSystem;

   // Check if system is networked (DistributedMIL) [CALL TO MIL]
   if(SystemId)
      NetworkedSystem = (MsysInquire(SystemId, M_NETWORKED, M_NULL) == M_YES);

   return NetworkedSystem;
   }
示例#3
0
bool MdispGtkApp::InitInstance()
   {
   // Allocate an application and system [CALL TO MIL]
   MappAllocDefault(M_DEFAULT, &m_MilApplication, &m_MilSystem, M_NULL, M_NULL, M_NULL);

   // Hook MIL error on function DisplayError() [CALL TO MIL]
   MappHookFunction(M_ERROR_CURRENT,DisplayErrorExt,this);

   m_isCurrentlyHookedOnErrors = true;
	
   // Disable MIL error message to be displayed as the usual way [CALL TO MIL]
   MappControl(M_ERROR,M_PRINT_DISABLE);
 
   // Inquire number of digitizers available on the system [CALL TO MIL]
   MsysInquire(m_MilSystem,M_DIGITIZER_NUM,&m_numberOfDigitizer);
	
   // Digitizer is available
   if (m_numberOfDigitizer)	
      {
      // Allocate a digitizer [CALL TO MIL]
      MdigAlloc(m_MilSystem,M_DEFAULT,M_CAMERA_SETUP,M_DEFAULT,&m_MilDigitizer);
		
      // Stop live grab when window is disable [CALL TO MIL]
    	//TBM MIL 8.0 MsysControl(MilSystem,M_STOP_LIVE_GRAB_WHEN_DISABLED,M_ENABLE);

		// Inquire digitizer informations [CALL TO MIL]
      MdigInquire(m_MilDigitizer,M_SIZE_X,&m_digitizerSizeX);
      MdigInquire(m_MilDigitizer,M_SIZE_Y,&m_digitizerSizeY);  	
      MdigInquire(m_MilDigitizer,M_SIZE_BAND,&m_digitizerNbBands);
   
      if (m_digitizerSizeX > M_DEF_IMAGE_SIZE_X_MAX) 
         m_digitizerSizeX = M_DEF_IMAGE_SIZE_X_MAX;
      if (m_digitizerSizeY > M_DEF_IMAGE_SIZE_Y_MAX) 
         m_digitizerSizeY = M_DEF_IMAGE_SIZE_Y_MAX;
      }
   else 
      {
      m_MilDigitizer=0;
      m_digitizerNbBands =	M_DEF_IMAGE_NUMBANDS_MIN;
      }

   // Initialize the state of the grab
   m_isGrabStarted = false;
   return true;
   }
/*************************** ini_control_digitalizador  *********************
	Función para reservar memoria para los diferentes formatos de
	digitalizadores que se utilizarán en la toma de imágenes.
	Previamente, se comprueba que los parámetros iniciales son válidos para
	el formato y tipo de digitalizador reservado.
	Seguidamente se reserva el display y los buffers que se utilizan en el
	proceso de adquisición de imágenes.
*****************************************************************************/
int ini_control_digitalizador(parametros *param)
{
	char	*fn = "ini_control_digitalizador - ";
	int		i;

	paramAux = param; //para usar en otras funciones

	//	SI DEFINO UN TAMAÑO DE DIGITALIZADOR DE ENFOQUE...	(DIGITALIZADOR)
	//	Reservo memoria para un nuevo display en el que se mostrarán los campos
	//	recorridos y los que se han podido enfocar. 
	if (param->Cam.formatoDig_e[0] != '\0' &&
		strcmp(param->Cam.formatoDig, param->Cam.formatoDig_e) )  
    {

		//	Configuro el digitalizador en formato enfoque
		if (M_digitalizador != M_NULL)
			libera_digitalizador();
		if ( MdigAlloc (M_sistema, M_DEV0, param->Cam.formatoDig_e, M_DEFAULT, &M_digitalizador)
			== M_NULL )  
        {
			error_fatal("ini_control_digitalizador", "Formato incorrecto", 0);
#if !defined (__BORLANDC__)
			putch('\a');
#endif
			return 1;
		}
		MdigInquire(M_digitalizador, M_SIZE_X, &limCam.anchoDig_e);
		if ( limCam.anchoDig_e > MAX_ANCHO_IMAGEN ||
				limCam.anchoDig_e < param->Cam.anchoImagen_e )  
        {
			error_fatal(fn, "Error en los parámetros iniciales", 0);
#if !defined (__BORLANDC__)
			putch('\a');
#endif
			return 1;
		}

		MdigInquire(M_digitalizador, M_SIZE_Y, &limCam.altoDig_e);
		if ( limCam.altoDig_e > MAX_ALTO_IMAGEN || 
                limCam.altoDig_e < param->Cam.altoImagen_e )  
        {
			error_fatal(fn, "Error en los parámetros iniciales", 0);
#if !defined (__BORLANDC__)
			putch('\a');
#endif
			return 1;
		}
	}


	//	Configuro el digitalizador en formato normal. 
	if (M_digitalizador != M_NULL)
		libera_digitalizador();

	if ( MdigAlloc (M_sistema, M_DEV0, param->Cam.formatoDig, M_DEFAULT, &M_digitalizador)
		== M_NULL )  {
		error_fatal("ini_control_proceso_imagenes", "Formato incorrecto", 0);
		return 1;
	}
	MdigInquire(M_digitalizador, M_SIZE_X, &limCam.anchoDig);
	if ( limCam.anchoDig > MAX_ANCHO_IMAGEN ||
			limCam.anchoDig < param->Cam.anchoImagen )  {
		error_fatal(fn, "Error en los parámetros iniciales", 0);
#if !defined (__BORLANDC__)
		putch('\a');
#endif
		return 1;
	}

	MdigInquire(M_digitalizador, M_SIZE_Y, &limCam.altoDig);
	if ( limCam.altoDig > MAX_ALTO_IMAGEN || 
            limCam.altoDig < param->Cam.altoImagen )  {
		error_fatal(fn, "Error en los parámetros iniciales", 0);
#if !defined (__BORLANDC__)
		putch('\a');
#endif
		return 1;
	}

	//	Si el formato del digitalizador de enfoque es el mismo que el de
	//	captura normal, copiamos las dimensiones porque no se leyeron. 
	if ( strcmp(param->Cam.formatoDig, param->Cam.formatoDig_e) == 0 )  {
		limCam.anchoDig_e = limCam.anchoDig;
		limCam.altoDig_e = limCam.altoDig;
	}

	//	Compruebo los valores iniciales de brillo, ganancia y exposición. 
	if ( info_digitalizador(M_digitalizador) )  {
		error_fatal(fn, "Error en los parámetros iniciales", 0);
		return 1;
	}

    // Se centra la camara en el caso de que se haya configurado un tamaño de toma diferente al maximo de la camara
	if ( configura_digitalizador(FORMATO_NORMAL) )  
        return 1;

	//	Buffer auxiliar de PROFUNDIDAD_ACUMULACION bits para acumular valores.
	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, PROFUNDIDAD_ACUMULACION+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC+M_GRAB, &M_imagen_acum);
	if ( M_imagen_acum == M_NULL )  {
		error_fatal(fn, "M_imagen_acum", 0);
		return 1;
	}

    // Obtenemos la profundidad de la camara
	MdigInquire(M_digitalizador, M_SIZE_BIT , &param->Cam.profundidad);

    if ( (BITS_CAMARA > 8 && param->Cam.profundidad <= 8) ||
         (BITS_CAMARA <= 8 && param->Cam.profundidad > 8) )
    {
		error_fatal(fn, "BITS_CAMARA (DEFINE en codigo) y profundidad camara no coherentes", 0);
		return 1;
	}

    //Si la profundidad no es de 8bit, hay que configurar el display.
    //El display siempre es de 8 bit
    if (param->Cam.profundidad == 16)
    {
        MdispControl(M_display_normal,M_VIEW_MODE,M_BIT_SHIFT);
        MdispControl(M_display_normal,M_VIEW_BIT_SHIFT,4); //despreciamos los 4 bits menos significativos
		MdispLut(M_display_normal, M_PSEUDO); //esto es necesario para que la intensidad no sea anormalmente elevada
    }

	//	Reservamos los buffers donde se almacenarán y procesarán las imágenes. 
	//	M_imagen1 será el buffer que normalmente estará asociado al display_normal.

	// En modo VGA no permite grabar datos en el buffer.
    long nSD_size;
    MsysInquire(M_sistema,M_SYSTEM_DESCRIPTOR_SIZE,&nSD_size);
    char* systemDescriptor = new char[nSD_size];
    MsysInquire(M_sistema,M_SYSTEM_DESCRIPTOR,systemDescriptor);
	if (systemDescriptor == M_SYSTEM_VGA)
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
			M_IMAGE+M_DISP+M_PROC, &M_imagen1 );
	else
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
			M_IMAGE+M_DISP+M_GRAB+M_PROC, &M_imagen1 );
    delete [ ] systemDescriptor;
	if ( M_imagen1 == M_NULL)  {
		error_fatal(fn, "M_imagen1", 0);
		return -1;
	}
	if ( M_imagen1 != M_NULL )  
    {
	//	Seleccionamos el display para imagen normal, asociando el overlay. 
#if !defined (__BORLANDC__)
	    configura_overlay(M_display_normal, M_imagen1, &M_overlay_normal, 1);
#else
	    configura_overlay(M_display_normal, M_imagen1, HWindow, &M_overlay_normal, 1);
        borra_buffer(M_imagen1, NEGRO, 0, 0, NULL, NULL);
#endif
/*
*/
	    if (param->Cam.anchoImagen != param->Cam.anchoImagen_e    || 
            param->Cam.altoImagen != param->Cam.altoImagen_e)  
        {
            // Reservo un child buffer de M_imagen1 con el tamaño de enfoque.
            MbufChild2d(M_imagen1, (param->Cam.anchoImagen - param->Cam.anchoImagen_e) /2,
                (param->Cam.altoImagen- param->Cam.altoImagen_e) /2,
                param->Cam.anchoImagen_e, param->Cam.altoImagen_e, &M_centro_imagen);
            if (M_centro_imagen == M_NULL)  
            {
                error_fatal(fn, "M_centro_imagen", 0);
                return -1;
		    }
        }
        else
            M_centro_imagen = M_imagen1;
	}

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC, &M_imagen2 );
	if ( M_imagen2 == M_NULL )  {
		error_fatal(fn, "M_imagen2", 0);
		return -1;
	}

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC, &M_imagen3);
	if ( M_imagen3 == M_NULL )  {
		error_fatal(fn, "M_imagen3", 0);
		return -1;
	}

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC, &M_imagen4);
	if ( M_imagen4 == M_NULL )  {
		error_fatal(fn, "M_imagen4", 0);
		return -1;
	}

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC, &M_imagen5);
	if ( M_imagen5 == M_NULL )  {
		error_fatal(fn, "M_imagen5", 0);
		return -1;
	}

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
		M_IMAGE+M_DISP+M_PROC, &M_imagen6);
	if ( M_imagen6 == M_NULL )  {
		error_fatal(fn, "M_imagen6", 0);
		return -1;
	}

	//	Reservo memoria para los buffers utilizados en la adquisición
	//	de las bandas y en la correccion de la iluminación.
	for (i=0; i < param->nBandas; i++) {
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, param->Cam.profundidad+M_UNSIGNED,
			M_IMAGE+M_DISP+M_PROC, &M_banda[i]);
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT,
			M_IMAGE+M_PROC, &M_correc_denom[i]);
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT,
			M_IMAGE+M_PROC, &M_correc_numer[i]);

		if ( M_banda[i] == M_NULL ||
				M_correc_numer[i] == M_NULL || M_correc_denom[i] == M_NULL )  {
			error_fatal(fn, "M_banda", 0);
			return 1;
		}
	}
    //El resto de filtros no usados a NULL
	for (; i < MAX_FILTROS_DTA; i++)
		M_banda[i] = M_correc_numer[i] = M_correc_denom[i] = M_NULL;

	MbufAlloc2d(M_sistema, param->Cam.anchoImagen, param->Cam.altoImagen, 32+M_FLOAT,
		M_IMAGE+M_PROC, &M_correc_aux);
	if ( M_correc_aux == M_NULL )  {
		error_fatal(fn, "M_correc_aux", 0);
		return 1;
	}

	//	SI DEFINO UN TAMAÑO DE DIGITALIZADOR DE ENFOQUE...	(BUFFERS)
    //	Reservo memoria para los buffers empleados durante el enfoque mediante la funcion determina_contraste2
	if ( param->Cam.formatoDig_e[0] != '\0' )  {
		MbufAlloc2d(M_sistema, param->Cam.anchoImagen_e, param->Cam.altoImagen_e, param->Cam.profundidad+M_UNSIGNED,
			M_IMAGE+M_DISP+M_GRAB+M_PROC, &M_enfoque);
		if ( M_enfoque == M_NULL )  {
			error_fatal(fn, "M_enfoque", 0);
			return 1;
		}
	}

	return 0;
}