//************************************************************************************************** void ossimScaleFilter::setFilterType(ossimScaleFilterType minifyFilterType, ossimScaleFilterType magnifyFilterType) { if(m_MinifyFilter) { delete m_MinifyFilter; m_MinifyFilter = NULL; } if(m_MagnifyFilter) { delete m_MagnifyFilter; m_MagnifyFilter = NULL; } m_MinifyFilterType = minifyFilterType; m_MagnifyFilterType = magnifyFilterType; m_MinifyFilter = createNewFilter(minifyFilterType, m_MinifyFilterType); m_MagnifyFilter = createNewFilter(magnifyFilterType, m_MagnifyFilterType); }
// 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); }