Again the code I'm showing is in the old style as it is an example of how I did it for a project last year. I do not know if the new style can also be used for this as on the help page of the codec toolkit one only talks about box algorithms, i.e. it is expected that the template of the codec is a box algorithm, but I would like someone else to confirm this.
If someone of the core team reads this (or anybody else that knows the answer). Can this codec toolkit also be used in the above scenario?
Anyway to explain how I did this, I had to pass a string from my algorithm to my box, you will probably use floats.
In the .h file of your algorithm you need to add input and output parameters
Code: Select all
//you will probably need something of type OpenViBE::Kernel::ParameterType_Float
rAlgorithmPrototype.addInputParameter(OVP_Algorithm_WordPredictionSystem_InputParameterId, "Prefix string", OpenViBE::Kernel::ParameterType_String, NULL);
rAlgorithmPrototype.addOutputParameter(OVP_Algorithm_WordPredictionSystem_OutputParameterId, "Predicted word", OpenViBE::Kernel::ParameterType_String, NULL);
The code in the box algorithm looked like:
Code: Select all
//in- and outputs that will be connected to in- and outputs of your algorithm, instead you will probably need an OpenViBE::float64
OpenViBE::Kernel::TParameterHandler<OpenViBE::CString*> ip_pPrefixString;
OpenViBE::Kernel::TParameterHandler<OpenViBE::CString*> op_pPredictedWord;
//initialization of my algorithm
m_pWordPredictor = &this->getAlgorithmManager().getAlgorithm(this->getAlgorithmManager().createAlgorithm(OVP_ClassId_Algorithm_WordPredictionSystem));
m_pWordPredictor->initialize();
//connecting in- and output variables in the box algorithm to the in- and output of my algorithm ip_pPrefixString.initialize(m_pWordPredictor->getInputParameter(OVP_Algorithm_WordPredictionSystem_InputParameterId));
op_pPredictedWord.initialize(m_pWordPredictor->getOutputParameter(OVP_Algorithm_WordPredictionSystem_OutputParameterId));
Code: Select all
this->m_pWordPredictor->process(OVP_Algorithm_WordPredictionSystem_InputTriggerId_Process);
if(m_pWordPredictor->isOutputTriggerActive(OVP_Algorithm_WordPredictionSystem_OutputTriggerId_Done)) {
//do some stuff
}
You will also need to define triggers (e.g. OVP_Algorithm_WordPredictionSystem_OutputTriggerId_Done) in your algorithm to indicate the processing is done, in your algorithm you do this by activating the trigger
Code: Select all
this->activateOutputTrigger(OVP_Algorithm_WordPredictionSystem_OutputTriggerId_Done, true);
Best regards,
Dieter