Example #1
0
        /// <summary>
        /// 初期化
        /// </summary>
        /// <param name="point">左上の頂点の座標</param>
        /// <param name="size">矩形の大きさ</param>
#else
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="point">coordinate of the left-most rectangle corner</param>
        /// <param name="size">size of the rectangle</param>
#endif
        public CvRect(CvPoint point, CvSize size)
        {
            X      = point.X;
            Y      = point.Y;
            Width  = size.Width;
            Height = size.Height;
        }
Example #2
0
        /// <summary>
        /// チェスボードからコーナーが完全に検出されていない場合(pattern_was_found=false)は,検出されたコーナーそれぞれに赤色の円を描く.
        /// また完全に検出されている場合(pattern_was_found=true)は,色付けされた各コーナを線分で接続して表示する. 
        /// </summary>
        /// <param name="image">コーナー点を表示する画像.8ビットカラー画像.</param>
        /// <param name="patternSize">チェスボードの各行と各列の内部コーナーの数.</param>
        /// <param name="corners">検出されたコーナーの配列.</param>
        /// <param name="patternWasFound">チェスボードからコーナーが完全に発見された(true)か,そうでない(false)かを示す.</param>
#else
        /// <summary>
        /// Draws the individual chessboard corners detected (as red circles) in case if the board was not found (pattern_was_found=0) or the colored corners connected with lines when the board was found (pattern_was_found≠0). 
        /// </summary>
        /// <param name="image">The destination image; it must be 8-bit color image. </param>
        /// <param name="patternSize">The number of inner corners per chessboard row and column. </param>
        /// <param name="corners">The array of corners detected. </param>
        /// <param name="patternWasFound">Indicates whether the complete board was found (≠0) or not (=0). One may just pass the return value cvFindChessboardCorners here. </param>
#endif
        public static void DrawChessboardCorners(CvArr image, CvSize patternSize, CvPoint2D32f[] corners, bool patternWasFound)
        {
            if (image == null)
                throw new ArgumentNullException("image");
            if (corners == null)
                throw new ArgumentNullException("corners");
            NativeMethods.cvDrawChessboardCorners(image.CvPtr, patternSize, corners, corners.Length, patternWasFound);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="modelPoints"></param>
 /// <param name="modelSize"></param>
 /// <param name="maxBasicSolutions"></param>
 protected CvModelEstimator2(int modelPoints, CvSize modelSize, int maxBasicSolutions)
 {
     this.modelPoints         = modelPoints;
     this.modelSize           = modelSize;
     this.maxBasicSolutions   = maxBasicSolutions;
     this.checkPartialSubsets = true;
     this.rng = new CvRNG(-1);
 }
Example #4
0
        /// <summary>
        /// チェスボードからコーナーが完全に検出されていない場合(pattern_was_found=false)は,検出されたコーナーそれぞれに赤色の円を描く.
        /// また完全に検出されている場合(pattern_was_found=true)は,色付けされた各コーナを線分で接続して表示する.
        /// </summary>
        /// <param name="image">コーナー点を表示する画像.8ビットカラー画像.</param>
        /// <param name="patternSize">チェスボードの各行と各列の内部コーナーの数.</param>
        /// <param name="corners">検出されたコーナーの配列.</param>
        /// <param name="patternWasFound">チェスボードからコーナーが完全に発見された(true)か,そうでない(false)かを示す.</param>
#else
        /// <summary>
        /// Draws the individual chessboard corners detected (as red circles) in case if the board was not found (pattern_was_found=0) or the colored corners connected with lines when the board was found (pattern_was_found≠0).
        /// </summary>
        /// <param name="image">The destination image; it must be 8-bit color image. </param>
        /// <param name="patternSize">The number of inner corners per chessboard row and column. </param>
        /// <param name="corners">The array of corners detected. </param>
        /// <param name="patternWasFound">Indicates whether the complete board was found (≠0) or not (=0). One may just pass the return value cvFindChessboardCorners here. </param>
#endif
        public static void DrawChessboardCorners(CvArr image, CvSize patternSize, CvPoint2D32f[] corners, bool patternWasFound)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (corners == null)
            {
                throw new ArgumentNullException(nameof(corners));
            }
            NativeMethods.cvDrawChessboardCorners(image.CvPtr, patternSize, corners, corners.Length, patternWasFound);
            KeepAlive(image);
        }
Example #5
0
        public static CvHaarClassifierCascade FromDirectory(string directory, CvSize origWindowSize)
        {
            if (string.IsNullOrEmpty(directory))
            {
                throw new ArgumentNullException("directory");
            }
            IntPtr result = NativeMethods.cvLoadHaarClassifierCascade(directory, origWindowSize);

            if (result == IntPtr.Zero)
            {
                return(null);
            }
            return(new CvHaarClassifierCascade(result));
        }
Example #6
0
        /// <summary>
        /// ビデオライタを作成し、返す.
        /// </summary>
        /// <param name="filename">出力するビデオファイルの名前</param>
        /// <param name="fourcc">
        /// フレームを圧縮するためのコーデックを表す 4 文字.例えば,"PIM1" は,MPEG-1 コーデック, "MJPG" は,motion-jpeg コーデックである.
        /// Win32 環境下では,null を渡すとダイアログから圧縮方法と圧縮のパラメータを選択できるようになる.
        /// </param>
        /// <param name="fps">作成されたビデオストリームのフレームレート</param>
        /// <param name="frameSize">ビデオフレームのサイズ</param>
        /// <param name="isColor">trueの場合,エンコーダはカラーフレームとしてエンコードする. falseの場合,グレースケールフレームとして動作する(現在のところ,このフラグは Windows でのみ利用できる).</param>
        /// <returns>CvVideoWriter</returns>
#else
        /// <summary>
        /// Creates video writer structure.
        /// </summary>
        /// <param name="filename">Name of the output video file. </param>
        /// <param name="fourcc">4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc.
        /// Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. </param>
        /// <param name="fps">Framerate of the created video stream. </param>
        /// <param name="frameSize">Size of video frames. </param>
        /// <param name="isColor">If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). </param>
        /// <returns></returns>
#endif
        public CvVideoWriter(string filename, int fourcc, double fps, CvSize frameSize, bool isColor)
        {
            if (filename == null)
            {
                throw new ArgumentNullException();
            }
            FileName  = filename;
            Fps       = fps;
            FrameSize = frameSize;
            IsColor   = isColor;
            ptr       = NativeMethods.cvCreateVideoWriter(filename, fourcc, fps, frameSize, isColor);
            if (ptr == IntPtr.Zero)
            {
                throw new OpenCvSharpException("Failed to create CvVideoWriter");
            }
        }
Example #7
0
        /// <summary>
        /// ビデオライタを作成し、返す.
        /// </summary>
        /// <param name="filename">出力するビデオファイルの名前</param>
        /// <param name="fourcc">
        /// フレームを圧縮するためのコーデックを表す 4 文字.例えば,"PIM1" は,MPEG-1 コーデック, "MJPG" は,motion-jpeg コーデックである.
        /// Win32 環境下では,null を渡すとダイアログから圧縮方法と圧縮のパラメータを選択できるようになる.
        /// </param>
        /// <param name="fps">作成されたビデオストリームのフレームレート</param>
        /// <param name="frameSize">ビデオフレームのサイズ</param>
        /// <param name="isColor">trueの場合,エンコーダはカラーフレームとしてエンコードする. falseの場合,グレースケールフレームとして動作する(現在のところ,このフラグは Windows でのみ利用できる).</param>
        /// <returns>CvVideoWriter</returns>
#else
        /// <summary>
        /// Creates video writer structure.
        /// </summary>
        /// <param name="filename">Name of the output video file. </param>
        /// <param name="fourcc">4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc.
        /// Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. </param>
        /// <param name="fps">Framerate of the created video stream. </param>
        /// <param name="frameSize">Size of video frames. </param>
        /// <param name="isColor">If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). </param>
        /// <returns></returns>
#endif
        public CvVideoWriter(string filename, FourCC fourcc, double fps, CvSize frameSize, bool isColor)
            : this(filename, (int)fourcc, fps, frameSize, isColor)
        {
        }
Example #8
0
        /// <summary>
        /// ヒストグラムの比較に基づき画像内部でのテンプレート位置を求める
        /// </summary>
        /// <param name="image">入力画像群( CvMat** 形式でも構わない).すべて同じサイズ.</param>
        /// <param name="dst">出力画像</param>
        /// <param name="patchSize">入力画像群上をスライドさせるテンプレートのサイズ</param>
        /// <param name="method">比較方法.値は関数 cvCompareHist に渡される(この関数に関する記述を参照)</param>
        /// <param name="factor">ヒストグラムの正規化係数.出力画像の正規化スケールに影響する.値に確信がない場合は,1にする.</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Locates a template within image by histogram comparison
        /// </summary>
        /// <param name="image">Source images (though you may pass CvMat** as well), all are of the same size and type </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="patchSize">Size of patch slid though the source images. </param>
        /// <param name="method">Compasion method, passed to cvCompareHist (see description of that function). </param>
        /// <param name="factor">Normalization factor for histograms, will affect normalization scale of destination image, pass 1. if unsure. </param>
        /// <returns></returns>
#endif
        public void CalcBackProjectPatch(CvArr[] image, CvArr dst, CvSize patchSize, HistogramComparison method, float factor)
        {
            Cv.CalcArrBackProjectPatch(image, dst, patchSize, this, method, factor);
        }
Example #9
0
        /// <summary>
        /// 与えられた画像からオブジェクトを含む様な矩形領域を検出し,それらの領域を矩形の列として返す.
        /// </summary>
        /// <param name="image">この画像の中からオブジェクトを検出する</param>
        /// <param name="storage">オブジェクト候補の矩形が得られた場合に,その矩形列を保存するメモリストレージ</param>
        /// <param name="scaleFactor">スキャン毎に探索ウィンドウがスケーリングされる際のスケールファクタ. 例えばこの値が 1.1 ならば,ウィンドウが 10% 大きくなる</param>
        /// <param name="minNeighbors">(これから 1 を引いた値が)オブジェクトを構成する近傍矩形の最小数となる. min_neighbors-1 よりも少ない矩形しか含まないようなグループは全て棄却される. もし min_neighbors が 0 である場合,この関数はグループを一つも生成せず,候補となる矩形を全て返す.これはユーザがカスタマイズしたグループ化処理を適用したい場合に有用である. </param>
        /// <param name="flags">処理モード</param>
        /// <param name="minSize">最小ウィンドウサイズ.デフォルトでは分類器の学習に用いられたサンプルのサイズが設定される(顔検出の場合は,~20×20).</param>
        /// <returns>CvAvgCompを要素とするCvSeq</returns>
#else
        /// <summary>
        /// Finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles.
        /// </summary>
        /// <param name="image">Image to detect objects in. </param>
        /// <param name="storage">Memory storage to store the resultant sequence of the object candidate rectangles. </param>
        /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%. </param>
        /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure. </param>
        /// <param name="flags">Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING. If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing. </param>
        /// <param name="minSize">Minimum window size. By default, it is set to the size of samples the classifier has been trained on (~20×20 for face detection). </param>
        /// <returns></returns>
#endif
        public CvSeq HaarDetectObjects(CvArr image, CvMemStorage storage, double scaleFactor, int minNeighbors, HaarDetectionType flags, CvSize minSize)
        {
            return(Cv.HaarDetectObjects(image, this, storage, scaleFactor, minNeighbors, flags, minSize));
        }
Example #10
0
 public static IplImage FromPixelData(CvSize size, int channels, short[] data);
Example #11
0
        /// <summary>
        /// ビデオライタを作成し、返す.
        /// </summary>
        /// <param name="filename">出力するビデオファイルの名前</param>
        /// <param name="fourcc">
        /// フレームを圧縮するためのコーデックを表す 4 文字.例えば,"PIM1" は,MPEG-1 コーデック, "MJPG" は,motion-jpeg コーデックである.
        /// Win32 環境下では,null を渡すとダイアログから圧縮方法と圧縮のパラメータを選択できるようになる.
        /// </param>
        /// <param name="fps">作成されたビデオストリームのフレームレート</param>
        /// <param name="frameSize">ビデオフレームのサイズ</param>
#else
        /// <summary>
        /// Creates video writer structure.
        /// </summary>
        /// <param name="filename">Name of the output video file. </param>
        /// <param name="fourcc">4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc.
        /// Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. </param>
        /// <param name="fps">Framerate of the created video stream. </param>
        /// <param name="frameSize">Size of video frames. </param>
#endif
        public CvVideoWriter(string filename, string fourcc, double fps, CvSize frameSize)
            : this(filename, Cv.FOURCC(fourcc), fps, frameSize, true)
        {
        }
Example #12
0
 public void SnakeImage(CvPoint[] points, float[] alpha, float[] beta, float[] gamma, CvSize win,
                        CvTermCriteria criteria, bool calc_gradient);
Example #13
0
 public void SnakeImage(CvPoint[] points, float[] alpha, float[] beta, float[] gamma, CvSize win,
                        CvTermCriteria criteria);
Example #14
0
 public IplImage(CvSize size, BitDepth depth, int channels);
Example #15
0
 public static IplImage InitImageHeader(CvSize size, BitDepth depth, int channels, ImageOrigin origin, int align);
Example #16
0
 public static IplImage InitImageHeader(CvSize size, BitDepth depth, int channels);
Example #17
0
 public int CheckChessboard(CvSize size);
Example #18
0
        /// <summary>
        /// ビデオライタを作成し、返す.
        /// </summary>
        /// <param name="filename">出力するビデオファイルの名前</param>
        /// <param name="fourcc">
        /// フレームを圧縮するためのコーデックを表す 4 文字.例えば,"PIM1" は,MPEG-1 コーデック, "MJPG" は,motion-jpeg コーデックである.
        /// Win32 環境下では,null を渡すとダイアログから圧縮方法と圧縮のパラメータを選択できるようになる.
        /// </param>
        /// <param name="fps">作成されたビデオストリームのフレームレート</param>
        /// <param name="frameSize">ビデオフレームのサイズ</param>
        /// <returns>CvVideoWriter</returns>
#else
        /// <summary>
        /// Creates video writer structure.
        /// </summary>
        /// <param name="filename">Name of the output video file. </param>
        /// <param name="fourcc">4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc.
        /// Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. </param>
        /// <param name="fps">Framerate of the created video stream. </param>
        /// <param name="frameSize">Size of video frames. </param>
        /// <returns></returns>
#endif
        public CvVideoWriter(string filename, int fourcc, double fps, CvSize frameSize)
            : this(filename, fourcc, fps, frameSize, true)
        {
        }
Example #19
0
        /// <summary>
        /// このCvRectを指定の量だけ膨らませる
        /// </summary>
        /// <param name="size">この四角形の膨張量</param>
#else
        /// <summary>
        /// Inflates this CvRect by the specified amount.
        /// </summary>
        /// <param name="size">The amount to inflate this rectangle. </param>
#endif
        public void Inflate(CvSize size)
        {
            Inflate(size.Width, size.Height);
        }
Example #20
0
 public static IplImage FromPixelData(CvSize size, int channels, IntPtr data);
Example #21
0
        /// <summary>
        /// ビデオライタを作成し、返す.
        /// </summary>
        /// <param name="filename">出力するビデオファイルの名前</param>
        /// <param name="fourcc">
        /// フレームを圧縮するためのコーデックを表す 4 文字.例えば,"PIM1" は,MPEG-1 コーデック, "MJPG" は,motion-jpeg コーデックである.
        /// Win32 環境下では,null を渡すとダイアログから圧縮方法と圧縮のパラメータを選択できるようになる.
        /// </param>
        /// <param name="fps">作成されたビデオストリームのフレームレート</param>
        /// <param name="frameSize">ビデオフレームのサイズ</param>
        /// <param name="isColor">trueの場合,エンコーダはカラーフレームとしてエンコードする. falseの場合,グレースケールフレームとして動作する(現在のところ,このフラグは Windows でのみ利用できる).</param>
        /// <returns>CvVideoWriter</returns>
#else
        /// <summary>
        /// Creates video writer structure.
        /// </summary>
        /// <param name="filename">Name of the output video file. </param>
        /// <param name="fourcc">4-character code of codec used to compress the frames. For example, "PIM1" is MPEG-1 codec, "MJPG" is motion-jpeg codec etc.
        /// Under Win32 it is possible to pass null in order to choose compression method and additional compression parameters from dialog. </param>
        /// <param name="fps">Framerate of the created video stream. </param>
        /// <param name="frameSize">Size of video frames. </param>
        /// <param name="isColor">If it is true, the encoder will expect and encode color frames, otherwise it will work with grayscale frames (the flag is currently supported on Windows only). </param>
#endif
        public CvVideoWriter(string filename, string fourcc, double fps, CvSize frameSize, bool isColor)
            : this(filename, Cv.FOURCC(fourcc), fps, frameSize, isColor)
        {
        }
Example #22
0
 public static IplImage FromPixelData(CvSize size, BitDepth depth, int channels, Array data);
Example #23
0
        /// <summary>
        /// 与えられた画像からオブジェクトを含む様な矩形領域を検出し,それらの領域を矩形の列として返す.
        /// </summary>
        /// <param name="image">この画像の中からオブジェクトを検出する</param>
        /// <param name="cascade">Haar 分類器カスケード の内部表現</param>
        /// <param name="storage">オブジェクト候補の矩形が得られた場合に,その矩形列を保存するメモリストレージ</param>
        /// <param name="scaleFactor">スキャン毎に探索ウィンドウがスケーリングされる際のスケールファクタ. 例えばこの値が 1.1 ならば,ウィンドウが 10% 大きくなる</param>
        /// <param name="minNeighbors">(これから 1 を引いた値が)オブジェクトを構成する近傍矩形の最小数となる. min_neighbors-1 よりも少ない矩形しか含まないようなグループは全て棄却される. もし min_neighbors が 0 である場合,この関数はグループを一つも生成せず,候補となる矩形を全て返す.これはユーザがカスタマイズしたグループ化処理を適用したい場合に有用である. </param>
        /// <param name="flags">処理モード</param>
        /// <param name="minSize">最小ウィンドウサイズ.デフォルトでは分類器の学習に用いられたサンプルのサイズが設定される(顔検出の場合は,~20×20).</param>
        /// <returns>CvAvgCompを要素とするCvSeq</returns>
#else
        /// <summary>
        /// Finds rectangular regions in the given image that are likely to contain objects the cascade has been trained for and returns those regions as a sequence of rectangles.
        /// </summary>
        /// <param name="image">Image to detect objects in. </param>
        /// <param name="cascade">Haar classifier cascade in internal representation. </param>
        /// <param name="storage">Memory storage to store the resultant sequence of the object candidate rectangles. </param>
        /// <param name="scaleFactor">The factor by which the search window is scaled between the subsequent scans, for example, 1.1 means increasing window by 10%. </param>
        /// <param name="minNeighbors">Minimum number (minus 1) of neighbor rectangles that makes up an object. All the groups of a smaller number of rectangles than min_neighbors-1 are rejected. If min_neighbors is 0, the function does not any grouping at all and returns all the detected candidate rectangles, which may be useful if the user wants to apply a customized grouping procedure. </param>
        /// <param name="flags">Mode of operation. Currently the only flag that may be specified is CV_HAAR_DO_CANNY_PRUNING. If it is set, the function uses Canny edge detector to reject some image regions that contain too few or too much edges and thus can not contain the searched object. The particular threshold values are tuned for face detection and in this case the pruning speeds up the processing. </param>
        /// <param name="minSize">Minimum window size. By default, it is set to the size of samples the classifier has been trained on (~20×20 for face detection). </param>
        /// <returns></returns>
#endif
        public static CvSeq <CvAvgComp> HaarDetectObjects(CvArr image, CvHaarClassifierCascade cascade, CvMemStorage storage, double scaleFactor, int minNeighbors, HaarDetectionType flags, CvSize minSize)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }
            if (cascade == null)
            {
                throw new ArgumentNullException("cascade");
            }
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }
            IntPtr result = NativeMethods.cvHaarDetectObjects(image.CvPtr, cascade.CvPtr, storage.CvPtr, scaleFactor, minNeighbors, flags, minSize);

            if (result == IntPtr.Zero)
            {
                return(null);
            }
            else
            {
                return(new CvSeq <CvAvgComp>(result));
            }
        }
Example #24
0
 public Vec2F(OpenCvSharp.CvSize size) : this(size.Width, size.Height)
 {
 }