//-------------------------------------------------------------- void openniTracking::updateOpenCV(){ cleanImage.setFromPixels(depthRangeMaskScaled.getPixels(), _width, _height); ////////////////////////////////////////////// cleanImage.erode(ciErode); cleanImage.dilate(ciDilate); cleanImage.blur(ciBlur); ////////////////////////////////////////////// ////////////////////////////////////////////// // motion detection calculateMotion(); ////////////////////////////////////////////// ////////////////////////////////////////////// // find contours if(computeContourFinder){ runningBlobs = contourFinder.findContours(cleanImage, minBlobArea, maxBlobArea, MAX_NUM_CONTOURS_TO_FIND, false, false); if(runningBlobs > 0 && runningBlobs < MAX_NUM_CONTOURS_TO_FIND){ computeContourAnalysis(); blobTracker.trackBlobs(contourFinder.blobs); } } ////////////////////////////////////////////// ////////////////////////////////////////////// // motion trigger areas if(computeContourFinder && computeTriggerAreas){ if(numPixelsChanged > onHorizon){ // if first blob is inside area... // this is useful when working with laser tracking triggerAreas.isPointInside(box[0].center.x,box[0].center.y); if(lastAreaON != triggerAreas.areaON){ if(actualArea != triggerAreas.areaON){ actualArea = triggerAreas.areaON; // actualArea activated triggerState[actualArea] = !triggerState[actualArea]; } lastTime = ofGetElapsedTimeMillis(); } lastAreaON = triggerAreas.areaON; } if(numPixelsChanged < offHorizon){ if(lastAreaON != -1){ silencePeriod = ofGetElapsedTimeMillis(); // actualArea deactivated after (silencePeriod-lastTime); } lastAreaON = -1; } } ////////////////////////////////////////////// ////////////////////////////////////////////// // apply kalman filter (if selected) to every output value // smoothing & normalize numerical variable // (prepare it for sending via OSC) kalmanFilterValues(); smoothingValues(); normalizeValues(); ////////////////////////////////////////////// }
//--------------------------------------------------------------- void audioInputChannel::captureChannel(float *input){ ///////////////////// // mute/unmute channel if(_mute){ _internalMute = 0.0f; }else{ _internalMute = 1.0f; } ///////////////////// ///////////////////// // capture channel for (unsigned int i = 0; i < bufferSize; i++){ chRaw[i] = input[i*numChannels + chID] * (_volume*_internalMute); } ///////////////////// // autocorrelation + normalization doAutoCorrelation(); // get volume detectVolume(); // get pitch detectPitch(); // parametric eq [normalized radial basis function network] updateFilter(); ///////////////////// // FFT analysis fft_mutex.lock(); if(noiseRec){ fft->setSignal(autoCorrelationNorm); memcpy(fftBins, fft->getAmplitude(), sizeof(float) * fft->getBinSize()); for(unsigned int i = 0; i < fft->getBinSize(); i++){ noiseFilterStep[i] += fftBins[i]; noiseFilter[i] = noiseFilterStep[i]/bufferRecCounter; } bufferRecCounter++; }else{ fft->setSignal(autoCorrelation); memcpy(fftBins, fft->getAmplitude(), sizeof(float) * fft->getBinSize()); fft_StrongestBinValue = 0.0f; for(unsigned int j=0;j<BARK_SCALE_CRITICAL_BANDS;j++){ barkBins[j] = 0.0f; } for(unsigned int i = 0; i < fft->getBinSize(); i++){ // apply noise and parametric eq to fft bins binsFiltered[i] = fftBins[i] * (1.0 - (noiseFilter[i]*reduxFactor)); binsFiltered[i] *= (gaussianFilter[i] + 1.0f); // storing strongest bin for pitch detection if(binsFiltered[i] > fft_StrongestBinValue){ fft_StrongestBinValue = binsFiltered[i]; fft_StrongestBinIndex = i; } // calculate bark scale bins from fft bins updateBarkScale(i); } } fft->setPolar(binsFiltered, fft->getPhase()); fft->clampSignal(); memcpy(chClean, fft->getSignal(), sizeof(float) * fft->getSignalSize()); fft_mutex.unlock(); ///////////////////// ////////////////////////////////////////////// // apply kalman filter (if selected) to every output value // smoothing & normalize numerical variable // (prepare it for sending via OSC) kalmanFilterValues(); smoothingValues(); normalizeValues(); ////////////////////////////////////////////// }