Пример #1
0
        /// <summary>
        /// Copies the values of the <paramref name="data"/> to Mat.
        /// </summary>
        /// <param name="data">The data storage, must match the size of the Mat</param>
        public void SetTo(Array data)
        {
            if (IsEmpty)
            {
                int dimension = data.Rank;

                DepthType dt = Mat.GetDepthTypeFromArray(data);
                if (dt == DepthType.Default)
                {
                    throw new Exception("The specific data type is not supported.");
                }

                if (dimension == 1)
                {
                    this.Create(data.GetLength(0), 1, dt, 1);
                }
                else if (dimension == 2)
                {
                    this.Create(data.GetLength(0), data.GetLength(1), dt, 1);
                }
                else if (dimension == 3)
                {
                    this.Create(data.GetLength(0), data.GetLength(1), dt, 1);
                }
                else
                {
                    throw new Exception("The Mat has to be pre-allocated");
                }
            }

            using (Mat.MatWithHandle m = Mat.PrepareArrayForCopy(Depth, Size, NumberOfChannels, data))
                m.CopyTo(this);
        }
Пример #2
0
        /// <summary>
        /// Copies the values of the UMat to <paramref name="data"/>.
        /// </summary>
        /// <param name="data">The data storage, must match the size of the UMat</param>
        public void CopyTo(Array data)
        {
            if (IsEmpty)
            {
                throw new Exception("The UMat is empty");
            }

            using (Mat.MatWithHandle m = Mat.PrepareArrayForCopy(Depth, Size, NumberOfChannels, data))
                CopyTo(m);
        }