Beispiel #1
0
        /// <summary>
        /// N x 1 の行列(ベクトル)として初期化し、指定した配列からデータをコピーする
        /// </summary>
        /// <param name="arr">この行列にコピーされるデータ</param>
#else
        /// <summary>
        /// Initializes as N x 1 matrix and copies array data to this
        /// </summary>
        /// <param name="arr">Source array data to be copied to this</param>
#endif
        public static Mat <TElem> FromArray(params TElem[] arr)
        {
            if (arr == null)
            {
                throw new ArgumentNullException(nameof(arr));
            }
            if (arr.Length == 0)
            {
                throw new ArgumentException("arr.Length == 0");
            }

            var numElems = arr.Length /* / ThisChannels*/;
            var mat      = new Mat <TElem>(numElems, 1);

            if (!mat.SetArray(arr))
            {
                throw new OpenCvSharpException("Failed to copy pixel data into cv::Mat");
            }
            return(mat);
        }