Hi all,
I am attempting to write input processing code to handle multiple streamed matrix inputs but don't know how to appropriately read from each input stream. I am using the Graz Visualizer as my starting point because I would like my first stream to be Stimulations, and my second and third inputs to be Streamed Matrix. In my modified box, I have added the third input, Streamed Matrix and am currently using the Sinus generator with sampling rate = 30, channels =4 and block = 1. When I check the setMatrixDimmensionSize() and setMatrixDimmensionLabel() I find that input index 0 has 4 items but that index 1 has only 1 item. Any thoughts as to my problem here?
Thanks
-Jon
Multiple Matrix Streams per Box Algorithm
Re: Multiple Matrix Streams per Box Algorithm
Dear Jon,
Thank you for your interest in OpenViBE.
in the method "process"
you can find more details on the openvibe site: http://openvibe.inria.fr/documentation/ ... ssing.html
For the dimension 1 : op_pMatrix->getDimensionSize(0)= 4, because you had 4 channels.
For the dimension 2 : op_Matrix->getDimensionSize(1)=1, because your "sinus oscillator" sent 1 sample by chunk. On the "sinus oscillator" box, parameter: "Generated epoch sample count = 1".
I hope this help you.
Best regards,
Baptiste
Thank you for your interest in OpenViBE.
First you need a buffer for each inputs and outputs and connects them to the appropriate algorithm decoder or encoder. This operation is made in the “initialize” method.I am attempting to write input processing code to handle multiple streamed matrix inputs but don't know how to appropriately read from each input stream.
Code: Select all
//Create a decoder for your input ( for this example I have a “streamed matrix” input)
OpenViBE::Kernel::IAlgorithmProxy* m_pStreamDecoder=&getAlgorithmManager().getAlgorithm(getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StreamedMatrixStreamDecoder));
m_pStreamDecoder->initialize();
//create a "memory buffer" for your input stream
TParameterHandler < const IMemoryBuffer* > ip_pMemoryBuffer(m_pStreamDecoder->getInputParameter(OVP_GD_Algorithm_StreamedMatrixStreamDecoder_InputParameterId_MemoryBufferToDecode));
//and create a matrix will contains your decode input stream
TParameterHandler < IMatrix* > op_pMatrix(m_pStreamDecoder->getOutputParameter(OVP_GD_Algorithm_StreamedMatrixStreamDecoder_OutputParameterId_Matrix));
Code: Select all
//put data from your input stream in the memory buffer
//i correspond to the number of your input
//j correspond to the number of the chunk where you work
ip_pMemoryBuffer=l_rDynamicBoxContext.getInputChunk(i, j);
//and decode it
m_pStreamDecoder->process();
A signal can be convert in a matrix with 2 dimensions. The first correspond to channels of your signal and the second correspond to samples of each channels. That's why, you have this values.In my modified box, I have added the third input, Streamed Matrix and am currently using the Sinus generator with sampling rate = 30, channels =4 and block = 1. When I check the setMatrixDimmensionSize() and setMatrixDimmensionLabel() I find that input index 0 has 4 items but that index 1 has only 1 item. Any thoughts as to my problem here?
For the dimension 1 : op_pMatrix->getDimensionSize(0)= 4, because you had 4 channels.
For the dimension 2 : op_Matrix->getDimensionSize(1)=1, because your "sinus oscillator" sent 1 sample by chunk. On the "sinus oscillator" box, parameter: "Generated epoch sample count = 1".
I hope this help you.
Best regards,
Baptiste
Re: Multiple Matrix Streams per Box Algorithm
Hi Jon welcome on board !
Then you can access the data using the getBuffer function.
Example :
will give you the j-th sample on the i-th channel. In your case i goes from 0 to 3 and j can only be 0 (and getDimensionSize(1) returns 1).
I hope this helps.
Laurent
First, I suggest you look at the tutorial for developer : writing an algorithm and use it in a box. It shows how you can read a streamed matrix input, and output another streamed matrix.I am attempting to write input processing code to handle multiple streamed matrix inputs but don't know how to appropriately read from each input stream.
In my opinion, the graz visualisation box is quiet complex for a first try... You should definitely look at the simple box given in the tutorial. It is easy to add one more streamed matrix as input. If you need an example of stimulation processing, you can look at the Run command box : this box reads stimulation stream, and run a specific system command if a specific stim is coming.I am using the Graz Visualizer as my starting point because I would like my first stream to be Stimulations, and my second and third inputs to be Streamed Matrix.
As Baptiste said, these values seem okWhen I check the setMatrixDimmensionSize() and setMatrixDimmensionLabel() I find that input index 0 has 4 items but that index 1 has only 1 item.
Then you can access the data using the getBuffer function.
Example :
Code: Select all
buffer[i*matrix->getDimensionSize(1)+j]
I hope this helps.
Laurent
Re: Multiple Matrix Streams per Box Algorithm
Thanks for the code pointers. I have successfully enabled a new box-algorithm to read from input Streamed Matrix types. I have enabled two input streams - should I use two memory buffers and two different matrices since each input stream can be a different size? In that case, how can I dynamically ensure the right input stream goes to the right buffer? That is, the current method:
(note: I use a variable for IBoxIO, but used the data type for illustration)
Makes no assumptions about the incoming data. If I were to use two different buffers I would have to hard-code the expected order, as in:
Is this the best/only way to achieve my desired result?
Thanks,
Jon
Code: Select all
buffer=IBoxIO->getInputChunk(input,chunk)
Makes no assumptions about the incoming data. If I were to use two different buffers I would have to hard-code the expected order, as in:
Code: Select all
buffer0 = IBoxIO->getInputChunk(0,chunk);
buffer1 = IBoxIO->getInputChunk(1,chunk);
Thanks,
Jon
Re: Multiple Matrix Streams per Box Algorithm
Dear jbrumberg,
indeed, you should probably take care of using different IMemoryBuffer parameter handlers (as for decoder inputs) and IMatrix parameter handlers (as for decoder outputs).
This will lead you to something quite similar to the code you proposed :
Hope this helps,
Yann
indeed, you should probably take care of using different IMemoryBuffer parameter handlers (as for decoder inputs) and IMatrix parameter handlers (as for decoder outputs).
This will lead you to something quite similar to the code you proposed :
Code: Select all
buffer0 = IBoxIO->getInputChunk(0,chunk);
buffer1 = IBoxIO->getInputChunk(1,chunk);
Yann