Ejemplo n.º 1
0
 /// <summary>
 /// Create a Matrix (only header is allocated) using the Pinned/Unmanaged <paramref name="data"/>. The <paramref name="data"/> is not freed by the disposed function of this class
 /// </summary>
 /// <param name="rows">The number of rows</param>
 /// <param name="cols">The number of cols</param>
 /// <param name="channels">The number of channels</param>
 /// <param name="data">The Pinned/Unmanaged data, the data must not be release before the Matrix is Disposed</param>
 /// <param name="step">The step (row stride in bytes)</param>
 /// <remarks>The caller is responsible for allocating and freeing the block of memory specified by the data parameter, however, the memory should not be released until the related Matrix is released. </remarks>
 public Matrix(int rows, int cols, int channels, IntPtr data, int step)
 {
     AllocateHeader();
     CvInvoke.cvInitMatHeader(_ptr, rows, cols, CvInvoke.CV_MAKETYPE((int)Util.GetMatrixDepth(typeof(TDepth)), channels), data, step);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a sparse matrix of the specific dimension
        /// </summary>
        /// <param name="dimension">The dimension of the sparse matrix</param>
        public SparseMatrix(int[] dimension)
        {
            _dimension = new int[dimension.Length];
            Array.Copy(dimension, _dimension, dimension.Length);
            GCHandle handle = GCHandle.Alloc(_dimension, GCHandleType.Pinned);

            _ptr = CvInvoke.cvCreateSparseMat(_dimension.Length, handle.AddrOfPinnedObject(), Util.GetMatrixDepth(typeof(TDepth)));
            handle.Free();
        }