static void dvidump(void) { unsigned int counter; while(1) { printf("waiting for PLL lock...\n"); while(!dvisampler0_clocking_locked_read()); printf("PLL locked\n"); calibrate_delays(); if(init_phase()) printf("Phase init OK\n"); else printf("Phase did not settle\n"); print_status(); counter = 0; while(dvisampler0_clocking_locked_read()) { counter++; if(counter == 2000000) { print_status(); adjust_phase(); counter = 0; } if(readchar_nonblock() && (readchar() == 'c')) capture_raw(); } printf("PLL unlocked\n"); } }
double bob::ip::gabor::JetStatistics::logLikelihood(const boost::shared_ptr<bob::ip::gabor::Jet> jet, bool estimate_phase, const blitz::TinyVector<double,2>& offset) const{ double q_phase = 0.; double factor = 1.; if (estimate_phase){ // compute the disparity for the given jet auto disp = disparity(jet); // correct disparity (which was computed from integer location) disp[0] -= offset[0] - (int)offset[0]; disp[1] -= offset[1] - (int)offset[1]; // .. and the phase part auto kernels = m_gwt->waveletFrequencies(); auto abs = jet->abs(), phase = jet->phase(); for (int j = jet->length(); j--;){ q_phase += sqr(adjust_phase(phase(j) + kernels[j][0] * disp[0] + kernels[j][1] * disp[1] - m_meanPhase(j))) / m_varPhase(j) * abs(j) / m_varAbs(j); } // q_phase *= blitz::sum(m_varPhase); factor = 2.; } // compute quality measure // .. absolute part blitz::Array<double,1> diff(jet->abs() - m_meanAbs); double q_abs = blitz::sum(diff*diff / m_varAbs); // double q_abs = blitz::sum(diff*diff / m_varAbs) * blitz::sum(m_varAbs); return -(q_abs + q_phase)/(factor*jet->length()); }
static int init_phase(void) { int od0; int i, j; for(i=0;i<100;i++) { od0 = d0; for(j=0;j<1000;j++) adjust_phase(); if(abs(d0 - od0) < 4) return 1; } return 0; }
bob::ip::gabor::JetStatistics::JetStatistics(const std::vector<boost::shared_ptr<bob::ip::gabor::Jet>>& jets, boost::shared_ptr<bob::ip::gabor::Transform> gwt) : m_gwt(gwt) { // compute statistics of Gabor jets // ... get the average Gabor jet bob::ip::gabor::Jet average(jets); int jet_length = average.length(); // ... the phases of the average serve as the mean for the phases m_meanPhase.reference(average.phase()); // ... the average of the absolute values must be comupted separately m_meanAbs.resize(jet_length); m_meanAbs = 0.; for (int j = jet_length; j--;){ for (int i = jets.size(); i--;){ m_meanAbs(j) += jets[i]->abs()(j); } m_meanAbs(j) /= jets.size(); } // ... get variances m_varAbs.resize(jet_length); m_varAbs = 0.; m_varPhase.resize(jet_length); m_varPhase = 0.; for (int j = jet_length; j--;){ for (int i = jets.size(); i--;){ m_varAbs(j) += sqr(jets[i]->abs()(j) - m_meanAbs(j)); m_varPhase(j) += sqr(adjust_phase(jets[i]->phase()(j) - m_meanPhase(j))); } m_varAbs(j) /= jets.size() - 1; m_varPhase(j) /= jets.size() - 1; } }