Пример #1
0
void CalcStatsFrame(STFrame* frameDataOut ){

	struct timeval ti;
	float TiempoParcial;
	static int init = 1;

	if( !frameDataOut) return;
#ifdef MEDIR_TIEMPOS
	gettimeofday(&ti, NULL);
	printf( "Rastreo finalizado con éxito ..." );
	printf( "Comenzando análisis estadístico de los datos obtenidos ...\n" );
	printf("\n3)Cálculo de estadísticas en tiempo de ejecución:\n");

#endif


	// Iniciar estructuras de estadísticas.
	 frameDataOut->Stats = InitStatsFrame(  frameDataOut->GStats->fps );

	// estadísticas de cada blob
	statsBloB( frameDataOut );

	// cálculos estadísticos del movimiento de los blobs en conjunto
	if( CALC_STATS_MOV ) statsBlobS( frameDataOut );


#ifdef MEDIR_TIEMPOS
	printf( "Análisis finalizado ...\n" );
	TiempoParcial = obtenerTiempo( ti , NULL);
	printf("Cálculos realizados. Tiempo total %5.4g ms\n", TiempoParcial);
#endif
}
Пример #2
0
STGlobStatF* SetGlobalStats( int NumFrame, timeval tif, timeval tinicio, int TotalFrames, float FPS  ){
	//FrameData->Stats->totalFrames = 0;
	// FRAME
	STGlobStatF* GStats = NULL;
	GStats = ( STGlobStatF *) malloc( sizeof(STGlobStatF));
	if(!GStats) {error(4); return 0;}

	GStats->TiempoFrame = obtenerTiempo( tif, 0 );
	GStats->TiempoGlobal = obtenerTiempo( tinicio, 1);
	GStats->numFrame = NumFrame;
	GStats->fps = FPS;
	GStats->totalFrames = TotalFrames;

	return GStats;

}
Пример #3
0
STFrame* Tracking( STFrame* frameDataIn, int MaxTracks,StaticBGModel* BGModel, int FPS ){


	STFrame* frameDataOut = NULL; // frame de salida

#ifdef MEDIR_TIEMPOS
	struct timeval ti,tif; // iniciamos la estructura
	float tiempoParcial;
	gettimeofday(&tif, NULL);
	printf("\n2)Tracking:\n");
	gettimeofday(&ti, NULL);
	printf("\t1)Asignación de identidades\n");
#endif



	////////////// AÑADIR AL BUFFER /////////////
	anyadirAlFinal( frameDataIn, framesBuf);
//	MotionTemplate( framesBuf,Identities );

	////////////// ASIGNACIÓN DE IDENTIDADES ///////////

	//APLICAR EL METODO DE OPTIMIZACION HUNGARO A LA MATRIZ DE PESOS
	// Asignar identidades.
	// resolver las asociaciones usando las predicciones de kalman mediante el algoritmo Hungaro
	// Si varias dan a la misma etiquetarla como 0. Enlazar flies.
	// Se trabaja en las posiciones frame MAX_BUFFER - 1 y MAX_BUFFER -2.

	asignarIdentidades( lsTracks,frameDataIn->Flies);

	ordenarTracks( lsTracks );
#ifdef MEDIR_TIEMPOS
	tiempoParcial= obtenerTiempo( ti, 0);
	printf("\t\t-Tiempo: %5.4g ms\n", tiempoParcial);
	gettimeofday(&ti, NULL);
	fprintf(stderr,"\t2)Filtro de Kalman\n");
#endif

	/////////////// ELIMIRAR FALSOS TRACKS. APLICACIÓN DE HEURíSTICAS AL FINAL DEL BUFFER ///
	frameDataIn->numTracks = validarTracks( framesBuf, lsTracks,Identities, trackParams->MaxBlobs, frameDataIn->num_frame );

	/////////////// FILTRO DE KALMAN //////////////
	// El filtro de kalman trabaja en la posicion MAX_BUFFER -1. Ultimo elemento anyadido.
	Kalman( frameDataIn , Identities, lsTracks, trackParams);

	frameDataIn->Tracks = lsTracks;

#ifdef MEDIR_TIEMPOS
	tiempoParcial= obtenerTiempo( ti, 0);
	printf("\t\t-Tiempo: %5.4g ms\n", tiempoParcial);
#endif

	///////   FASE DE CORRECCIÓN. APLICACION DE HEURISTICAS AL FRAME DE SALIDA /////////

	despertarTrack(framesBuf, lsTracks, Identities );
	ordenarTracks( lsTracks );

	// SI BUFFER LLENO
	if( framesBuf->numeroDeElementos == trackParams->MaxBuffer ){

		corregirTracks(framesBuf,  lsTracks, Identities );


	////////// LIBERAR MEMORIA  ////////////
		frameDataOut = (STFrame*)liberarPrimero( framesBuf ) ;
		if(!frameDataOut){error(7); exit(1);}

		VisualizarEl( framesBuf, PENULTIMO, BGModel );

#ifdef MEDIR_TIEMPOS
		tiempoParcial = obtenerTiempo( tif , NULL);
		printf("Tracking correcto.Tiempo total %5.4g ms\n", tiempoParcial);
#endif
		return frameDataOut;
	}
	else {
		VerEstadoBuffer( frameDataIn->Frame, framesBuf->numeroDeElementos, trackParams->MaxBuffer);
		VisualizarEl( framesBuf, PENULTIMO, BGModel );
#ifdef MEDIR_TIEMPOS
		tiempoParcial = obtenerTiempo( tif , NULL);
		printf("Tracking correcto.Tiempo total %5.4g ms\n", tiempoParcial);
#endif
		return 0;
	}
}