コード例 #1
0
ファイル: gabor.c プロジェクト: rafaelalmeida/poc
////////////////////////////////////////////////////////
// Filterbank Functions - BEGIN
////////////////////////////////////////////////////////
Filterbank * CreateFilterbank( int sze ){

  Filterbank * pFilterbank = NULL;
  pFilterbank = (Filterbank*)calloc(1, sizeof(Filterbank));
  assert(pFilterbank!=NULL);

  pFilterbank->m_pSpectralFilterBank = NULL;
  pFilterbank->m_pSpectralFilterBank = (Spectrum**)calloc(NSCALES*NORIENTATIONS,sizeof(Spectrum*));
  assert(pFilterbank!=NULL);

  gabor * pGabor = NULL;
  register int s, k;

  for( s = 0; s < NSCALES; s++ ){
    for( k = 0; k < NORIENTATIONS; k++ ){

      pGabor = CreateGabor( sze );
      assert(pGabor!=NULL);
      gaborFilter(pGabor, s+1, k+1);

      pFilterbank->m_pSpectralFilterBank[s*NORIENTATIONS+k] = DFFT2DWithImag(pGabor->m_pReal, pGabor->m_pImag);
      DestroyGabor(&(pGabor));
    }
  }

  pFilterbank->m_pFeatures = NULL;
  return (pFilterbank);
}
コード例 #2
0
ファイル: WorkerThread.cpp プロジェクト: tibo-xx/UNR_Gabor
// Main execution loop.
// Capture from camera, filter image data, save filered data.
// Note*: wait conditions are used to ensure that the previous image
// has been rendered while allowing for continued operation.
void WorkerThread::run()
{
	createInitialFilter();
	while( 1 )
	{
		// Throttling
		while( !g_throttleTimerFlag ){}
		g_throttleTimerFlag = 0;

		// Capture image data
		_camera->capture();
		float *data = _camera->frameData();

		// Need a new filter?
		_new_filter_mutex.lock();	
		if( _should_create_new_filter )
		{
			createNewFilter();
		}
		_new_filter_mutex.unlock();	

		// Gabor filter
		gaborFilter( data );	

		// Make sure the previous image has been rendered before overwriting it
		_image_mutex.lock();
		if( !_is_image_processed )
		{
			_image_processed.wait(&_image_mutex);	
		}

		// Copy image data so the thread continues capturing and filtering
		memcpy( _full_image, data, sizeof(float) * _original_image_width * _original_image_height * 2 );
		_is_image_processed = false;
		emit filterComplete();
		_image_mutex.unlock();

		if( _should_terminate )
		{
			break;
		}
	}

	// Free GPU resources
	cudaFree(_gabor_data);
	cudaFree(_gpu_image_0);
	cudaFree(_gpu_image_1);
	cufftDestroy(_fft_plan);
}