/// <summary> /// Returns stacked data in a 3D form compatible with CV2. /// </summary> /// <param name="bReset">Specifies to reset the stack or not.</param> /// <param name="nFrames">Optionally, specifies the number of frames (default = 4).</param> /// <param name="nStacks">Optionally, specifies the number of stacks (default = 4).</param> /// <param name="bGrayscale">Optionally, specifies to return gray scale data (default = true, one channel).</param> /// <param name="dfScale">Optionally, specifies the scale to apply to each item (default = 1.0).</param> /// <returns>The data is returned as a multi-dimensional array.</returns> public List <List <List <double> > > GetDataAsStacked3D(bool bReset, int nFrames = 4, int nStacks = 4, bool bGrayscale = true, double dfScale = 1) { SimpleDatum sd = preprocess(m_state.Item1, bGrayscale, dfScale); if (bReset) { m_rgData.Clear(); for (int i = 0; i < nFrames * nStacks; i++) { m_rgData.Add(sd); } } else { m_rgData.Add(sd); m_rgData.RemoveAt(0); } SimpleDatum[] rgSd = new SimpleDatum[nStacks]; for (int i = 0; i < nStacks; i++) { int nIdx = ((nStacks - i) * nFrames) - 1; rgSd[i] = m_rgData[nIdx]; } SimpleDatum sd1 = new SimpleDatum(rgSd.ToList(), true); return(GetDataAs3D(false, 1, sd1)); }
/// <summary> /// Preprocesses the data. /// </summary> /// <param name="s">Specifies the state and data to use.</param> /// <param name="bUseRawInput">Specifies whether or not to use the raw data <i>true</i>, or a difference of the current and previous data <i>false</i> (default = <i>false</i>).</param> /// <param name="bDifferent">Returns whether or not the current state data is different from the previous - note this is only set when NOT using raw input, otherwise <i>true</i> is always returned.</param> /// <param name="bReset">Optionally, specifies to reset the last sd to null.</param> /// <returns>The preprocessed data is returned.</returns> public SimpleDatum Preprocess(StateBase s, bool bUseRawInput, out bool bDifferent, bool bReset = false) { bDifferent = false; SimpleDatum sd = new SimpleDatum(s.Data, true); if (!bUseRawInput) { if (bReset) { m_sdLast = null; } if (m_sdLast == null) { sd.Zero(); } else { bDifferent = sd.Sub(m_sdLast); } m_sdLast = new SimpleDatum(s.Data, true); } else { bDifferent = true; } sd.Tag = bReset; if (bReset) { m_rgX = new List <SimpleDatum>(); for (int i = 0; i < m_nFramesPerX * m_nStackPerX; i++) { m_rgX.Add(sd); } } else { m_rgX.Add(sd); m_rgX.RemoveAt(0); } SimpleDatum[] rgSd = new SimpleDatum[m_nStackPerX]; for (int i = 0; i < m_nStackPerX; i++) { int nIdx = ((m_nStackPerX - i) * m_nFramesPerX) - 1; rgSd[i] = m_rgX[nIdx]; } return(new SimpleDatum(rgSd.ToList(), true)); }