Ejemplo n.º 1
0
            /// <summary>
            /// Creates a matrix header for the specified column span.
            /// </summary>
            /// <param name="startCol">An inclusive 0-based start index of the column span.</param>
            /// <param name="endCol">An exclusive 0-based ending index of the column span.</param>
            /// <returns></returns>
            public override GpuMat this[int startCol, int endCol]
            {
                get
                {
                    parent.ThrowIfDisposed();
                    var matPtr = NativeMethods.cuda_GpuMat_rowRange(parent.ptr, startCol, endCol);
                    return(new GpuMat(matPtr));
                }
                set
                {
                    parent.ThrowIfDisposed();
                    if (value == null)
                    {
                        throw new ArgumentNullException(nameof(value));
                    }
                    value.ThrowIfDisposed();

                    var matPtr = NativeMethods.cuda_GpuMat_rowRange(parent.ptr, startCol, endCol);
                    var mat    = new GpuMat(matPtr);
                    if (mat.Size() != value.Size())
                    {
                        throw new ArgumentException("Specified ROI != mat.Size()");
                    }
                    value.CopyTo(mat);
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Creates a matrix header for the specified matrix column.
            /// </summary>
            /// <param name="x">A 0-based column index.</param>
            /// <returns></returns>
            public override GpuMat this[int x]
            {
                get
                {
                    parent.ThrowIfDisposed();
                    IntPtr matPtr = NativeMethods.cuda_GpuMat_col(parent.ptr, x);
                    GC.KeepAlive(this);
                    return(new GpuMat(matPtr));
                }
                set
                {
                    parent.ThrowIfDisposed();
                    if (value == null)
                    {
                        throw new ArgumentNullException(nameof(value));
                    }
                    value.ThrowIfDisposed();

                    var matPtr = NativeMethods.cuda_GpuMat_col(parent.ptr, x);
                    GC.KeepAlive(this);
                    var mat = new GpuMat(matPtr);
                    if (mat.Size() != value.Size())
                    {
                        throw new ArgumentException("Specified ROI != mat.Size()");
                    }
                    value.CopyTo(mat);
                }
            }