int main() { PROFILER_INIT(); FrameList frameList(10); // Keep a history of up to 100 frames (might be used by some modules) // Modules //BackgroundModelling_simple::BackgroundModel backgroundModel; BackgroundModelling::BackgroundModel backgroundModel; ForegroundProcessing::ForegroundProcessor foregroundProcessor; Identification::Identifier identifier; Prediction::Kalman kalmanFilter; Evaluation evaluate(&frameList, 20); // Init foregroundProcessor.setAlgortihm(ForegroundProcessing::SLOW); //Use slow, toggle shadows in the init command foregroundProcessor.init(3, 2, 125, 4, false); foregroundProcessor.initShadow(0.5, 0.5, 0.3, 0.99); identifier.init(Identification::Ultimate); evaluate.readXML2FrameList("clip1.xml"); //evaluate.readXML2FrameList("CAVIAR1/fosne2gt.xml"); int waitForBGConvergence = 60; // Load frame source //frameList.open("CAVIAR1/OneStopNoEnter2front.mpg"); //frameList.open("clip1.mpeg"); frameList.open("camera1.mov"); //frameList.open("Renova_20080420_083025_Cam10_0000.mpeg"); //Record video VideoWriter demo("trackingDemo.mpeg", CV_FOURCC('P','I','M','1'), 20, frameList.movieSize*2); // Create windows namedWindow("Info",CV_WINDOW_AUTOSIZE); namedWindow("Background",CV_WINDOW_AUTOSIZE); namedWindow("Foreground",CV_WINDOW_AUTOSIZE); namedWindow("Tracking",CV_WINDOW_AUTOSIZE); namedWindow("Raw image", CV_WINDOW_AUTOSIZE); //namedWindow("BackgroundModel",CV_WINDOW_AUTOSIZE); namedWindow("Evaluation", CV_WINDOW_AUTOSIZE); while (frameList.queryNextFrame()) { PROFILER_RESET(); sampleDown(frameList.getLatestFrame().image, frameList.getLatestFrame().image, 1); // Speed up by sampling down the image // Do the nessecary processing backgroundModel.update(frameList.getFrames()); PROFILE("BackgroundModel"); if (frameList.getCurrentFrameNumber() > waitForBGConvergence) //Wait for convergence foregroundProcessor.segmentForeground(frameList.getLatestFrame()); PROFILE("ForegroundSeg."); identifier.identify(frameList.getFrames()); PROFILE("Identification"); kalmanFilter.predict(frameList.getLatestFrame()); PROFILE("Kalman Prediction"); evaluate.currentFrame(); PROFILE("Evaluation"); // Display result frameList.display("Tracking"); frameList.displayBackground("Background"); if (frameList.getCurrentFrameNumber() > waitForBGConvergence) //Wait for convergence frameList.displayForeground("Foreground"); evaluate.displayInfo("Evaluation"); // Give the GUI time to render waitKey(1); PROFILE("Display"); // Write current frame (and info) to file demo << frameList.getLatestFrame().demoImage; // Optional pause between each frame //stepWiseFromFrame(frameList, 55); PROFILE("QueryNextFrame"); PROFILE_TOTALTIME(); PROFILE("FPS"); PROFILE_FPS(); // Evaluate accuracy and precision evaluate.MOTA(); evaluate.MOTP(); // Display info frameList.displayInfo("Info"); } evaluate.displaySequenceInfo("Evaluation"); waitKey(0); return 0; }
bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { m_pluginMutex.lock(); if( !isOkay() || dontRun() || !isRunning() || !isEnabled() ) { m_pluginMutex.unlock(); return( false ); } int frames = _frames; sampleFrame * o_buf = NULL; sampleFrame sBuf [_frames]; if( m_maxSampleRate < engine::mixer()->processingSampleRate() ) { o_buf = _buf; _buf = &sBuf[0]; sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / engine::mixer()->processingSampleRate(); } // Copy the LMMS audio buffer to the LADSPA input buffer and initialize // the control ports. Need to change this to handle non-in-place-broken // plugins--would speed things up to use the same buffer for both // LMMS and LADSPA. ch_cnt_t channel = 0; for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { for( int port = 0; port < m_portCount; ++port ) { port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { case CHANNEL_IN: for( fpp_t frame = 0; frame < frames; ++frame ) { pp->buffer[frame] = _buf[frame][channel]; } ++channel; break; case AUDIO_RATE_INPUT: pp->value = static_cast<LADSPA_Data>( pp->control->value() / pp->scale ); // This only supports control rate ports, so the audio rates are // treated as though they were control rate by setting the // port buffer to all the same value. for( fpp_t frame = 0; frame < frames; ++frame ) { pp->buffer[frame] = pp->value; } break; case CONTROL_RATE_INPUT: if( pp->control == NULL ) { break; } pp->value = static_cast<LADSPA_Data>( pp->control->value() / pp->scale ); pp->buffer[0] = pp->value; break; case CHANNEL_OUT: case AUDIO_RATE_OUTPUT: case CONTROL_RATE_OUTPUT: break; default: break; } } } // Process the buffers. for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { (m_descriptor->run)( m_handles[proc], frames ); } // Copy the LADSPA output buffers to the LMMS buffer. double out_sum = 0.0; channel = 0; const float d = dryLevel(); const float w = wetLevel(); for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { for( int port = 0; port < m_portCount; ++port ) { port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { case CHANNEL_IN: case AUDIO_RATE_INPUT: case CONTROL_RATE_INPUT: break; case CHANNEL_OUT: for( fpp_t frame = 0; frame < frames; ++frame ) { _buf[frame][channel] = d * _buf[frame][channel] + w * pp->buffer[frame]; out_sum += _buf[frame][channel] * _buf[frame][channel]; } ++channel; break; case AUDIO_RATE_OUTPUT: case CONTROL_RATE_OUTPUT: break; default: break; } } } if( o_buf != NULL ) { sampleBack( _buf, o_buf, m_maxSampleRate ); } checkGate( out_sum / frames ); bool is_running = isRunning(); m_pluginMutex.unlock(); return( is_running ); }