This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,38 @@
PROJECT(openvibe-plugins-sdk-data-generation)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
FILE(GLOB_RECURSE SRC_FILES src/*.cpp src/*.h src/*.hpp src/*.inl)
INCLUDE("FindSourceRCProperties")
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC_FILES})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
FOLDER ${PLUGINS_FOLDER}
COMPILE_FLAGS "-DOVP_Exports -DOVP_Shared")
# ---------------------------------
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEToolkit")
INCLUDE("FindOpenViBEModuleEBML")
INCLUDE("FindOpenViBEModuleXML")
# ---------------------------------
# Target macros
# Defines target operating system, architecture and compiler
# ---------------------------------
SET_BUILD_PLATFORM()
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${DIST_BINDIR}
LIBRARY DESTINATION ${DIST_LIBDIR}
ARCHIVE DESTINATION ${DIST_LIBDIR})
INSTALL(DIRECTORY box-tutorials/ DESTINATION ${DIST_DATADIR}/openvibe/scenarios/box-tutorials)
@@ -0,0 +1,192 @@
<OpenViBE-Scenario>
<FormatVersion>2</FormatVersion>
<Creator>OpenViBE Designer</Creator>
<CreatorVersion>2.2.0</CreatorVersion>
<Settings></Settings>
<Inputs></Inputs>
<Outputs></Outputs>
<Boxes>
<Box>
<Identifier>(0x000015f6, 0x00002e14)</Identifier>
<Name>Matrix Display</Name>
<AlgorithmClassIdentifier>(0x54f0796d, 0x3ede2cc0)</AlgorithmClassIdentifier>
<Inputs>
<Input>
<TypeIdentifier>(0x544a003e, 0x6dcba5f6)</TypeIdentifier>
<Name>Matrix</Name>
</Input>
</Inputs>
<Settings>
<Setting>
<TypeIdentifier>(0x3d3c7c7f, 0xef0e7129)</TypeIdentifier>
<Name>Color gradient</Name>
<DefaultValue>0:2,36,58; 50:100,100,100; 100:83,17,20</DefaultValue>
<Value>0:100,100,100; 100:100,100,100</Value>
<Modifiability>false</Modifiability>
</Setting>
<Setting>
<TypeIdentifier>(0x007deef9, 0x2f3e95c6)</TypeIdentifier>
<Name>Steps</Name>
<DefaultValue>100</DefaultValue>
<Value>100</Value>
<Modifiability>false</Modifiability>
</Setting>
<Setting>
<TypeIdentifier>(0x2cdb2f0b, 0x12f231ea)</TypeIdentifier>
<Name>Symetric min/max</Name>
<DefaultValue>false</DefaultValue>
<Value>false</Value>
<Modifiability>false</Modifiability>
</Setting>
<Setting>
<TypeIdentifier>(0x2cdb2f0b, 0x12f231ea)</TypeIdentifier>
<Name>Real time min/max</Name>
<DefaultValue>false</DefaultValue>
<Value>false</Value>
<Modifiability>false</Modifiability>
</Setting>
</Settings>
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>0</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>368</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0x4ff49bdb, 0x9dcf6788)</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>4</Value>
</Attribute>
<Attribute>
<Identifier>(0xcfad85b0, 0x7c6d841c)</Identifier>
<Value>1</Value>
</Attribute>
</Attributes>
</Box>
<Box>
<Identifier>(0x5f3d3b70, 0x223fa5b7)</Identifier>
<Name>Time signal</Name>
<AlgorithmClassIdentifier>(0x28a5e7ff, 0x530095de)</AlgorithmClassIdentifier>
<Outputs>
<Output>
<TypeIdentifier>(0x5ba36127, 0x195feae1)</TypeIdentifier>
<Name>Generated signal</Name>
</Output>
</Outputs>
<Settings>
<Setting>
<TypeIdentifier>(0x007deef9, 0x2f3e95c6)</TypeIdentifier>
<Name>Sampling frequency</Name>
<DefaultValue>512</DefaultValue>
<Value>512</Value>
<Modifiability>false</Modifiability>
</Setting>
<Setting>
<TypeIdentifier>(0x007deef9, 0x2f3e95c6)</TypeIdentifier>
<Name>Generated epoch sample count</Name>
<DefaultValue>32</DefaultValue>
<Value>8</Value>
<Modifiability>false</Modifiability>
</Setting>
</Settings>
<Attributes>
<Attribute>
<Identifier>(0x1fa7a38f, 0x54edbe0b)</Identifier>
<Value>-80</Value>
</Attribute>
<Attribute>
<Identifier>(0x207c9054, 0x3c841b63)</Identifier>
<Value>368</Value>
</Attribute>
<Attribute>
<Identifier>(0x4e7b798a, 0x183beafb)</Identifier>
<Value>(0x9e5ca01e, 0x30a4d8c3)</Value>
</Attribute>
<Attribute>
<Identifier>(0xc80ce8af, 0xf699f813)</Identifier>
<Value>1</Value>
</Attribute>
<Attribute>
<Identifier>(0xce18836a, 0x9c0eb403)</Identifier>
<Value>2</Value>
</Attribute>
</Attributes>
</Box>
</Boxes>
<Links>
<Link>
<Identifier>(0x00004fef, 0x00006a19)</Identifier>
<Source>
<BoxIdentifier>(0x5f3d3b70, 0x223fa5b7)</BoxIdentifier>
<BoxOutputIndex>0</BoxOutputIndex>
</Source>
<Target>
<BoxIdentifier>(0x000015f6, 0x00002e14)</BoxIdentifier>
<BoxInputIndex>0</BoxInputIndex>
</Target>
</Link>
</Links>
<Comments>
<Comment>
<Identifier>(0x0000019a, 0x000047dc)</Identifier>
<Text>You can browse each box' documentation by selecting the box and pressing &lt;b&gt;F1&lt;/b&gt;</Text>
<Attributes>
<Attribute>
<Identifier>(0x473d9a43, 0x97fc0a97)</Identifier>
<Value>704</Value>
</Attribute>
<Attribute>
<Identifier>(0x7234b86b, 0x2b8651a5)</Identifier>
<Value>-80</Value>
</Attribute>
</Attributes>
</Comment>
</Comments>
<Metadata>
<Entry>
<Identifier>(0x05377d7e, 0x41751bb3)</Identifier>
<Type>(0x3bcce5d2, 0x43f2d968)</Type>
<Data>[{"boxIdentifier":"(0x000015f6, 0x00002e14)","childCount":0,"identifier":"(0x000055e3, 0x0000746e)","parentIdentifier":"(0xffffffff, 0xffffffff)","type":3}]</Data>
</Entry>
</Metadata>
<Attributes>
<Attribute>
<Identifier>(0x4c90d4ad, 0x7a2554ec)</Identifier>
<Value>320</Value>
</Attribute>
<Attribute>
<Identifier>(0x790d75b8, 0x3bb90c33)</Identifier>
<Value>Jussi T. Lindgren</Value>
</Attribute>
<Attribute>
<Identifier>(0x7b814cca, 0x271df6dd)</Identifier>
<Value>475</Value>
</Attribute>
<Attribute>
<Identifier>(0x8c1fc55b, 0x7b433dc2)</Identifier>
<Value>1.0</Value>
</Attribute>
<Attribute>
<Identifier>(0x9f5c4075, 0x4a0d3666)</Identifier>
<Value>Classification training example</Value>
</Attribute>
<Attribute>
<Identifier>(0xf36a1567, 0xd13c53da)</Identifier>
<Value></Value>
</Attribute>
<Attribute>
<Identifier>(0xf6b2e3fa, 0x7bd43926)</Identifier>
<Value>box-tutorials</Value>
</Attribute>
<Attribute>
<Identifier>(0xf8034a49, 0x8b3f37cc)</Identifier>
<Value>Inria</Value>
</Attribute>
</Attributes>
</OpenViBE-Scenario>
@@ -0,0 +1,61 @@
/**
* \page BoxAlgorithm_TimeSignal Time signal
__________________________________________________________________
Detailed description
__________________________________________________________________
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Description|
* This box generates a linear signal on a single channel.
* The box can be used in order to test some processings on a specific
* signal when no data is available. Each sample value of the generated
* signal exactly equals to time in second.
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Description|
__________________________________________________________________
Outputs description
__________________________________________________________________
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Outputs|
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Outputs|
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Output1|
* This output contains the generated signal.
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Output1|
__________________________________________________________________
Settings description
__________________________________________________________________
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Settings|
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Settings|
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Setting1|
* The first setting indicates the samling frequency of the produced signal in Hz.
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Setting1|
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Setting2|
* The last setting indicates how many sample will be sent for each output chunk.
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Setting2|
__________________________________________________________________
Examples description
__________________________________________________________________
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Examples|
* In order to illustrate this case, just drag'n drop a \ref Doc_BoxAlgorithm_SignalDisplay
* box on the scenario and connect its input to a sinus oscillator box. You will be able to
* see the generated signal.
*
* For better use of this box, consider using an additional \ref Doc_BoxAlgorithm_SimpleDSP
* box. Put whatever function you like in this box configuration and visualize it with the
* \ref Doc_BoxAlgorithm_SignalDisplay.
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Examples|
__________________________________________________________________
Miscellaneous description
__________________________________________________________________
* |OVP_DocBegin_BoxAlgorithm_TimeSignal_Miscellaneous|
* |OVP_DocEnd_BoxAlgorithm_TimeSignal_Miscellaneous|
*/
@@ -0,0 +1,66 @@
.. _Doc_BoxAlgorithm_TimeSignal:
Time signal
===========
.. container:: attribution
:Author:
Yann Renard
:Company:
INRIA/IRISA
.. image:: images/Doc_BoxAlgorithm_TimeSignal.png
This box generates a linear signal on a single channel.
The box can be used in order to test some processings on a specific
signal when no data is available. Each sample value of the generated
signal exactly equals to time in second.
Outputs
-------
.. csv-table::
:header: "Output Name", "Stream Type"
"Generated signal", "Signal"
Generated signal
~~~~~~~~~~~~~~~~
This output contains the generated signal.
.. _Doc_BoxAlgorithm_TimeSignal_Settings:
Settings
--------
.. csv-table::
:header: "Setting Name", "Type", "Default Value"
"Sampling frequency", "Integer", "512"
"Generated epoch sample count", "Integer", "32"
Sampling frequency
~~~~~~~~~~~~~~~~~~
The first setting indicates the samling frequency of the produced signal in Hz.
Generated epoch sample count
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The last setting indicates how many sample will be sent for each output chunk.
.. _Doc_BoxAlgorithm_TimeSignal_Examples:
Examples
--------
In order to illustrate this case, just drag'n drop a :ref:`Doc_BoxAlgorithm_ContinuousOscilloscope`
box on the scenario and connect its input to a sinus oscillator box. You will be able to
see the generated signal.
For better use of this box, consider using an additional :ref:`Doc_BoxAlgorithm_SimpleDSP`
box. Put whatever function you like in this box configuration and visualize it with the
:ref:`Doc_BoxAlgorithm_ContinuousOscilloscope`.
@@ -0,0 +1,78 @@
#include "ovpCBoxAlgorithmTimeSignalGenerator.h"
namespace OpenViBE {
namespace Plugins {
namespace DataGeneration {
bool CBoxAlgorithmTimeSignalGenerator::initialize()
{
m_encoder.initialize(*this, 0);
// Parses box settings to try connecting to server
m_sampling = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 0);
m_nGeneratedEpochSample = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 1);
m_headerSent = false;
m_nSentSample = 0;
return true;
}
bool CBoxAlgorithmTimeSignalGenerator::uninitialize()
{
m_encoder.uninitialize();
return true;
}
bool CBoxAlgorithmTimeSignalGenerator::processClock(Kernel::CMessageClock& /*msg*/)
{
this->getBoxAlgorithmContext()->markAlgorithmAsReadyToProcess();
return true;
}
bool CBoxAlgorithmTimeSignalGenerator::process()
{
Kernel::IBoxIO* boxContext = getBoxAlgorithmContext()->getDynamicBoxContext();
if (!m_headerSent)
{
m_encoder.getInputSamplingRate() = m_sampling;
CMatrix* matrix = m_encoder.getInputMatrix();
matrix->resize(1, m_nGeneratedEpochSample);
matrix->setDimensionLabel(0, 0, "Time signal");
m_encoder.encodeHeader();
m_headerSent = true;
boxContext->markOutputAsReadyToSend(0, 0, 0);
}
else
{
// Create sample chunks up until the next step (current time + 1/128) but do not overshoot it
// This way we will always create the correct number of samples for frequencies that are above 128Hz
const uint64_t nextStepDate = CTime(uint64_t(this->getPlayerContext().getCurrentTime() + (1ULL << 25))).toSampleCount(m_sampling);
while (m_nSentSample + m_nGeneratedEpochSample < nextStepDate)
{
double* buffer = m_encoder.getInputMatrix()->getBuffer();
for (size_t i = 0; i < m_nGeneratedEpochSample; ++i) { buffer[i] = (i + m_nSentSample) / double(m_sampling); }
m_encoder.encodeBuffer();
const uint64_t tStart = CTime(m_sampling, m_nSentSample).time();
m_nSentSample += m_nGeneratedEpochSample;
const uint64_t tEnd = CTime(m_sampling, m_nSentSample).time();
boxContext->markOutputAsReadyToSend(0, tStart, tEnd);
}
}
return true;
}
} // namespace DataGeneration
} // namespace Plugins
} // namespace OpenViBE
@@ -0,0 +1,70 @@
#pragma once
#include "../ovp_defines.h"
#include <toolkit/ovtk_all.h>
namespace OpenViBE {
namespace Plugins {
namespace DataGeneration {
class CBoxAlgorithmTimeSignalGenerator final : public Toolkit::TBoxAlgorithm<IBoxAlgorithm>
{
public:
CBoxAlgorithmTimeSignalGenerator() {}
void release() override { delete this; }
uint64_t getClockFrequency() override { return 128LL << 32; }
bool initialize() override;
bool uninitialize() override;
bool processClock(Kernel::CMessageClock& msg) override;
bool process() override;
_IsDerivedFromClass_Final_(Toolkit::TBoxAlgorithm<IBoxAlgorithm>, OVP_ClassId_BoxAlgorithm_TimeSignalGenerator)
protected:
Toolkit::TSignalEncoder<CBoxAlgorithmTimeSignalGenerator> m_encoder;
bool m_headerSent = false;
size_t m_sampling = 0;
size_t m_nGeneratedEpochSample = 0;
size_t m_nSentSample = 0;
};
class CBoxAlgorithmTimeSignalGeneratorDesc final : public IBoxAlgorithmDesc
{
public:
void release() override { }
CString getName() const override { return CString("Time signal"); }
CString getAuthorName() const override { return CString("Yann Renard"); }
CString getAuthorCompanyName() const override { return CString("INRIA/IRISA"); }
CString getShortDescription() const override { return CString("Simple time signal generator (for use with DSP)"); }
CString getDetailedDescription() const override { return CString(""); }
CString getCategory() const override { return CString("Data generation"); }
CString getVersion() const override { return CString("1.1"); }
CString getSoftwareComponent() const override { return CString("openvibe-sdk"); }
CString getAddedSoftwareVersion() const override { return CString("0.0.0"); }
CString getUpdatedSoftwareVersion() const override { return CString("0.4.0"); }
CIdentifier getCreatedClass() const override { return OVP_ClassId_BoxAlgorithm_TimeSignalGenerator; }
IPluginObject* create() override { return new CBoxAlgorithmTimeSignalGenerator(); }
bool getBoxPrototype(Kernel::IBoxProto& prototype) const override
{
prototype.addOutput("Generated signal", OV_TypeId_Signal);
prototype.addSetting("Sampling frequency", OV_TypeId_Integer, "512");
prototype.addSetting("Generated epoch sample count", OV_TypeId_Integer, "32");
return true;
}
_IsDerivedFromClass_Final_(IBoxAlgorithmDesc, OVP_ClassId_BoxAlgorithm_TimeSignalGeneratorDesc)
};
} // namespace DataGeneration
} // namespace Plugins
} // namespace OpenViBE
@@ -0,0 +1,11 @@
#pragma once
// Global defines
//---------------------------------------------------------------------------------------------------
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovp_global_defines.h"
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#define OVP_ClassId_BoxAlgorithm_TimeSignalGenerator OpenViBE::CIdentifier(0x28A5E7FF, 0x530095DE)
#define OVP_ClassId_BoxAlgorithm_TimeSignalGeneratorDesc OpenViBE::CIdentifier(0x57AD8655, 0x1966B4DC)
@@ -0,0 +1,7 @@
#include "ovp_defines.h"
#include "box-algorithms/ovpCBoxAlgorithmTimeSignalGenerator.h"
OVP_Declare_Begin()
OVP_Declare_New(OpenViBE::Plugins::DataGeneration::CBoxAlgorithmTimeSignalGeneratorDesc);
OVP_Declare_End()