float SVMClassifier::predict( const cv::Mat_<float>& z) const { if ( svmp.isLinear()) return (z.dot(linx) - b)/linx.total(); // Normalise by the vector length double result = -b; KernelThreadFunc ktf( as, kernel, xs); ktf.calcResult( 0, numSVs, &z); result += ktf.getResult(); return result / z.total(); /* static const int nthreads = boost::thread::hardware_concurrency(); // CPU threads available const int segSz = numSVs / nthreads; int rem = numSVs % nthreads; boost::thread_group tgroup; vector<KernelThreadFunc*> tobjs(nthreads); int segOffset = 0; for ( int i = 0; i < nthreads; ++i) { int ssz = segSz; if ( rem > 0) { ssz++; rem--; } // end if tobjs[i] = new KernelThreadFunc( as, kernel, xs); tgroup.create_thread( boost::bind( &KernelThreadFunc::calcResult, tobjs[i], segOffset, ssz, &z)); // Start thread segOffset += ssz; // Offset for next thread } // end for tgroup.join_all(); // All processing done // Collect the result for return for ( int i = 0; i < nthreads; ++i) { result += tobjs[i]->getResult(); delete tobjs[i]; } // end for return result / z.total(); // Normalise by the vector length */ } // end predict
/** * @brief Gabor filtering * @ref http://en.wikipedia.org/wiki/Gabor_filter */ float VO_Gabor::VO_GaborFiltering(const cv::Mat_<float>& iImg) { return iImg.dot(this->m_VOWindowFunc->m_MatWindowedKernel); }