bool FFT::update(const MatrixFloat &x){ if( !initialized ){ errorLog << "update(const MatrixFloat &x) - Not initialized!" << std::endl; return false; } if( x.getNumCols() != numInputDimensions ){ errorLog << "update(const MatrixFloat &x) - The number of columns in the inputMatrix (" << x.getNumCols() << ") does not match that of the FeatureExtraction (" << numInputDimensions << ")!" << std::endl; return false; } featureDataReady = false; for(UINT k=0; k<x.getNumRows(); k++){ //Add the current input to the data buffers dataBuffer.push_back( x.getRow(k) ); if( ++hopCounter == hopSize ){ hopCounter = 0; //Compute the FFT for each dimension for(UINT j=0; j<numInputDimensions; j++){ //Copy the input data for this dimension into the temp buffer for(UINT i=0; i<dataBufferSize; i++){ tempBuffer[i] = dataBuffer[i][j]; } //Compute the FFT if( !fft[j].computeFFT( tempBuffer ) ){ errorLog << "update(const VectorFloat &x) - Failed to compute FFT!" << std::endl; return false; } } //Flag that the fft was computed during this update featureDataReady = true; //Copy the FFT data to the feature vector UINT index = 0; for(UINT j=0; j<numInputDimensions; j++){ if( computeMagnitude ){ Float *mag = fft[j].getMagnitudeDataPtr(); for(UINT i=0; i<fft[j].getFFTSize()/2; i++){ featureVector[index++] = *mag++; } } if( computePhase ){ Float *phase = fft[j].getPhaseDataPtr(); for(UINT i=0; i<fft[j].getFFTSize()/2; i++){ featureVector[index++] = *phase++; } } } } } return true; }
ClassificationData ClassificationDataStream::getClassificationData( const bool includeNullGestures ) const { ClassificationData classificationData; classificationData.setNumDimensions( getNumDimensions() ); classificationData.setAllowNullGestureClass( includeNullGestures ); bool addSample = false; for(UINT i=0; i<timeSeriesPositionTracker.size(); i++){ addSample = includeNullGestures ? true : timeSeriesPositionTracker[i].getClassLabel() != GRT_DEFAULT_NULL_CLASS_LABEL; if( addSample ){ MatrixFloat dataSegment = getTimeSeriesData( timeSeriesPositionTracker[i] ); for(UINT j=0; j<dataSegment.getNumRows(); j++){ classificationData.addSample(timeSeriesPositionTracker[i].getClassLabel(), dataSegment.getRow(j) ); } } } return classificationData; }