Commit 9d5afb7f authored by Jussi Lindgren's avatar Jussi Lindgren

Plugins: Removed unused versions of the Spatial Filter code

parent 5812dda2
#if 0
#include "ovpCApplySpatialFilter.h"
#include <cmath>
#include <system/ovCMemory.h>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;
using namespace std;
// ________________________________________________________________________________________________________________
//
boolean CApplySpatialFilter::initialize(void)
{
m_oSignalIntputMatrixHandle.initialize(getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix));
m_oFilterCoefficientsInputMatrixHandle.initialize(getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix));
m_oSignalOutputMatrixHandle.initialize(getOutputParameter(OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix));
m_bActive=true;
return true;
}
boolean CApplySpatialFilter::uninitialize(void)
{
m_oSignalIntputMatrixHandle.uninitialize();
m_oFilterCoefficientsInputMatrixHandle.uninitialize();
m_oSignalOutputMatrixHandle.uninitialize();
return true;
}
// ________________________________________________________________________________________________________________
//
boolean CApplySpatialFilter::process(void)
{
if(!m_bActive)
{
return false;
}
IMatrix* l_pFilterCoefficientsInputMatrix = m_oFilterCoefficientsInputMatrixHandle;
IMatrix* l_pSignalInputMatrix = m_oSignalIntputMatrixHandle;
IMatrix* l_pSignalOutputMatrix = m_oSignalOutputMatrixHandle;
// dimensions of the filter coefficients matrix
uint32 l_ui32FilterCoefficientsLineDimensionSize=m_oFilterCoefficientsInputMatrixHandle->getDimensionSize(0);
uint32 l_ui32FilterCoefficientsColumnDimensionSize=m_oFilterCoefficientsInputMatrixHandle->getDimensionSize(1);
// dimensions of the input buffer of signal
uint32 l_ui32SignalInputMatrixDimensionCount=m_oSignalIntputMatrixHandle->getDimensionCount();
uint32 l_ui32SignalInputLineDimensionSize=m_oSignalIntputMatrixHandle->getDimensionSize(0);
uint32 l_ui32SignalInputColumnDimensionSize=m_oSignalIntputMatrixHandle->getDimensionSize(1);
if(l_ui32FilterCoefficientsColumnDimensionSize != l_ui32SignalInputLineDimensionSize)
{
getLogManager() << LogLevel_ImportantWarning << "Bad matrix size - number of column of filter coefficients = " << l_ui32FilterCoefficientsColumnDimensionSize << " while Number of Line of Signal = " << l_ui32SignalInputLineDimensionSize << "\n";
m_bActive=false;
return false;
}
// Input vars
float64* l_pSignalInput = l_pSignalInputMatrix->getBuffer();
float64* l_pFilterCoefficientsInput = l_pFilterCoefficientsInputMatrix->getBuffer();
// signal output vars
l_pSignalOutputMatrix->setDimensionCount(l_ui32SignalInputMatrixDimensionCount);
l_pSignalOutputMatrix->setDimensionSize(0,l_ui32FilterCoefficientsLineDimensionSize);
l_pSignalOutputMatrix->setDimensionSize(1,l_ui32SignalInputColumnDimensionSize);
//~ l_pOutputMatrix->setDimensionLabel(indexDimension, indexSize, label);
float64* l_pSignalOutput = l_pSignalOutputMatrix->getBuffer();
if(isInputTriggerActive(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize))
{
for (uint64 i=0; i < l_ui32SignalInputColumnDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32FilterCoefficientsLineDimensionSize; j++)
{
l_pSignalOutput[i*l_ui32FilterCoefficientsLineDimensionSize+j]=0;
}
}
}
if(isInputTriggerActive(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter))
{
for (uint64 i=0; i < l_ui32SignalInputColumnDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32FilterCoefficientsLineDimensionSize; j++)
{
l_pSignalOutput[i*l_ui32FilterCoefficientsLineDimensionSize+j]=0;
}
}
for (uint64 i=0; i < l_ui32FilterCoefficientsLineDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32SignalInputColumnDimensionSize; j++)
{
for (uint64 k=0; k< l_ui32FilterCoefficientsColumnDimensionSize; k++)
{
l_pSignalOutput[i*l_ui32SignalInputColumnDimensionSize+j] = l_pFilterCoefficientsInput[k+l_ui32FilterCoefficientsColumnDimensionSize*i]*l_pSignalInput[j+k*l_ui32SignalInputColumnDimensionSize]+l_pSignalOutput[i*l_ui32SignalInputColumnDimensionSize+j];
}
}
}
}
return true;
}
#endif
#if 0
#ifndef __OpenViBEPlugins_SignalProcessing_Algorithms_Filter_CApplySpatialFilter_H__
#define __OpenViBEPlugins_SignalProcessing_Algorithms_Filter_CApplySpatialFilter_H__
#include "../../ovp_defines.h"
#include <openvibe/ov_all.h>
#include <toolkit/ovtk_all.h>
namespace OpenViBEPlugins
{
namespace SignalProcessing
{
class CApplySpatialFilter : virtual public OpenViBEToolkit::TAlgorithm < OpenViBE::Plugins::IAlgorithm >
{
public:
virtual void release(void) { delete this; }
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean process(void);
_IsDerivedFromClass_Final_(OpenViBEToolkit::TAlgorithm < OpenViBE::Plugins::IAlgorithm >, OVP_ClassId_Algorithm_ApplySpatialFilter);
protected:
OpenViBE::Kernel::TParameterHandler < OpenViBE::IMatrix* > m_oSignalIntputMatrixHandle;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IMatrix* > m_oFilterCoefficientsInputMatrixHandle;
OpenViBE::Kernel::TParameterHandler < OpenViBE::IMatrix* > m_oSignalOutputMatrixHandle;
OpenViBE::boolean m_bActive;
OpenViBE::CMatrix* m_vInputMatrixCache;
};
class CApplySpatialFilterDesc : virtual public OpenViBE::Plugins::IAlgorithmDesc
{
public:
virtual void release(void) { }
virtual OpenViBE::CString getName(void) const { return OpenViBE::CString("Apply spatial filter"); }
virtual OpenViBE::CString getAuthorName(void) const { return OpenViBE::CString("Guillaume Gibert"); }
virtual OpenViBE::CString getAuthorCompanyName(void) const { return OpenViBE::CString("INSERM/U821"); }
virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("Signal processing/Filtering"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("1.0"); }
virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_Algorithm_ApplySpatialFilter; }
virtual OpenViBE::Plugins::IPluginObject* create(void) { return new OpenViBEPlugins::SignalProcessing::CApplySpatialFilter(); }
virtual OpenViBE::boolean getAlgorithmPrototype(
OpenViBE::Kernel::IAlgorithmProto& rAlgorithmProto) const
{
rAlgorithmProto.addInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix, "Signal Input matrix", OpenViBE::Kernel::ParameterType_Matrix);
rAlgorithmProto.addInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix, "Spatial Filter matrix", OpenViBE::Kernel::ParameterType_Matrix);
rAlgorithmProto.addOutputParameter(OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix, "Signal Output matrix", OpenViBE::Kernel::ParameterType_Matrix);
rAlgorithmProto.addInputTrigger(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize, "Initialize");
rAlgorithmProto.addInputTrigger(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter, "Apply filter");
return true;
}
_IsDerivedFromClass_Final_(OpenViBE::Plugins::IAlgorithmDesc, OVP_ClassId_Algorithm_ApplySpatialFilterDesc);
};
};
};
#endif // __OpenViBEPlugins_SignalProcessing_Algorithms_Filter_CApplySpatialFilter_H__
#endif
#if 0
#include "ovpCSpatialFilterBoxAlgorithm.h"
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;
using namespace std;
boolean CSpatialFilterBoxAlgorithm::initialize(void)
{
CIdentifier l_oInputTypeIdentifier;
getStaticBoxContext().getInputType(0, l_oInputTypeIdentifier);
if(l_oInputTypeIdentifier==OV_TypeId_Signal)
{
m_pStreamDecoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalStreamDecoder));
m_pStreamEncoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalStreamEncoder));
}
else
{
return false;
}
m_pStreamDecoder->initialize();
m_pStreamEncoder->initialize();
// Apply filter to signal input buffer
m_pApplySpatialFilter=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_ClassId_Algorithm_ApplySpatialFilter));
m_pApplySpatialFilter->initialize();
if(l_oInputTypeIdentifier==OV_TypeId_Signal)
{
m_pStreamEncoder->getInputParameter(OVP_GD_Algorithm_SignalStreamEncoder_InputParameterId_SamplingRate)->setReferenceTarget(m_pStreamDecoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamDecoder_OutputParameterId_SamplingRate));
}
// compute filter coefs settings
CString l_oParameters;
CString l_oNbLine;
CString l_oNbColumn;
getStaticBoxContext().getSettingValue(0, l_oParameters);
getStaticBoxContext().getSettingValue(1, l_oNbLine);
getStaticBoxContext().getSettingValue(2, l_oNbColumn);
uint64 l_ui64NbLine = atoi(l_oNbLine);
uint64 l_ui64NbColumn = atoi(l_oNbColumn);
istringstream l_oStreamString((const char*)l_oParameters);
float64 l_f64CurrentValue;
while(l_oStreamString>>l_f64CurrentValue)
{
m_oCoefficients.push_back(l_f64CurrentValue);
}
TParameterHandler<IMatrix*> ip_pFilterCoefficientsInputMatrix(m_pApplySpatialFilter->getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix));
ip_pFilterCoefficientsInputMatrix->setDimensionCount(2);
ip_pFilterCoefficientsInputMatrix->setDimensionSize(0, (uint32)l_ui64NbLine);
ip_pFilterCoefficientsInputMatrix->setDimensionSize(1, (uint32)l_ui64NbColumn);
float64* l_pFilterCoefficientsInput = ip_pFilterCoefficientsInputMatrix->getBuffer();
for (uint32 i = 0; i<m_oCoefficients.size(); i++)
{
l_pFilterCoefficientsInput[i] = m_oCoefficients[i];
}
// apply filter settings
m_pApplySpatialFilter->getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix)->setReferenceTarget(m_pStreamDecoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamDecoder_OutputParameterId_Matrix));
m_pStreamEncoder->getInputParameter(OVP_GD_Algorithm_SignalStreamEncoder_InputParameterId_Matrix)->setReferenceTarget(m_pApplySpatialFilter->getOutputParameter(OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix));
return true;
}
boolean CSpatialFilterBoxAlgorithm::uninitialize(void)
{
m_pApplySpatialFilter->uninitialize();
m_pStreamEncoder->uninitialize();
m_pStreamDecoder->uninitialize();
getAlgorithmManager().releaseAlgorithm(*m_pApplySpatialFilter);
getAlgorithmManager().releaseAlgorithm(*m_pStreamEncoder);
getAlgorithmManager().releaseAlgorithm(*m_pStreamDecoder);
return true;
}
boolean CSpatialFilterBoxAlgorithm::processInput(uint32 ui32InputIndex)
{
getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
return true;
}
boolean CSpatialFilterBoxAlgorithm::process(void)
{
IBoxIO& l_rDynamicBoxContext=getDynamicBoxContext();
IBox& l_rStaticBoxContext=getStaticBoxContext();
for(uint32 i=0; i<l_rStaticBoxContext.getInputCount(); i++)
{
for(uint32 j=0; j<l_rDynamicBoxContext.getInputChunkCount(i); j++)
{
TParameterHandler < const IMemoryBuffer* > l_oInputMemoryBufferHandle(m_pStreamDecoder->getInputParameter(OVP_GD_Algorithm_SignalStreamDecoder_InputParameterId_MemoryBufferToDecode));
TParameterHandler < IMemoryBuffer* > l_oOutputMemoryBufferHandle(m_pStreamEncoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamEncoder_OutputParameterId_EncodedMemoryBuffer));
l_oInputMemoryBufferHandle=l_rDynamicBoxContext.getInputChunk(i, j);
l_oOutputMemoryBufferHandle=l_rDynamicBoxContext.getOutputChunk(i);
m_pStreamDecoder->process();
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedHeader))
{
m_pApplySpatialFilter->process(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize);
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeHeader);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedBuffer))
{
m_pApplySpatialFilter->process(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter);
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeBuffer);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedEnd))
{
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeEnd);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
l_rDynamicBoxContext.markInputAsDeprecated(i, j);
}
}
return true;
}
#endif
#if 0
#ifndef __OpenViBEPlugins_SignalProcessing_BoxAlgorithms_Filter_CSpatialFilterBoxAlgorithm_H__
#define __OpenViBEPlugins_SignalProcessing_BoxAlgorithms_Filter_CSpatialFilterBoxAlgorithm_H__
#include "../../ovp_defines.h"
#include <toolkit/ovtk_all.h>
#define OVP_ClassId_Box_SpatialFilterBoxAlgorithm OpenViBE::CIdentifier(0xDD332C6C, 0x195B4FD4)
#define OVP_ClassId_Box_SpatialFilterBoxAlgorithmDesc OpenViBE::CIdentifier(0x72A01C92, 0xF8C1FA24)
namespace OpenViBEPlugins
{
namespace SignalProcessing
{
class CSpatialFilterBoxAlgorithm : virtual public OpenViBEToolkit::TBoxAlgorithm<OpenViBE::Plugins::IBoxAlgorithm>
{
public:
virtual void release(void) { delete this; }
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean processInput(OpenViBE::uint32 ui32InputIndex);
virtual OpenViBE::boolean process(void);
_IsDerivedFromClass_Final_(OpenViBEToolkit::TBoxAlgorithm<OpenViBE::Plugins::IBoxAlgorithm>, OVP_ClassId_Box_SpatialFilterBoxAlgorithm)
protected:
OpenViBE::Kernel::IAlgorithmProxy* m_pStreamDecoder;
OpenViBE::Kernel::IAlgorithmProxy* m_pStreamEncoder;
OpenViBE::Kernel::IAlgorithmProxy* m_pApplySpatialFilter;
std::vector<OpenViBE::float64> m_oCoefficients;
};
class CSpatialFilterBoxAlgorithmDesc : virtual public OpenViBE::Plugins::IBoxAlgorithmDesc
{
public:
virtual void release(void) { }
virtual OpenViBE::CString getName(void) const { return OpenViBE::CString("Spatial filter Deprecated"); }
virtual OpenViBE::CString getAuthorName(void) const { return OpenViBE::CString("Guillaume Gibert"); }
virtual OpenViBE::CString getAuthorCompanyName(void) const { return OpenViBE::CString("INSERM/U821"); }
virtual OpenViBE::CString getShortDescription(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CString getDetailedDescription(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CString getCategory(void) const { return OpenViBE::CString("Signal processing/Filtering"); }
virtual OpenViBE::CString getVersion(void) const { return OpenViBE::CString("1.0"); }
virtual OpenViBE::CString getStockItemName(void) const { return OpenViBE::CString(""); }
virtual OpenViBE::CIdentifier getCreatedClass(void) const { return OVP_ClassId_Box_SpatialFilterBoxAlgorithm; }
virtual OpenViBE::Plugins::IPluginObject* create(void) { return new OpenViBEPlugins::SignalProcessing::CSpatialFilterBoxAlgorithm; }
virtual OpenViBE::boolean getBoxPrototype(
OpenViBE::Kernel::IBoxProto& rPrototype) const
{
rPrototype.addInput("Input signal", OV_TypeId_Signal);
rPrototype.addOutput("Filtered signal", OV_TypeId_Signal);
rPrototype.addSetting("Spatial filter coefficients", OV_TypeId_String, "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1");
rPrototype.addSetting("Number of output channels", OV_TypeId_Integer, "4");
rPrototype.addSetting("Number of input channels", OV_TypeId_Integer, "4");
return true;
}
_IsDerivedFromClass_Final_(OpenViBE::Plugins::IBoxAlgorithmDesc, OVP_ClassId_Box_SpatialFilterBoxAlgorithmDesc)
};
};
};
#endif // __OpenViBEPlugins_SignalProcessing_BoxAlgorithms_Filter_CSpatialFilterBoxAlgorithm_H__
#endif
#if 0
#include "ovpCApplySpatialFilter.h"
#include <cmath>
#include <system/ovCMemory.h>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;
using namespace std;
// ________________________________________________________________________________________________________________
//
boolean CApplySpatialFilter::initialize(void)
{
m_oSignalIntputMatrixHandle.initialize(getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix));
m_oFilterCoefficientsInputMatrixHandle.initialize(getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix));
m_oSignalOutputMatrixHandle.initialize(getOutputParameter(OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix));
m_bActive=true;
return true;
}
boolean CApplySpatialFilter::uninitialize(void)
{
m_oSignalIntputMatrixHandle.uninitialize();
m_oFilterCoefficientsInputMatrixHandle.uninitialize();
m_oSignalOutputMatrixHandle.uninitialize();
return true;
}
// ________________________________________________________________________________________________________________
//
boolean CApplySpatialFilter::process(void)
{
if(!m_bActive)
{
return false;
}
IMatrix* l_pFilterCoefficientsInputMatrix = m_oFilterCoefficientsInputMatrixHandle;
IMatrix* l_pSignalInputMatrix = m_oSignalIntputMatrixHandle;
IMatrix* l_pSignalOutputMatrix = m_oSignalOutputMatrixHandle;
// dimensions of the filter coefficients matrix
uint32 l_ui32FilterCoefficientsLineDimensionSize=m_oFilterCoefficientsInputMatrixHandle->getDimensionSize(0);
uint32 l_ui32FilterCoefficientsColumnDimensionSize=m_oFilterCoefficientsInputMatrixHandle->getDimensionSize(1);
// dimensions of the input buffer of signal
uint32 l_ui32SignalInputMatrixDimensionCount=m_oSignalIntputMatrixHandle->getDimensionCount();
uint32 l_ui32SignalInputLineDimensionSize=m_oSignalIntputMatrixHandle->getDimensionSize(0);
uint32 l_ui32SignalInputColumnDimensionSize=m_oSignalIntputMatrixHandle->getDimensionSize(1);
if(l_ui32FilterCoefficientsColumnDimensionSize != l_ui32SignalInputLineDimensionSize)
{
getLogManager() << LogLevel_ImportantWarning << "Bad matrix size - number of column of filter coefficients = " << l_ui32FilterCoefficientsColumnDimensionSize << " while Number of Line of Signal = " << l_ui32SignalInputLineDimensionSize << "\n";
m_bActive=false;
return false;
}
// Input vars
float64* l_pSignalInput = l_pSignalInputMatrix->getBuffer();
float64* l_pFilterCoefficientsInput = l_pFilterCoefficientsInputMatrix->getBuffer();
// signal output vars
l_pSignalOutputMatrix->setDimensionCount(l_ui32SignalInputMatrixDimensionCount);
l_pSignalOutputMatrix->setDimensionSize(0,l_ui32FilterCoefficientsLineDimensionSize);
l_pSignalOutputMatrix->setDimensionSize(1,l_ui32SignalInputColumnDimensionSize);
//~ l_pOutputMatrix->setDimensionLabel(indexDimension, indexSize, label);
float64* l_pSignalOutput = l_pSignalOutputMatrix->getBuffer();
if(isInputTriggerActive(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize))
{
for (uint64 i=0; i < l_ui32SignalInputColumnDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32FilterCoefficientsLineDimensionSize; j++)
{
l_pSignalOutput[i*l_ui32FilterCoefficientsLineDimensionSize+j]=0;
}
}
}
if(isInputTriggerActive(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter))
{
for (uint64 i=0; i < l_ui32SignalInputColumnDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32FilterCoefficientsLineDimensionSize; j++)
{
l_pSignalOutput[i*l_ui32FilterCoefficientsLineDimensionSize+j]=0;
}
}
for (uint64 i=0; i < l_ui32FilterCoefficientsLineDimensionSize; i++)
{
for(uint64 j=0 ; j<l_ui32SignalInputColumnDimensionSize; j++)
{
for (uint64 k=0; k< l_ui32FilterCoefficientsColumnDimensionSize; k++)
{
l_pSignalOutput[i*l_ui32SignalInputColumnDimensionSize+j] = l_pFilterCoefficientsInput[k+l_ui32FilterCoefficientsColumnDimensionSize*i]*l_pSignalInput[j+k*l_ui32SignalInputColumnDimensionSize]+l_pSignalOutput[i*l_ui32SignalInputColumnDimensionSize+j];
}
}
}
}
return true;
}
#endif
#if 0
#include "ovpCSpatialFilterBoxAlgorithm.h"
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;
using namespace OpenViBEPlugins;
using namespace OpenViBEPlugins::SignalProcessing;
using namespace std;
boolean CSpatialFilterBoxAlgorithm::initialize(void)
{
CIdentifier l_oInputTypeIdentifier;
getStaticBoxContext().getInputType(0, l_oInputTypeIdentifier);
if(l_oInputTypeIdentifier==OV_TypeId_Signal)
{
m_pStreamDecoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalStreamDecoder));
m_pStreamEncoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalStreamEncoder));
}
else
{
return false;
}
m_pStreamDecoder->initialize();
m_pStreamEncoder->initialize();
// Apply filter to signal input buffer
m_pApplySpatialFilter=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_ClassId_Algorithm_ApplySpatialFilter));
m_pApplySpatialFilter->initialize();
if(l_oInputTypeIdentifier==OV_TypeId_Signal)
{
m_pStreamEncoder->getInputParameter(OVP_GD_Algorithm_SignalStreamEncoder_InputParameterId_SamplingRate)->setReferenceTarget(m_pStreamDecoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamDecoder_OutputParameterId_SamplingRate));
}
// compute filter coefs settings
CString l_oParameters;
CString l_oNbLine;
CString l_oNbColumn;
getStaticBoxContext().getSettingValue(0, l_oParameters);
getStaticBoxContext().getSettingValue(1, l_oNbLine);
getStaticBoxContext().getSettingValue(2, l_oNbColumn);
uint64 l_ui64NbLine = atoi(l_oNbLine);
uint64 l_ui64NbColumn = atoi(l_oNbColumn);
istringstream l_oStreamString((const char*)l_oParameters);
float64 l_f64CurrentValue;
while(l_oStreamString>>l_f64CurrentValue)
{
m_oCoefficients.push_back(l_f64CurrentValue);
}
TParameterHandler<IMatrix*> ip_pFilterCoefficientsInputMatrix(m_pApplySpatialFilter->getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix));
ip_pFilterCoefficientsInputMatrix->setDimensionCount(2);
ip_pFilterCoefficientsInputMatrix->setDimensionSize(0, (uint32)l_ui64NbLine);
ip_pFilterCoefficientsInputMatrix->setDimensionSize(1, (uint32)l_ui64NbColumn);
float64* l_pFilterCoefficientsInput = ip_pFilterCoefficientsInputMatrix->getBuffer();
for (uint32 i = 0; i<m_oCoefficients.size(); i++)
{
l_pFilterCoefficientsInput[i] = m_oCoefficients[i];
}
// apply filter settings
m_pApplySpatialFilter->getInputParameter(OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix)->setReferenceTarget(m_pStreamDecoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamDecoder_OutputParameterId_Matrix));
m_pStreamEncoder->getInputParameter(OVP_GD_Algorithm_SignalStreamEncoder_InputParameterId_Matrix)->setReferenceTarget(m_pApplySpatialFilter->getOutputParameter(OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix));
return true;
}
boolean CSpatialFilterBoxAlgorithm::uninitialize(void)
{
m_pApplySpatialFilter->uninitialize();
m_pStreamEncoder->uninitialize();
m_pStreamDecoder->uninitialize();
getAlgorithmManager().releaseAlgorithm(*m_pApplySpatialFilter);
getAlgorithmManager().releaseAlgorithm(*m_pStreamEncoder);
getAlgorithmManager().releaseAlgorithm(*m_pStreamDecoder);
return true;
}
boolean CSpatialFilterBoxAlgorithm::processInput(uint32 ui32InputIndex)
{
getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
return true;
}
boolean CSpatialFilterBoxAlgorithm::process(void)
{
IBoxIO& l_rDynamicBoxContext=getDynamicBoxContext();
IBox& l_rStaticBoxContext=getStaticBoxContext();
for(uint32 i=0; i<l_rStaticBoxContext.getInputCount(); i++)
{
for(uint32 j=0; j<l_rDynamicBoxContext.getInputChunkCount(i); j++)
{
TParameterHandler < const IMemoryBuffer* > l_oInputMemoryBufferHandle(m_pStreamDecoder->getInputParameter(OVP_GD_Algorithm_SignalStreamDecoder_InputParameterId_MemoryBufferToDecode));
TParameterHandler < IMemoryBuffer* > l_oOutputMemoryBufferHandle(m_pStreamEncoder->getOutputParameter(OVP_GD_Algorithm_SignalStreamEncoder_OutputParameterId_EncodedMemoryBuffer));
l_oInputMemoryBufferHandle=l_rDynamicBoxContext.getInputChunk(i, j);
l_oOutputMemoryBufferHandle=l_rDynamicBoxContext.getOutputChunk(i);
m_pStreamDecoder->process();
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedHeader))
{
m_pApplySpatialFilter->process(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize);
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeHeader);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedBuffer))
{
m_pApplySpatialFilter->process(OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter);
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeBuffer);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
if(m_pStreamDecoder->isOutputTriggerActive(OVP_GD_Algorithm_SignalStreamDecoder_OutputTriggerId_ReceivedEnd))
{
m_pStreamEncoder->process(OVP_GD_Algorithm_SignalStreamEncoder_InputTriggerId_EncodeEnd);
l_rDynamicBoxContext.markOutputAsReadyToSend(i, l_rDynamicBoxContext.getInputChunkStartTime(i, j), l_rDynamicBoxContext.getInputChunkEndTime(i, j));
}
l_rDynamicBoxContext.markInputAsDeprecated(i, j);
}
}
return true;
}
#endif
......@@ -13,14 +13,6 @@
#define OVP_ClassId_TimeBasedEpoching OpenViBE::CIdentifier(0x00777FA0, 0x5DC3F560)
#define OVP_ClassId_TimeBasedEpochingDesc OpenViBE::CIdentifier(0x00ABDABE, 0x41381683)
#define OVP_ClassId_Algorithm_ApplySpatialFilter OpenViBE::CIdentifier(0xC5DC28FF, 0x2394AFBC)
#define OVP_ClassId_Algorithm_ApplySpatialFilterDesc OpenViBE::CIdentifier(0x0601FABE, 0x85692BFD)
#define OVP_Algorithm_ApplySpatialFilter_InputParameterId_SignalMatrix OpenViBE::CIdentifier(0x6FF50741, 0xB9757B1F)
#define OVP_Algorithm_ApplySpatialFilter_InputParameterId_FilterCoefficientsMatrix OpenViBE::CIdentifier(0x43DC06E5, 0x48E413BA)
#define OVP_Algorithm_ApplySpatialFilter_OutputParameterId_FilteredSignalMatrix OpenViBE::CIdentifier(0x695B69B2, 0x02DBE696)
#define OVP_Algorithm_ApplySpatialFilter_InputTriggerId_Initialize OpenViBE::CIdentifier(0x06D0E2D6, 0xE1E9C082)
#define OVP_Algorithm_ApplySpatialFilter_InputTriggerId_ApplyFilter OpenViBE::CIdentifier(0x316BBE5D, 0xBEE0F747)
#define OVP_TypeId_EpochAverageMethod OpenViBE::CIdentifier(0x6530BDB1, 0xD057BBFE)
#define OVP_TypeId_EpochAverageMethod_MovingAverage OpenViBE::CIdentifier(0x426377E7, 0xCF8E32CD)
#define OVP_TypeId_EpochAverageMethod_MovingAverageImmediate OpenViBE::CIdentifier(0x1F830F88, 0xAA01A592)
......
#include "algorithms/basic/ovpCMatrixAverage.h"
#include "algorithms/epoching/ovpCAlgorithmStimulationBasedEpoching.h"
//#include "algorithms/filters/ovpCApplySpatialFilter.h"
#include "box-algorithms/basic/ovpCIdentity.h"
......@@ -14,7 +13,6 @@
#include "box-algorithms/basic/ovpCBoxAlgorithmReferenceChannel.h"
#include "box-algorithms/basic/ovpCBoxAlgorithmDifferentialIntegral.h"
#include "box-algorithms/epoching/ovpCBoxAlgorithmStimulationBasedEpoching.h"
//#include "box-algorithms/filters/ovpCSpatialFilterBoxAlgorithm.h"
#include "box-algorithms/filters/ovpCBoxAlgorithmCommonAverageReference.h"
#include "box-algorithms/filters/ovpCBoxAlgorithmSpatialFilter.h"
......@@ -109,7 +107,6 @@ OVP_Declare_Begin()
OVP_Declare_New(OpenViBEPlugins::SignalProcessing::CMatrixAverageDesc)
OVP_Declare_New(OpenViBEPlugins::SignalProcessing::CAlgorithmStimulationBasedEpochingDesc)
// OVP_Declare_New(OpenViBEPlugins::SignalProcessing::CApplySpatialFilterDesc)
OVP_Declare_New(OpenViBEPlugins::SignalProcessing::CBoxAlgorithmChannelRenameDesc)
OVP_Declare_New(OpenViBEPlugins::SignalProcessing::CBoxAlgorithmChannelSelectorDesc)
......@@ -120,7 +117,6 @@ OVP_Declare_Begin()