diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b0ac0575475a314b3cb9d9827cf043a91e076d..a6b443500c17463b4ddf92016e7bc2ceb91f9f0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ set(RAPIDMIX_FULL_SRC ${RAPIDMIX_SRC} ${JSON_SRC} ) -add_library(RAPID-MIX_API ${RAPIDMIX_FULL_SRC}) +add_library(RAPID-MIX_API SHARED ${RAPIDMIX_FULL_SRC}) add_executable(rapidmixTest tests/rapidMixTest.cpp ) diff --git a/src/machineLearning/rapidGVF/rapidGVF.cpp b/src/machineLearning/rapidGVF/rapidGVF.cpp index adccd071cb0520fa5e364a31a3c3627a05a59ba5..4ac7570c7b9b3e86bfab207ccd439ee6d107813c 100644 --- a/src/machineLearning/rapidGVF/rapidGVF.cpp +++ b/src/machineLearning/rapidGVF/rapidGVF.cpp @@ -78,9 +78,25 @@ std::vector<double> rapidGVF::run(const std::vector<double> &inputVector){ output.push_back(this->outcomes.likeliestGesture); output.insert(output.end(), this->outcomes.likelihoods.begin(), this->outcomes.likelihoods.end()); output.insert(output.end(), this->outcomes.alignments.begin(), this->outcomes.alignments.end()); -// output.insert(output.end(), this->outcomes.dynamics.begin(), this->outcomes.dynamics.end()); -// output.insert(output.end(), this->outcomes.scalings.begin(), this->outcomes.scalings.end()); -// output.insert(output.end(), this->outcomes.rotations.begin(), this->outcomes.rotations.end()); -// return output; } + +const std::vector<float> rapidGVF::getLikelihoods() { + return outcomes.likelihoods; +}; + +const std::vector<float> rapidGVF::getAlignments() { + return outcomes.alignments; +}; + +const std::vector<std::vector<float> > * rapidGVF::getDynamics() { + return &outcomes.dynamics; +}; + +const std::vector<std::vector<float> > * rapidGVF::getScalings() { + return &outcomes.scalings; +}; + +const std::vector<std::vector<float> > * rapidGVF::getRotations() { + return &outcomes.rotations; +}; diff --git a/src/machineLearning/rapidGVF/rapidGVF.h b/src/machineLearning/rapidGVF/rapidGVF.h index f42472f5ff261ff06f6bf8fa44464d3d2ff5b8ed..57b47ad0bfaf2dd90407d55b8f70aa255d032177 100644 --- a/src/machineLearning/rapidGVF/rapidGVF.h +++ b/src/machineLearning/rapidGVF/rapidGVF.h @@ -28,6 +28,12 @@ public: std::vector<double> run(const std::vector<double> &inputVector); //TODO: needs a "reset" message + const std::vector<float> getLikelihoods(); + const std::vector<float> getAlignments(); + const std::vector<std::vector<float> > * getDynamics(); + const std::vector<std::vector<float> > * getScalings(); + const std::vector<std::vector<float> > * getRotations(); + protected: GVF * gvf; GVFGesture currentGesture; diff --git a/tests/src/test_gvf.cpp b/tests/src/test_gvf.cpp index 3eda681879f0ed03fb3710d4e19674862c7818da..be6b9801872ba3448de52133ab4d8aa581791a61 100644 --- a/tests/src/test_gvf.cpp +++ b/tests/src/test_gvf.cpp @@ -11,13 +11,13 @@ #include "rapidMix.h" TEST_CASE( "Tests default GVF ctor.", "[GVF]" ) { - + GVF * gvf = new GVF(); gvf->translate(false); gvf->segmentation(false); REQUIRE(gvf != NULL); - + } TEST_CASE( "Tests default GVFGesture ctor.", "[GVF]" ) { @@ -33,7 +33,7 @@ TEST_CASE( "Tests default GVFGesture ctor.", "[GVF]" ) { gvf->setTolerance(0.2f); gvf->setScalingsVariance(0.00001f); //0.00001f); //0.000002f); //0.00004f); gvf->setDynamicsVariance(0.0001f); - + vector<vector<float>> trainingData; if(gvf->getState() == GVF::STATE_LEARNING) @@ -64,12 +64,12 @@ TEST_CASE( "Tests default GVFGesture ctor.", "[GVF]" ) { gvf->update(gesture.getLastObservation()); } -// float phase = gvf->getOutcomes().estimations[0].alignment; -// float speed = gvf->getOutcomes().estimations[0].dynamics[0]; -// -// getDynamicsVariance(); -// getScalingsVariance(); -// getRotationsVariance(); + // float phase = gvf->getOutcomes().estimations[0].alignment; + // float speed = gvf->getOutcomes().estimations[0].dynamics[0]; + // + // getDynamicsVariance(); + // getScalingsVariance(); + // getRotationsVariance(); REQUIRE( gvf != NULL); @@ -144,26 +144,27 @@ SCENARIO("Test GVF Regression", "[machineLearning]") // The assumtion for the test is that the outcome of the last segment of the test gesture must converge REQUIRE(outcomes[0] == 0); // outcomes[0] - likeliestGesture must be equal to first gesture '0' - REQUIRE(outcomes[1] > 0.5); // outcomes[1] - likelihood gesture '0' must be greater than 50% - REQUIRE(outcomes[2] < 0.5); // outcomes[2] - likelihood gesture '1' must be lesser than 50% -// REQUIRE(outcomes[3] < 0.5); // outcomes[3] - alignment gesture '0' must be lesser than 50% -// REQUIRE(outcomes[4] < 0.5); // outcomes[4] - alignment gesture '1' must be lesser than 50% + REQUIRE(gvf.getLikelihoods()[0] > 0.5); // outcomes[1] - likelihood gesture '0' must be greater than 50% + REQUIRE(gvf.getLikelihoods()[1] < 0.5); // outcomes[2] - likelihood gesture '1' must be lesser than 50% + REQUIRE(gvf.getAlignments()[0] < 0.5); // outcomes[3] - alignment gesture '0' must be lesser than 50% + // REQUIRE(outcomes[4] < 0.5); // outcomes[4] - alignment gesture '1' must be lesser than 50% + } - } - - WHEN("when gvf is trained with two gestures") - { - THEN("gvf follows the test gesture (first gesture scaled) and confirm it is the likeliestGesture and likelihoods anc reasonable ") + + WHEN("when gvf is trained with two gestures") { - + THEN("gvf follows the test gesture (first gesture scaled) and confirm it is the likeliestGesture and likelihoods anc reasonable ") + { + + } } - } - - WHEN("when gvf is trained with two gestures") - { - THEN("gvf follows the test gesture (first gesture scaled) and confirm it is the likeliestGesture and likelihoods anc reasonable ") + + WHEN("when gvf is trained with two gestures") { - + THEN("gvf follows the test gesture (first gesture scaled) and confirm it is the likeliestGesture and likelihoods anc reasonable ") + { + + } } } } diff --git a/tests/test_project.xcodeproj/project.pbxproj b/tests/test_project.xcodeproj/project.pbxproj index 56340d92de4818946f4c887038da9487b1112bb7..2b40e7d71e4becfdfd5fff6cbba4caac6c57ee36 100644 --- a/tests/test_project.xcodeproj/project.pbxproj +++ b/tests/test_project.xcodeproj/project.pbxproj @@ -66,6 +66,10 @@ 319C94BB1FC5C1200055BE40 /* rta_int.c in Sources */ = {isa = PBXBuildFile; fileRef = 319C940E1FC49C990055BE40 /* rta_int.c */; }; 319C94BC1FC5C1200055BE40 /* rta_util.c in Sources */ = {isa = PBXBuildFile; fileRef = 319C94141FC49C990055BE40 /* rta_util.c */; }; 31A8F1971F4ECF3300CA8CEC /* rapidXMM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A8F1941F4ECD1200CA8CEC /* rapidXMM.cpp */; }; + BE0AC6251FD17669008056E6 /* BayesianFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93ED1FC49B5C0055BE40 /* BayesianFilter.cpp */; }; + BE0AC6261FD1766D008056E6 /* filter_utilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93EF1FC49B5C0055BE40 /* filter_utilities.cpp */; }; + BE0AC6271FD1768D008056E6 /* BayesianFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93ED1FC49B5C0055BE40 /* BayesianFilter.cpp */; }; + BE0AC6281FD17690008056E6 /* filter_utilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93EF1FC49B5C0055BE40 /* filter_utilities.cpp */; }; BE5733061F505ECC0063F4D1 /* machineLearning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5EBE1ED8459300E9FAFA /* machineLearning.cpp */; }; BE5733071F505F190063F4D1 /* rapidGVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BE2E7351EE56F4F00722712 /* rapidGVF.cpp */; }; BE5733081F505F310063F4D1 /* GVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BE2E72F1EE56E6D00722712 /* GVF.cpp */; }; @@ -1235,6 +1239,8 @@ 0BA41BAD1EE6E0ED00B74667 /* trainingData.cpp in Sources */, BE5733061F505ECC0063F4D1 /* machineLearning.cpp in Sources */, BE5733111F505FDC0063F4D1 /* libsvm.cpp in Sources */, + BE0AC6271FD1768D008056E6 /* BayesianFilter.cpp in Sources */, + BE0AC6281FD17690008056E6 /* filter_utilities.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1299,6 +1305,8 @@ BE9286491EF015AE006847CF /* test_signalProcessing.cpp in Sources */, BEA7B71E1EDD963E0003E84B /* maximilian.cpp in Sources */, BE92864D1EF01622006847CF /* rapidStream.cpp in Sources */, + BE0AC6251FD17669008056E6 /* BayesianFilter.cpp in Sources */, + BE0AC6261FD1766D008056E6 /* filter_utilities.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };