Exemple #1
0
bool TimeDomainFeatures::saveModelToFile(fstream &file) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_TIME_DOMAIN_FEATURES_FILE_V1.0" << endl;	
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << endl;
        return false;
    }
    
    //Write the time domain settings to the file
    file << "BufferLength: " << bufferLength << endl;
    file << "NumFrames: " << numFrames << endl;
    file << "OffsetInput: " << offsetInput << endl;
    file << "UseMean: " << useMean << endl;
    file << "UseStdDev: " << useStdDev << endl;
    file << "UseEuclideanNorm: " << useEuclideanNorm << endl;
    file << "UseRMS: " << useRMS << endl;
    
    return true;
}
Exemple #2
0
bool KMeansQuantizer::saveModelToFile(fstream &file) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << endl;
        return false;
    }
    
    //First, you should add a header (with no spaces) e.g.
    file << "KMEANS_QUANTIZER_FILE_V1.0" << endl;
	
    //Second, you should save the base feature extraction settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << endl;
        return false;
    }
    
    file << "QuantizerTrained: " << trained << endl;
    file << "NumClusters: " << numClusters << endl;
    
    if( trained ){
        file << "Clusters: \n";
        for(UINT k=0; k<numClusters; k++){
            for(UINT j=0; j<numInputDimensions; j++){
                file << clusters[k][j];
                if( j != numInputDimensions-1 ) file << "\t";
                else file << endl;
            }
        }
    }
    
    return true;
}
Exemple #3
0
bool RBMQuantizer::save( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "save(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    //Write the header
    file << "RBM_QUANTIZER_FILE_V1.0" << std::endl;
    
    //Save the base feature extraction settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    file << "QuantizerTrained: " << trained << std::endl;
    file << "NumClusters: " << numClusters << std::endl;
    
    if( trained ){
        if( !rbm.save( file ) ){
            errorLog << "save(fstream &file) - Failed to save RBM settings to file!" << std::endl;
            return false;
        }
    }
    
    return true;
}
Exemple #4
0
bool KMeansQuantizer::saveModelToFile( std::ostream &file ) const{
    
    //Save the header
    file << "KMEANS_QUANTIZER_FILE_V1.0" << std::endl;
	
    //Save the feature extraction base class settings
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveModelToFile(ostream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    //Save the KMeansQuantizer settings
    file << "QuantizerTrained: " << trained << std::endl;
    file << "NumClusters: " << numClusters << std::endl;
    
    if( trained ){
        file << "Clusters: \n";
        for(UINT k=0; k<numClusters; k++){
            for(UINT j=0; j<numInputDimensions; j++){
                file << clusters[k][j];
                if( j != numInputDimensions-1 ) file << "\t";
                else file << std::endl;
            }
        }
    }
    
    return true;
}
Exemple #5
0
bool FFT::saveModelToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_FFT_FILE_V1.0" << std::endl;
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    //Write the FFT settings
    file << "HopSize: " << hopSize << std::endl;
    file << "FftWindowSize: " << fftWindowSize << std::endl;
    file << "FftWindowFunction: " << fftWindowFunction << std::endl;
    file << "ComputeMagnitude: " << computeMagnitude << std::endl;
    file << "ComputePhase: " << computePhase << std::endl;
    
    return true;
}
Exemple #6
0
bool FFTFeatures::saveModelToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_FFT_FEATURES_FILE_V1.0" << std::endl;
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    //Write the FFT features settings
    file << "FFTWindowSize: " << fftWindowSize << std::endl;
    file << "NumChannelsInFFTSignal: " << numChannelsInFFTSignal << std::endl;
    file << "ComputeMaxFreqFeature: " << computeMaxFreqFeature << std::endl;
    file << "ComputeMaxFreqSpectrumRatio: " << computeMaxFreqSpectrumRatio << std::endl;
    file << "ComputeCentroidFeature: " << computeCentroidFeature << std::endl;	
    file << "ComputeTopNFreqFeatures: " << computeTopNFreqFeatures << std::endl;		
    file << "N: " << N << std::endl;
    
    return true;
}
Exemple #7
0
bool KMeansFeatures::saveModelToFile(fstream &file) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << endl;
        return false;
    }
    
    //First, you should add a header (with no spaces) e.g.
    file << "KMEANS_FEATURES_FILE_V1.0" << endl;
	
    //Second, you should save the base feature extraction settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << endl;
        return false;
    }
    
    file << "NumLayers: " << getNumLayers() << endl;
    file << "NumClustersPerLayer: ";
    for(UINT i=0; i<numClustersPerLayer.size(); i++){
        file << " " << numClustersPerLayer[i];
    }
    file << endl;
    
    file << "Alpha: " << alpha << endl;
    
    if( trained ){
        file << "Ranges: ";
        for(UINT i=0; i<ranges.size(); i++){
            file << ranges[i].minValue << " " << ranges[i].maxValue << " ";
        }
        file << endl;
        
        file << "Clusters: " << endl;
        for(UINT k=0; k<clusters.size(); k++){
            file << "NumRows: " << clusters[k].getNumRows() << endl;
            file << "NumCols: " << clusters[k].getNumCols() << endl;
            for(UINT i=0; i<clusters[k].getNumRows(); i++){
                for(UINT j=0; j<clusters[k].getNumCols(); j++){
                    file << clusters[k][i][j];
                    if( j+1 < clusters[k].getNumCols() )
                        file << "\t";
                }
                file << endl;
            }
        }
    }
    
    return true;
}
Exemple #8
0
bool MovementIndex::saveModelToFile(fstream &file) const {

    if( !file.is_open() ) {
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << endl;
        return false;
    }

    //Write the file header
    file << "GRT_MOVEMENT_INDEX_FILE_V1.0" << endl;

    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ) {
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << endl;
        return false;
    }

    //Write the movement index settings to the file
    file << "BufferLength: " << bufferLength << endl;

    return true;
}
Exemple #9
0
bool TimeseriesBuffer::save( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "save(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_TIMESERIES_BUFFER_FILE_V1.0" << std::endl;
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    //Write the zero crossing counter settings
    file << "BufferSize: " << dataBuffer.getSize() << std::endl;
    
    return true;
}
Exemple #10
0
bool ThresholdDetection::saveModelToFile(fstream &file) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_THRESHOLD_DETECTION_FILE_V1.0" << endl;
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << endl;
        return false;
    }
    
    //Write the time domain settings to the file
    file << "BufferLength: " << bufferLength << endl;
    file << "Alpha: " << alpha << endl;
    file << "Beta: " << beta << endl;
    
    return true;
}
bool ZeroCrossingCounter::saveModelToFile( std::fstream &file ) const{
    
    if( !file.is_open() ){
        errorLog << "saveModelToFile(fstream &file) - The file is not open!" << std::endl;
        return false;
    }
    
    //Write the file header
    file << "GRT_ZERO_CROSSING_COUNTER_FILE_V1.0" << std::endl;
    
    //Save the base settings to the file
    if( !saveFeatureExtractionSettingsToFile( file ) ){
        errorLog << "saveFeatureExtractionSettingsToFile(fstream &file) - Failed to save base feature extraction settings to file!" << std::endl;
        return false;
    }
    
    //Write the zero crossing counter settings
    file << "SearchWindowSize: " << searchWindowSize << std::endl;
    file << "FeatureMode: " << featureMode << std::endl;	
    file << "DeadZoneThreshold: " << deadZoneThreshold << std::endl;		
    
    return true;
}