core_OutputArray_getMat() private méthode

private core_OutputArray_getMat ( IntPtr oa ) : IntPtr
oa IntPtr
Résultat IntPtr
        /// <summary>
        ///
        /// </summary>
        public override void AssignResult()
        {
            if (!IsReady())
            {
                throw new NotSupportedException();
            }

            // Matで結果取得
            NativeMethods.HandleException(
                NativeMethods.core_OutputArray_getMat(ptr, out var matPtr));
            GC.KeepAlive(this);
            using (var mat = new Mat(matPtr))
            {
                // 配列サイズ
                var size = mat.Rows * mat.Cols;
                // 配列にコピー
                var array = new T[size];
                using (var aa = new ArrayAddress1 <T>(array))
                {
                    var elemSize = MarshalHelper.SizeOf <T>();
                    MemoryHelper.CopyMemory(aa.Pointer, mat.Data, size * elemSize);
                }
                // リストにコピー
                list.Clear();
                list.AddRange(array);
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        public override void AssignResult()
        {
            if (!IsReady())
            {
                throw new NotSupportedException();
            }

            // Matで結果取得
            NativeMethods.HandleException(
                NativeMethods.core_OutputArray_getMat(ptr, out var matPtr));
            GC.KeepAlive(this);
            using (var mat = new Mat(matPtr))
            {
                // 配列サイズ
                var size = mat.Rows * mat.Cols;
                // 配列にコピー
                var array = new T[size];
                using (var aa = new ArrayAddress1 <T>(array))
                {
                    long bytesToCopy = Marshal.SizeOf <T>() * size;
                    unsafe
                    {
                        Buffer.MemoryCopy(mat.DataPointer, aa.Pointer.ToPointer(), bytesToCopy, bytesToCopy);
                    }
                }
                // リストにコピー
                list.Clear();
                list.AddRange(array);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        public override void AssignResult()
        {
            if (!IsReady())
            {
                throw new NotSupportedException();
            }

            // Matで結果取得
            IntPtr matPtr = NativeMethods.core_OutputArray_getMat(ptr);

            using (Mat mat = new Mat(matPtr))
            {
                // 配列サイズ
                int size = mat.Rows * mat.Cols;
                // 配列にコピー
                T[] array = new T[size];
                using (ArrayAddress1 <T> aa = new ArrayAddress1 <T>(array))
                {
                    int elemSize = Marshal.SizeOf(typeof(T));
                    Utility.CopyMemory(aa.Pointer, mat.Data, size * elemSize);
                }
                // リストにコピー
                list.Clear();
                list.AddRange(array);
            }
        }