示例#1
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す.
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
        /// <param name="ranges">ヒストグラムのビン(bin)(値域)を示す配列.このパラメータの意味はパラメータuniformに依存している.
        /// このレンジは,ヒストグラムを計算したり,またどのヒストグラムのビンが入力画像のどの値やどのデータ要素に対応するかを決めるためのバックプロジェクションで用いられる.
        /// null の場合は,後から関数 cvSetHistBinRanges を用いて決定される.</param>
        /// <param name="uniform">一様性に関するフラグ</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <param name="ranges">Array of ranges for histogram bins. Its meaning depends on the uniform parameter value. The ranges are used for when histogram is calculated or backprojected to determine, which histogram bin corresponds to which value/tuple of values from the input image[s]. </param>
        /// <param name="uniform">Uniformity flag.</param>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type, float[][] ranges, bool uniform)
        {
            if (sizes == null)
            {
                throw new ArgumentNullException("sizes");
            }

            if (ranges == null)
            {
                ptr = NativeMethods.cvCreateHist(sizes.Length, sizes, type, IntPtr.Zero, uniform);
            }
            else
            {
                // float[][]をIntPtr[]に変換する
                using (var rangesPtr = new ArrayAddress2 <float>(ranges))
                {
                    ptr = NativeMethods.cvCreateHist(sizes.Length, sizes, type, rangesPtr.Pointer, uniform);
                }
            }
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Failed to create CvHistogram");
            }

            if (ranges != null)
            {
                SetBinRanges(ranges, uniform);
            }
            Type = type;
            NotifyMemoryPressure(SizeOf);
        }
示例#2
0
 public static extern IntPtr cvCreateHist(int dims, [MarshalAs(UnmanagedType.LPArray)] int[] sizes, HistogramFormat type,
     IntPtr ranges, [MarshalAs(UnmanagedType.Bool)] bool uniform);
示例#3
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す. 
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
        /// <param name="ranges">ヒストグラムのビン(bin)(値域)を示す配列.このパラメータの意味はパラメータuniformに依存している.
        /// このレンジは,ヒストグラムを計算したり,またどのヒストグラムのビンが入力画像のどの値やどのデータ要素に対応するかを決めるためのバックプロジェクションで用いられる.
        /// null の場合は,後から関数 cvSetHistBinRanges を用いて決定される.</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <param name="ranges">Array of ranges for histogram bins. Its meaning depends on the uniform parameter value. The ranges are used for when histogram is calculated or backprojected to determine, which histogram bin corresponds to which value/tuple of values from the input image[s]. </param>
        /// <returns></returns>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type, float[][] ranges)
            : this(sizes, type, ranges, true)
        {
        }
示例#4
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す. 
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <returns></returns>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type)
            : this(sizes, type, null, true)
        {
        }
示例#5
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す. 
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
        /// <param name="ranges">ヒストグラムのビン(bin)(値域)を示す配列.このパラメータの意味はパラメータuniformに依存している.
        /// このレンジは,ヒストグラムを計算したり,またどのヒストグラムのビンが入力画像のどの値やどのデータ要素に対応するかを決めるためのバックプロジェクションで用いられる.
        /// null の場合は,後から関数 cvSetHistBinRanges を用いて決定される.</param>
        /// <param name="uniform">一様性に関するフラグ</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <param name="ranges">Array of ranges for histogram bins. Its meaning depends on the uniform parameter value. The ranges are used for when histogram is calculated or backprojected to determine, which histogram bin corresponds to which value/tuple of values from the input image[s]. </param>
        /// <param name="uniform">Uniformity flag.</param>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type, float[][] ranges, bool uniform)
        {
            if (sizes == null)
            {
                throw new ArgumentNullException("dims");
            }

            if (ranges == null)
            {
                this._ptr = CvInvoke.cvCreateHist(sizes.Length, sizes, type, IntPtr.Zero, uniform);
            }
            else
            {
                // float[][]をIntPtr[]に変換する
                using (var rangesPtr = new ArrayAddress2<float>(ranges))
                {
                    this._ptr = CvInvoke.cvCreateHist(sizes.Length, sizes, type, rangesPtr.Pointer, uniform);
                }
            }
            if (this._ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Failed to create CvHistogram");
            }

            if (ranges != null)
            {
                SetBinRanges(ranges, uniform);
            }
            this.Type = type;
            base.NotifyMemoryPressure(SizeOf);
        }
示例#6
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す.
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
        /// <param name="ranges">ヒストグラムのビン(bin)(値域)を示す配列.このパラメータの意味はパラメータuniformに依存している.
        /// このレンジは,ヒストグラムを計算したり,またどのヒストグラムのビンが入力画像のどの値やどのデータ要素に対応するかを決めるためのバックプロジェクションで用いられる.
        /// null の場合は,後から関数 cvSetHistBinRanges を用いて決定される.</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <param name="ranges">Array of ranges for histogram bins. Its meaning depends on the uniform parameter value. The ranges are used for when histogram is calculated or backprojected to determine, which histogram bin corresponds to which value/tuple of values from the input image[s]. </param>
        /// <returns></returns>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type, float[][] ranges)
            : this(sizes, type, ranges, true)
        {
        }
示例#7
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す.
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <returns></returns>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type)
            : this(sizes, type, null, true)
        {
        }
示例#8
0
        /// <summary>
        /// 指定サイズのヒストグラムを生成し,そのヒストグラムの参照を返す. 
        /// </summary>
        /// <param name="sizes">ヒストグラム各次元のサイズを示す配列</param>
        /// <param name="type">ヒストグラム表現フォーマット</param>
        /// <param name="ranges">ヒストグラムのビン(bin)(値域)を示す配列.このパラメータの意味はパラメータuniformに依存している.
        /// このレンジは,ヒストグラムを計算したり,またどのヒストグラムのビンが入力画像のどの値やどのデータ要素に対応するかを決めるためのバックプロジェクションで用いられる.
        /// null の場合は,後から関数 cvSetHistBinRanges を用いて決定される.</param>
        /// <param name="uniform">一様性に関するフラグ</param>
#else
        /// <summary>
        /// Creates a histogram of the specified size and returns the pointer to the created histogram.
        /// </summary>
        /// <param name="sizes">Number of histogram dimensions. </param>
        /// <param name="type">Histogram representation format.</param>
        /// <param name="ranges">Array of ranges for histogram bins. Its meaning depends on the uniform parameter value. The ranges are used for when histogram is calculated or backprojected to determine, which histogram bin corresponds to which value/tuple of values from the input image[s]. </param>
        /// <param name="uniform">Uniformity flag.</param>
#endif
        public CvHistogram(int[] sizes, HistogramFormat type, float[][] ranges, bool uniform)
        {
            if (sizes == null)
                throw new ArgumentNullException("sizes");

            if (ranges == null)
            {
                ptr = NativeMethods.cvCreateHist(sizes.Length, sizes, type, IntPtr.Zero, uniform);
            }
            else
            {
                // float[][]をIntPtr[]に変換する
                using (var rangesPtr = new ArrayAddress2<float>(ranges))
                {
                    ptr = NativeMethods.cvCreateHist(sizes.Length, sizes, type, rangesPtr.Pointer, uniform);
                }
            }
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Failed to create CvHistogram");
            }

            if (ranges != null)
            {
                SetBinRanges(ranges, uniform);
            }
            Type = type;
        }