MCPcopy Create free account
hub / github.com/MTG/essentia / PCA

Function PCA

src/examples/python/streaming_extractor/streaming_extractorutils.cpp:208–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206
207
208void PCA(Pool& pool, const string& nspace) {
209
210 // namespace:
211 string llspace = "lowlevel.";
212 if (!nspace.empty()) llspace = nspace + ".lowlevel.";
213
214 vector<vector<Real> > sccoeffs = pool.value<vector<vector<Real> > >(llspace + "sccoeffs");
215 vector<vector<Real> > scvalleys = pool.value<vector<vector<Real> > >(llspace + "scvalleys");
216
217 Pool poolSc, poolTransformed;
218
219 for (int iFrame = 0; iFrame < (int)sccoeffs.size(); iFrame++) {
220 vector<Real> merged(2*sccoeffs[iFrame].size(), 0.0);
221 for(int i=0, j=0; i<(int)sccoeffs[iFrame].size(); i++, j++) {
222 merged[j++] = sccoeffs[iFrame][i];
223 merged[j] = scvalleys[iFrame][i];
224 }
225 poolSc.add("contrast", merged);
226 }
227
228 standard::Algorithm* pca = standard::AlgorithmFactory::create("PCA",
229 "namespaceIn", "contrast",
230 "namespaceOut", "contrast");
231 pca->input("poolIn").set(poolSc);
232 pca->output("poolOut").set(poolTransformed);
233 pca->compute();
234
235 pool.set(llspace + "spectral_contrast.mean",
236 meanFrames(poolTransformed.value<vector<vector<Real> > >("contrast")));
237 pool.set(llspace + "spectral_contrast.var",
238 varianceFrames(poolTransformed.value<vector<vector<Real> > >("contrast")));
239
240 // remove original data from spectral contrast:
241 pool.remove(llspace + "sccoeffs");
242 pool.remove(llspace + "scvalleys");
243 delete pca;
244}
245
246// Add missing descriptors which are not computed yet, but will be for the
247// final release or during the 1.x cycle. However, the schema need to be

Callers 1

PostProcessFunction · 0.70

Calls 9

createFunction · 0.85
meanFramesFunction · 0.85
varianceFramesFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.45
addMethod · 0.45
setMethod · 0.45
computeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected