Exemplo n.º 1
0
        /// <summary>
        /// Create a GpuMat of the specified size
        /// </summary>
        /// <param name="rows">The number of rows (height)</param>
        /// <param name="cols">The number of columns (width)</param>
        /// <param name="channels">The number of channels</param>
        /// <param name="continuous">Indicates if the data should be continuous</param>
        public GpuMat(int rows, int cols, int channels, bool continuous)
        {
            int matType = CvInvoke.CV_MAKETYPE((int)CvToolbox.GetMatrixDepth(typeof(TDepth)), channels);

            if (continuous)
            {
                _ptr = GpuInvoke.GpuMatCreateContinuous(rows, cols, matType);
            }
            else
            {
                _ptr = GpuInvoke.GpuMatCreate(rows, cols, matType);
            }
        }
Exemplo 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(), CvToolbox.GetMatrixDepth(typeof(TDepth)));
            handle.Free();
        }
Exemplo n.º 3
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)CvToolbox.GetMatrixDepth(typeof(TDepth)), channels), data, step);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a GpuMat of the specified size
 /// </summary>
 /// <param name="rows">The number of rows (height)</param>
 /// <param name="cols">The number of columns (width)</param>
 /// <param name="channels">The number of channels</param>
 public GpuMat(int rows, int cols, int channels)
 {
     _ptr = GpuInvoke.GpuMatCreate(rows, cols, CvInvoke.CV_MAKETYPE((int)CvToolbox.GetMatrixDepth(typeof(TDepth)), channels));
 }