Problem using "addSample" while compiling
hadarszostak opened this issue · comments
Hi,
background:
I followed the build workflow in this Link to compile on Linux, I'm using a Raspberry pi. The Build was applied with Shared Library option.
I had a problem after Build that libgrt.so wasn't located at "/usr/lib/arm-linux-gnueabihf" so I wasn't be able to run the GRT examples. I found the libgrt.so at "/usr/local/lib" and copied it to "/usr/lib/arm-linux-gnueabihf", then I was able to run some examples with databases like IrisData.grt
The GRT library is located at /usr/local/include/GRT.
End of background
while compiling the below lines I encountered a problem: (Short version of the code with only necessary code lines for understanding)
#include "GRT/GRT.h"
#include <vector>
using manespace GRT;
int main(){
ClassificationData trainingData;
GestureRecognitionPipeline pipeline;
pipeline.addPreProcessingModule(MovingAverageFilter(5,1));
pipeline.addFeatureExtractionModule(FFT(512));
pipeline.setClassifier(ANBC());
pipeline.addPostProcessingModule( ClassLabelTimeoutFilter(1000) );
trainingData.setNumDimensions( 1 );
UINT gestureLabel = 1;
std::vector< double > DataToRecognize (1)={1,2,3,4,5,6};
trainingData.addSample( gestureLabel, DataToRecognize );
bool saveResult = trainingData.save( "TrainingData.grt" );
bool loadResult = trainingData.load( "TrainingData.grt" );
}
Building this using g++ -g -Wall -std=c++11 -o "main" "Main.cpp" -l grt
Removing the Lines :
trainingData.addSample( gestureLabel, DataToRecognize );
bool saveResult = trainingData.save( "TrainingData.grt" );
bool loadResult = trainingData.load( "TrainingData.grt" );
Results with a good Compiling and Building session.
But adding these lines, results with the following compilation errors :
Main.cpp: In function ‘int main()’:
Main.cpp:94:56: error: no matching function for call to ‘GRT::ClassificationData::addSample(GRT::UINT&, std::vector<double>&)’
trainingData.addSample( gestureLabel, DataToRecognize );
^
Main.cpp:94:56: note: candidate is:
In file included from /usr/local/include/GRT/CoreModules/MLBase.h:33:0,
from /usr/local/include/GRT/CoreModules/PreProcessing.h:34,
from /usr/local/include/GRT/PreProcessingModules/DoubleMovingAverageFilter.h:31,
from /usr/local/include/GRT/Util/PeakDetection.h:13,
from /usr/local/include/GRT/GRT.h:60,
from Main.cpp:14:
/usr/local/include/GRT/DataStructures/ClassificationData.h:163:10: note: bool GRT::ClassificationData::addSample(GRT::UINT, const GRT::VectorFloat&)
bool addSample(const UINT classLabel,const VectorFloat &sample);
^
/usr/local/include/GRT/DataStructures/ClassificationData.h:163:10: note: no known conversion for argument 2 from ‘std::vector<double>’ to ‘const GRT::VectorFloat&’
Main.cpp:96:7: warning: unused variable ‘saveResult’ [-Wunused-variable]
bool saveResult = trainingData.save( "TrainingData.grt" );
^
Main.cpp:98:7: warning: unused variable ‘loadResult’ [-Wunused-variable]
bool loadResult = trainingData.load( "TrainingData.grt" );
^
Compilation failed.
Need help here please. multiple candidates are detected to "addSample" and I have no idea how to solve this.
Nick,
Thanks for sharing the GRT, great "Getting Started" page.
Edit:
After I solved the problem, Please consider changing "Getting Started" page with the solution:
std::vector< double > sample(1);
To
VectorFloat sample(1);
Solved,
Reading the compiling error, there was a problem with input parameters of "addSample":
no matching function for call to ‘GRT::ClassificationData::addSample(GRT::UINT&, std::vector<double>&)
Vs.
bool GRT::ClassificationData::addSample(GRT::UINT, const GRT::VectorFloat&)
Changing:
std::vector< double > DataToRecognize (1)={1,2,3,4,5,6};
To:
VectorFloat DataToRecognize(1);
As for GRT::UINT&
vs GRT::UINT
, I did nothing to solve that. To be more accurate I passed (UINT)1
and then get back to gestureLabel
parameter.