Commit 730b713f authored by Jussi Lindgren's avatar Jussi Lindgren
Browse files

Plugins: Classification is now more strict with the version checking

parent abf3f45a
......@@ -406,7 +406,7 @@
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename to save configuration to</Name>
<DefaultValue>${Path_UserData}/my-classifier.xml</DefaultValue>
<Value>${Path_UserData}/my-classifier.xml</Value>
<Value>${Path_UserData}/classification-training-tutorial-model.xml</Value>
<Modifiability>false</Modifiability>
</Setting>
<Setting>
......@@ -491,7 +491,7 @@
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>384.000000</Value>
<Value>383.000000</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
......@@ -1418,7 +1418,7 @@
</Attribute>
<Attribute>
<Identifier>(0x358ae8b5, 0x0f8bacd1)</Identifier>
<Value>384</Value>
<Value>383</Value>
</Attribute>
<Attribute>
<Identifier>(0x3f0a3b27, 0x570913d2)</Identifier>
......@@ -1455,7 +1455,7 @@
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>406</Value>
<Value>405</Value>
</Attribute>
</Attributes>
</Link>
......@@ -1600,7 +1600,7 @@
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>361</Value>
<Value>360</Value>
</Attribute>
</Attributes>
</Link>
......@@ -1716,7 +1716,7 @@
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>376</Value>
<Value>375</Value>
</Attribute>
</Attributes>
</Link>
......@@ -1803,7 +1803,7 @@
</Attribute>
<Attribute>
<Identifier>(0x6267b5c5, 0x676e3e42)</Identifier>
<Value>391</Value>
<Value>390</Value>
</Attribute>
</Attributes>
</Link>
......
<OpenViBE-Classifier-Box XMLVersion="3">
<OpenViBE-Classifier-Box FormatVersion="4">
<Strategy-Identifier class-id="(0xffffffff, 0xffffffff)">Native</Strategy-Identifier>
<Algorithm-Identifier class-id="(0x2ba17a3c, 0x1bd46d84)">Linear Discrimimant Analysis (LDA)</Algorithm-Identifier>
<Stimulations>
......
......@@ -33,22 +33,29 @@ boolean CBoxAlgorithmClassifierProcessor::loadClassifier(const char* sFilename)
m_vStimulation.clear();
//Now check the version, and let's display a message if the version is not good
// Check the version of the file
string l_sVersion;
if(l_pRootNode->hasAttribute(c_sXmlVersionAttributeName))
if(l_pRootNode->hasAttribute(c_sFormatVersionAttributeName))
{
l_sVersion = l_pRootNode->getAttribute(c_sXmlVersionAttributeName);
l_sVersion = l_pRootNode->getAttribute(c_sFormatVersionAttributeName);
std::stringstream l_sData(l_sVersion);
uint32 l_ui32Version;
l_sData >> l_ui32Version;
if(l_ui32Version != OVP_Classification_BoxTrainerXMLVersion)
if(l_ui32Version > OVP_Classification_BoxTrainerFormatVersion)
{
this->getLogManager() << LogLevel_Warning << "The configuration file doesn't have the same version number as the box. Trouble may appear in loading process.\n";
this->getLogManager() << LogLevel_Warning << "The classifier configuration in [" << sFilename << "] was saved using a newer version of OpenViBE. Problems may occur.\n";
}
else if(l_ui32Version < OVP_Classification_BoxTrainerFormatVersionRequired)
{
this->getLogManager() << LogLevel_Error << "The classifier configuration in [" << sFilename << "] has XML version " << l_ui32Version << " but version " << OVP_Classification_BoxTrainerFormatVersionRequired
<< " is required. Please retrain the classifier using your current OpenViBE version.\n";
return false;
}
}
else
{
this->getLogManager() << LogLevel_Warning << "The configuration file has no version information. Trouble may appear in loading process.\n";
this->getLogManager() << LogLevel_Error << "The configuration file [" << sFilename << "] has no version information. Please retrain your classifier using your current OpenViBE version.\n";
return false;
}
CIdentifier l_oAlgorithmClassIdentifier = OV_UndefinedIdentifier;
......
......@@ -17,7 +17,11 @@
//This needs to reachable from outside
const char* const c_sClassifierRoot = "OpenViBE-Classifier";
const char* const c_sXmlVersionAttributeName = "XMLVersion";
const char* const c_sFormatVersionAttributeName = "FormatVersion";
const char* const c_sCreatorAttributeName = "Creator";
const char* const c_sCreatorVersionAttributeName = "CreatorVersion";
const char* const c_sIdentifierAttributeName = "class-id";
const char* const c_sStrategyNodeName = "Strategy-Identifier";
......@@ -649,9 +653,14 @@ boolean CBoxAlgorithmClassifierTrainer::saveConfiguration(void)
XML::IXMLNode *l_sRoot = XML::createNode(c_sClassificationBoxRoot);
std::stringstream l_sVersion;
l_sVersion << OVP_Classification_BoxTrainerXMLVersion;
l_sRoot->addAttribute(c_sXmlVersionAttributeName, l_sVersion.str().c_str());
l_sVersion << OVP_Classification_BoxTrainerFormatVersion;
l_sRoot->addAttribute(c_sFormatVersionAttributeName, l_sVersion.str().c_str());
l_sRoot->addAttribute(c_sCreatorAttributeName, OV_PROJECT_NAME);
std::stringstream l_sCreatorVersion;
l_sCreatorVersion << OV_VERSION_MAJOR << "." << OV_VERSION_MINOR << "." << OV_VERSION_PATCH;
l_sRoot->addAttribute(c_sCreatorVersionAttributeName, l_sCreatorVersion.str().c_str());
XML::IXMLNode *l_pTempNode = XML::createNode(c_sStrategyNodeName);
l_oStrategyClassIdentifier = this->getTypeManager().getEnumerationEntryValueFromName(OVTK_TypeId_ClassificationStrategy, (*m_pParameter)[c_sMulticlassStrategySettingName]);
......
#ifndef __OpenViBEPlugins_Defines_H__
#define __OpenViBEPlugins_Defines_H__
#define OVP_Classification_BoxTrainerXMLVersion 3
#define OVP_Classification_BoxTrainerFormatVersion 4
#define OVP_Classification_BoxTrainerFormatVersionRequired 4
//___________________________________________________________________//
// //
......@@ -29,7 +30,7 @@
#define OVP_TypeId_ClassificationPairwiseStrategy OpenViBE::CIdentifier(0x0DD51C74, 0x3C4E74C9)
extern const char* const c_sXmlVersionAttributeName;
extern const char* const c_sFormatVersionAttributeName;
extern const char* const c_sIdentifierAttributeName;
extern const char* const c_sStrategyNodeName;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment