Example #1
0
        /// <summary>
        /// 参照カウンタのポインタが null ではない場合に CvMat あるいは CvMatND のデータの参照カウンタをデクリメントし,さらにカウンタが 0 になった場合にはデータを解放する.
        /// </summary>
        /// <param name="arr">配列ヘッダ</param>
#else
        /// <summary>
        /// Decrements array data reference counter.
        /// </summary>
        /// <param name="arr">Input array. </param>
#endif
        public static void DecRefData(CvArr arr)
        {
            if (arr == null)
            {
                throw new ArgumentNullException(nameof(arr));
            }
            unsafe
            {
                if (arr is CvMat)
                {
                    CvMat mat = (CvMat)arr;
                    mat.Data = IntPtr.Zero;
                    if (mat.RefCount != IntPtr.Zero && --*(int *)mat.RefCount == 0)
                    {
                        NativeMethods.cvFree_(mat.RefCount);
                    }
                    mat.RefCount = IntPtr.Zero;
                }
                else if (arr is CvMatND)
                {
                    CvMatND mat = (CvMatND)arr;
                    mat.Data = IntPtr.Zero;
                    if (mat.RefCount != IntPtr.Zero && --*(int *)mat.RefCount == 0)
                    {
                        NativeMethods.cvFree_(mat.RefCount);
                    }
                    mat.RefCount = IntPtr.Zero;
                }
            }
            KeepAlive(arr);
        }
Example #2
0
        /// <summary>
        /// 参照カウンタのポインタが null ではない場合に CvMat あるいは CvMatND のデータの参照カウンタをデクリメントし,さらにカウンタが 0 になった場合にはデータを解放する.
        /// </summary>
        /// <param name="arr">配列ヘッダ</param>
#else
        /// <summary>
        /// Decrements array data reference counter.
        /// </summary>
        /// <param name="arr">Input array. </param>
#endif
        public static void DecRefData(CvArr arr)
        {
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }
            unsafe
            {
                if (arr is CvMat)
                {
                    CvMat mat = (CvMat)arr;
                    mat.Data = IntPtr.Zero;
                    if (mat.RefCount != IntPtr.Zero && --*(int*)mat.RefCount == 0)
                        NativeMethods.cvFree_(mat.RefCount);
                    mat.RefCount = IntPtr.Zero;
                }
                else if (arr is CvMatND)
                {
                    CvMatND mat = (CvMatND)arr;
                    mat.Data = IntPtr.Zero;
                    if (mat.RefCount != IntPtr.Zero && --*(int*)mat.RefCount == 0)
                        NativeMethods.cvFree_(mat.RefCount);
                    mat.RefCount = IntPtr.Zero;
                }
            }
        }
Example #3
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 #4
0
        public static void MainLoop()
        {
            PROCESS.SetWindowPos(0, 0, 800, 600);
            Thread.Sleep(200);
            foreach (var image in ImageList)
            {
                CvMat screen = Utils.TakeScreenshot().ToMat().ToCvMat();
                Screenshot = new CvMat(screen.Rows, screen.Cols, MatrixType.U8C1);
                screen.CvtColor(Screenshot, ColorConversion.BgraToGray);

                Result =
                    Cv.CreateImage(Cv.Size(Screenshot.Width - image.Width + 1, Screenshot.Height - image.Height + 1),
                        BitDepth.F32, 1);
                Cv.MatchTemplate(Screenshot, image, Result, MatchTemplateMethod.CCoeffNormed);
                /*Screenshot.SaveImage("data/screenshot.png");
                image.SaveImage("data/image.png");*/
                Cv.Normalize(Result, Result, 0, 1, NormType.MinMax);
                Cv.MinMaxLoc(Result, out MinAcc, out MaxAcc, out MinPos, out MaxPos, null);
                Console.WriteLine(MaxAcc);
                if (MaxAcc >= 0.75)
                {
                    Position = new Point(MaxPos.X, MaxPos.Y);
                    Utils.MoveMouse(Position);
                    Thread.Sleep(15);
                    Utils.LeftClick();
                    Thread.Sleep(100);
                    MaxAcc = 0;
                }
                Result.Dispose();
            }
        }
Example #5
0
        /// <summary>
        /// 半径方向や円周方向のレンズ歪みを補正するために画像を変換する.
        /// </summary>
        /// <param name="src">入力画像(歪みあり)</param>
        /// <param name="dst">出力画像(補正済み)</param>
        /// <param name="intrinsicMatrix">カメラ内部行列 (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">歪み係数ベクトル. 4x1 または 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#else
        /// <summary>
        /// Transforms image to compensate lens distortion.
        /// </summary>
        /// <param name="src">The input (distorted) image. </param>
        /// <param name="dst">The output (corrected) image. </param>
        /// <param name="intrinsicMatrix">The camera matrix (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">The vector of distortion coefficients, 4x1 or 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#endif
        public static void Undistort2(CvArr src, CvArr dst, CvMat intrinsicMatrix, CvMat distortionCoeffs, CvMat newCameraMatrix)
        {
            if (src == null)
            {
                throw new ArgumentNullException("src");
            }
            if (dst == null)
            {
                throw new ArgumentNullException("dst");
            }
            if (intrinsicMatrix == null)
            {
                throw new ArgumentNullException("intrinsicMatrix");
            }
            if (distortionCoeffs == null)
            {
                throw new ArgumentNullException("distortionCoeffs");
            }

            NativeMethods.cvUndistort2(
                src.CvPtr, dst.CvPtr, intrinsicMatrix.CvPtr, distortionCoeffs.CvPtr, ToPtr(newCameraMatrix));

            GC.KeepAlive(src);
            GC.KeepAlive(dst);
            GC.KeepAlive(intrinsicMatrix);
            GC.KeepAlive(distortionCoeffs);
            GC.KeepAlive(newCameraMatrix);
        }
Example #6
0
        /// <summary>
        /// 画像の外側輪郭線,または内側輪郭線を描画する
        /// </summary>
        /// <param name="img">輪郭を描画する元画像.輪郭はROIで切り取られる.</param>
        /// <param name="contour">最初の輪郭へのポインタ</param>
        /// <param name="externalColor">外側輪郭線の色</param>
        /// <param name="holeColor">内側輪郭線(穴)の色</param>
        /// <param name="maxLevel">描画される輪郭の最大レベル. 0にした場合,contourのみが描画される. 1にした場合,先頭の輪郭と,同レベルのすべての輪郭が描画される. 2にした場合,先頭の輪郭と同レベルのすべての輪郭と,先頭の輪郭の一つ下のレベルのすべての輪郭が描画される.以下同様.</param>
        /// <param name="thickness">描画される輪郭線の太さ. 負(例えば=Cv.FILLED)にした場合には,内部を塗りつぶす.</param>
        /// <param name="lineType">線の種類</param>
        /// <param name="offset">全ての座標を指定した値だけシフトする</param>
#else
        /// <summary>
        /// Draws contour outlines or interiors in the image
        /// </summary>
        /// <param name="img">Image where the contours are to be drawn. Like in any other drawing function, the contours are clipped with the ROI. </param>
        /// <param name="contour">Reference to the first contour. </param>
        /// <param name="externalColor">Color of the external contours. </param>
        /// <param name="holeColor">Color of internal contours (holes). </param>
        /// <param name="maxLevel">Maximal level for drawn contours. If 0, only contour is drawn. If 1, the contour and all contours after it on the same level are drawn. If 2, all contours after and all contours one level below the contours are drawn, etc. If the value is negative, the function does not draw the contours following after contour but draws child contours of contour up to abs(max_level)-1 level. </param>
        /// <param name="thickness">Thickness of lines the contours are drawn with. If it is negative (e.g. =CV_FILLED), the contour interiors are drawn. </param>
        /// <param name="lineType">Type of the contour segments.</param>
        /// <param name="offset">Shift all the point coordinates by the specified value. It is useful in case if the contours retrieved in some image ROI and then the ROI offset needs to be taken into account during the rendering. </param>
#endif
        public static void DrawContours(CvArr img, CvSeq<CvPoint> contour, CvScalar externalColor, CvScalar holeColor, int maxLevel, int thickness, LineType lineType, CvPoint offset)
        {
            if (img == null)
                throw new ArgumentNullException("img");
            if (contour == null)
                throw new ArgumentNullException("contour");
            NativeMethods.cvDrawContours(img.CvPtr, contour.CvPtr, externalColor, holeColor, maxLevel, thickness, lineType, offset);
        }
Example #7
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);
        }
Example #8
0
        /// <summary>
        /// ユークリッド距離に基づく2つの配列の内積を計算する.
        /// src1•src2 = sumI(src1(I)*src2(I))
        /// </summary>
        /// <param name="src1">1番目の入力配列</param>
        /// <param name="src2">2番目の入力配列</param>
        /// <returns>ユークリッド距離に基づく2つの配列の内積</returns>
#else
        /// <summary>
        /// Calculates dot product of two arrays in Euclidean metrics
        /// </summary>
        /// <param name="src1">The first source array. </param>
        /// <param name="src2">The second source array. </param>
        /// <returns></returns>
#endif
        public static double DotProduct(CvArr src1, CvArr src2)
        {
            if (src1 == null)
                throw new ArgumentNullException("src1");
            if (src2 == null)
                throw new ArgumentNullException("src2");
            return NativeMethods.cvDotProduct(src1.CvPtr, src2.CvPtr);
        }
Example #9
0
        /// <summary>
        /// 行列式を返す
        /// </summary>
        /// <param name="mat">入力行列</param>
        /// <returns>行列式</returns>
#else
        /// <summary>
        /// Returns determinant of matrix
        /// </summary>
        /// <param name="mat">The source matrix. </param>
        /// <returns>determinant of the square matrix mat</returns>
#endif
        public static double Det(CvArr mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            return NativeMethods.cvDet(mat.CvPtr);
        }
Example #10
0
        /// <summary>
        /// 配列の要素の絶対値を計算する. 
        /// dst(I) = abs(src(I)).
        /// すべての配列は同じタイプ,同じサイズ(または同じROIサイズ)でなければならない.
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
#else
        /// <summary>
        /// Calculates absolute difference between array and scalar
        /// </summary>
        /// <param name="src">The source array. </param>
        /// <param name="dst">The destination array. </param>
#endif
        public static void Abs(CvArr src, CvArr dst)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            CvInvoke.cvAbsDiffS(src.CvPtr, dst.CvPtr, CvScalar.ScalarAll(0));
        }
Example #11
0
        /// <summary>
        /// 2次元点列を包含するまっすぐな矩形を返す.
        /// </summary>
        /// <param name="points">シーケンス(CvSeq, CvContour)か,点のベクトル(CvMat)か,非0のピクセルが点列とみなされる8ビット1チャンネルマスク画像 (CvMat, IplImage)のいずれかで表現された2次元の点列.</param>
        /// <param name="update">更新フラグ.
        /// pointsがCvContour で,update=falseの場合: 包含矩形は計算されず,輪郭ヘッダのrectフィールドから読み込まれる.
        /// pointsがCvContour で,update=trueの場合: 包含矩形は計算され,輪郭ヘッダのrectフィールドに書き込まれる.
        /// pointsがCvSeqかCvMatの場合: updateは無視されて,包含矩形は計算されて返される. </param>
        /// <returns>矩形</returns>
#else
        /// <summary>
        /// Calculates up-right bounding rectangle of point set.
        /// </summary>
        /// <param name="points">Either a 2D point set, represented as a sequence (CvSeq, CvContour) or vector (CvMat) of points,
        /// or 8-bit single-channel mask image (CvMat, IplImage), in which non-zero pixels are considered. </param>
        /// <param name="update">The update flag</param>
        /// <returns></returns>
#endif
        public static CvRect BoundingRect(CvArr points, bool update)
        {
            if (points == null)
            {
                throw new ArgumentNullException("points");
            }
            return(NativeMethods.cvBoundingRect(points.CvPtr, update));
        }
Example #12
0
        /// <summary>
        /// 次元あるいは2次元浮動小数点型配列の順方向・逆方向離散コサイン変換を行う
        /// </summary>
        /// <param name="src">入力配列(実数の1次元あるいは2次元配列)</param>
        /// <param name="dst">入力と同じサイズ・タイプの出力配列</param>
        /// <param name="flags">変換フラグ</param>
#else
        /// <summary>
        /// Performs forward or inverse Discrete Cosine transform of 1D or 2D floating-point array
        /// </summary>
        /// <param name="src">Source array, real 1D or 2D array. </param>
        /// <param name="dst">Destination array of the same size and same type as the source. </param>
        /// <param name="flags">Transformation flags.</param>
#endif
        public static void DCT(CvArr src, CvArr dst, DCTFlag flags)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            NativeMethods.cvDCT(src.CvPtr, dst.CvPtr, flags);
        }
Example #13
0
        /// <summary>
        /// 輪郭の周囲長または曲線の長さを計算する
        /// </summary>
        /// <param name="curve">配列</param>
        /// <param name="slice">曲線の始点と終点.デフォルトでは曲線の全ての長さが計算される.</param>
        /// <param name="isClosed">閉曲線かどうかを示す.次の3つの状態がある:
        /// is_closed=0 - 曲線は閉曲線として扱われない.
        /// is_closed&gt;0 - 曲線は閉曲線として扱われる.
        /// is_closed&lt;0 - 曲線がシーケンスの場合, ((CvSeq*)curve)-&gt;flagsのフラグCV_SEQ_FLAG_CLOSEDから閉曲線かどうかを判別する.そうでない(曲線が点の配列(CvMat*)で表現される)場合,閉曲線として扱われない.
        /// </param>
        /// <returns>輪郭の周囲長または曲線の長さ</returns>
#else
        /// <summary>
        /// Calculates contour perimeter or curve length
        /// </summary>
        /// <param name="curve">Sequence or array of the curve points. </param>
        /// <param name="slice">Starting and ending points of the curve, by default the whole curve length is calculated. </param>
        /// <param name="isClosed">Indicates whether the curve is closed or not. There are 3 cases:
        /// * is_closed=0 - the curve is assumed to be unclosed.
        /// * is_closed&gt;0 - the curve is assumed to be closed.
        /// * is_closed&lt;0 - if curve is sequence, the flag CV_SEQ_FLAG_CLOSED of ((CvSeq*)curve)-&gt;flags is checked to determine if the curve is closed or not, otherwise (curve is represented by array (CvMat*) of points) it is assumed to be unclosed. </param>
        /// <returns></returns>
#endif
        public static double ArcLength(CvArr curve, CvSlice slice, int isClosed)
        {
            if (curve == null)
            {
                throw new ArgumentNullException("curve");
            }
            return(NativeMethods.cvArcLength(curve.CvPtr, slice, isClosed));
        }
Example #14
0
 /// <summary>
 /// Construct by cvInitTreeNodeIterator
 /// </summary>
 /// <param name="first"></param>
 /// <param name="max_level"></param>
 public CvTreeNodeIterator(CvArr first, int max_level)
 {
     if (first == null)
     {
         throw new ArgumentNullException("first");
     }
     NativeMethods.cvInitTreeNodeIterator(this, first.CvPtr, max_level);
 }
Example #15
0
        /// <summary>
        /// cvMomentsにより初期化
        /// </summary>
        /// <param name="arr">画像(1チャンネル,あるいはCOIをもつ3チャンネル画像) あるいはポリゴン (CvSeqで表される点群,または点のベクトル).</param>
        /// <param name="binary">(画像の場合のみ)このフラグがtrueの場合,値0のピクセルは0として,その他のピクセル値は1として扱われる. </param>
#else
        /// <summary>
        /// Initialize by cvMoments
        /// </summary>
        /// <param name="arr">Image (1-channel or 3-channel with COI set) or polygon (CvSeq of points or a vector of points). </param>
        /// <param name="binary">(For images only) If the flag is non-zero, all the zero pixel values are treated as zeroes, all the others are treated as 1’s. </param>
#endif
        public CvMoments(CvArr arr, bool binary)
        {
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }
            CvInvoke.cvMoments(arr.CvPtr, this, binary);
        }
Example #16
0
        /// <summary>
        /// 指定したウィンドウ内に画像を表示する(cvShowImage相当).
        /// このウィンドウのフラグに AutoSize が指定されていた場合は,画像はオリジナルサイズで表示される.
        /// それ以外の場合,ウィンドウサイズに合わせて 表示画像サイズが変更される.
        /// </summary>
        /// <param name="img">画像ヘッダ</param>
#else
        /// <summary>
        /// Shows the image in this window
        /// </summary>
        /// <param name="img">Image to be shown. </param>
#endif
        public void ShowImage(CvArr img)
        {
            if (img != null)
            {
                image = img;
                NativeMethods.cvShowImage(name, img.CvPtr);
            }
        }
Example #17
0
        /// <summary>
        /// 次元あるいは2次元浮動小数点型配列の順方向・逆方向離散コサイン変換を行う
        /// </summary>
        /// <param name="src">入力配列(実数の1次元あるいは2次元配列)</param>
        /// <param name="dst">入力と同じサイズ・タイプの出力配列</param>
        /// <param name="flags">変換フラグ</param>
#else
        /// <summary>
        /// Performs forward or inverse Discrete Cosine transform of 1D or 2D floating-point array
        /// </summary>
        /// <param name="src">Source array, real 1D or 2D array. </param>
        /// <param name="dst">Destination array of the same size and same type as the source. </param>
        /// <param name="flags">Transformation flags.</param>
#endif
        public static void DCT(CvArr src, CvArr dst, DCTFlag flags)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            NativeMethods.cvDCT(src.CvPtr, dst.CvPtr, flags);
        }
Example #18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="disparity"></param>
        /// <param name="cost"></param>
        /// <param name="minDisparity"></param>
        /// <param name="numberOfDisparities"></param>
        /// <param name="disp12MaxDiff"></param>
#else
        /// <summary>
        /// 
        /// </summary>
        /// <param name="disparity"></param>
        /// <param name="cost"></param>
        /// <param name="minDisparity"></param>
        /// <param name="numberOfDisparities"></param>
        /// <param name="disp12MaxDiff"></param>
#endif
        public static void ValidateDisparity(CvArr disparity, CvArr cost, int minDisparity, int numberOfDisparities, int disp12MaxDiff)
        {
            if (disparity == null)
                throw new ArgumentNullException("disparity");
            if (cost == null)
                throw new ArgumentNullException("cost");
            NativeMethods.cvValidateDisparity(disparity.CvPtr, cost.CvPtr, minDisparity, numberOfDisparities, disp12MaxDiff);
        }
Example #19
0
        /// <summary>
        /// 行列式を返す
        /// </summary>
        /// <param name="mat">入力行列</param>
        /// <returns>行列式</returns>
#else
        /// <summary>
        /// Returns determinant of matrix
        /// </summary>
        /// <param name="mat">The source matrix. </param>
        /// <returns>determinant of the square matrix mat</returns>
#endif
        public static double Det(CvArr mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            return NativeMethods.cvDet(mat.CvPtr);
        }
Example #20
0
        /// <summary>
        /// 行列のトレース(対角成分の和)を返す
        /// </summary>
        /// <param name="mat">入力行列</param>
        /// <returns>対角成分の和</returns>
#else
        /// <summary>
        /// Returns trace of matrix
        /// </summary>
        /// <param name="mat">The source matrix. </param>
        /// <returns>sum of diagonal elements of the matrix src1</returns>
#endif
        public static CvScalar Trace(CvArr mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }
            return(NativeMethods.cvTrace(mat.CvPtr));
        }
Example #21
0
        /// <summary>
        /// cvMomentsにより初期化
        /// </summary>
        /// <param name="arr">画像(1チャンネル,あるいはCOIをもつ3チャンネル画像) あるいはポリゴン (CvSeqで表される点群,または点のベクトル).</param>
        /// <param name="binary">(画像の場合のみ)このフラグがtrueの場合,値0のピクセルは0として,その他のピクセル値は1として扱われる. </param>
#else
        /// <summary>
        /// Initialize by cvMoments
        /// </summary>
        /// <param name="arr">Image (1-channel or 3-channel with COI set) or polygon (CvSeq of points or a vector of points). </param>
        /// <param name="binary">(For images only) If the flag is non-zero, all the zero pixel values are treated as zeroes, all the others are treated as 1’s. </param>
#endif
        public CvMoments(CvArr arr, bool binary)
        {
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }
            NativeMethods.cvMoments(arr.CvPtr, this, binary);
        }
Example #22
0
        /// <summary>
        /// 配列の要素と定数との差の絶対値を計算する. 
        /// dst(I) = abs(src(I) - value).
        /// </summary>
        /// <param name="src">1番目の入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="value">スカラー</param>
#else
        /// <summary>
        /// Calculates absolute difference between array and scalar
        /// </summary>
        /// <param name="src">The source array. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="value">The scalar. </param>
#endif
        public static void AbsDiffS(CvArr src, CvArr dst, CvScalar value)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            NativeMethods.cvAbsDiffS(src.CvPtr, dst.CvPtr, value);
        }
Example #23
0
 /// <summary>
 /// Initializes line iterator
 /// </summary>
 /// <param name="image">Image to sample the line from.  </param>
 /// <param name="pt1">First ending point of the line segment. </param>
 /// <param name="pt2">Second ending point of the line segment. </param>
 /// <param name="connectivity">The scanned line connectivity, 4 or 8. </param>
 /// <param name="leftToRight">The flag, indicating whether the line should be always scanned from the left-most point to the right-most out of pt1 and pt2 (leftToRight=true), or it is scanned in the specified order, from pt1 to pt2 (leftToRight=false). </param>
 /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns>
 private void Initialize(CvArr image, CvPoint pt1, CvPoint pt2, PixelConnectivity connectivity, bool leftToRight)
 {
     this.image        = image;
     this.pt1          = pt1;
     this.pt2          = pt2;
     this.connectivity = connectivity;
     this.leftToRight  = leftToRight;
     this.count        = NativeMethods.cvInitLineIterator(image.CvPtr, pt1, pt2, this.CvPtr, connectivity, leftToRight);
 }
Example #24
0
        /// <summary>
        /// 二つの配列の要素同士を除算する.
        /// dst(I)=scale*src1(I)/src2(I) [src1!=nullの場合],  
        /// dst(I)=scale/src2(I) [src1=nullの場合]
        /// </summary>
        /// <param name="src1">1番目の入力配列. nullの場合は,すべての要素が 1であると仮定する.</param>
        /// <param name="src2">2番目の入力配列</param>
        /// <param name="dst">出力配列</param>
        /// <param name="scale">任意のスケーリング係数</param>
#else
        /// <summary>
        /// Performs per-element division of two arrays
        /// </summary>
        /// <param name="src1">The first source array. If the pointer is NULL, the array is assumed to be all 1’s. </param>
        /// <param name="src2">The second source array. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="scale">Optional scale factor </param>
#endif
        public static void Div(CvArr src1, CvArr src2, CvArr dst, double scale)
        {
            IntPtr src1Ptr = (src1 == null) ? IntPtr.Zero : src1.CvPtr;
            if (src2 == null)
                throw new ArgumentNullException("src2");
            if (dst == null)
                throw new ArgumentNullException("dst");
            NativeMethods.cvDiv(src1Ptr, src2.CvPtr, dst.CvPtr, scale);
        }
Example #25
0
        /// <summary>
        /// 配列の各要素とスカラーとのビット単位の論理和(OR)を計算する. 
        /// 実際の計算の前に,スカラーは配列と同じタイプに変換される.浮動小数点型配列の場合,それらのビット表現が処理に使われる.
        /// dst(I)=src(I)|value [mask(I)!=0の場合]
        /// </summary>
        /// <param name="src1">入力配列</param>
        /// <param name="value">処理に用いるスカラー</param>
        /// <param name="dst">出力配列</param>
        /// <param name="mask">処理マスク.8ビットシングルチャンネル配列(出力配列のどの要素が変更されるかを指定する).</param>
#else
        /// <summary>
        /// Calculates per-element bit-wise disjunction of array and scalar
        /// </summary>
        /// <param name="src1">The source array. </param>
        /// <param name="value">Scalar to use in the operation. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="mask">Operation mask, 8-bit single channel array; specifies elements of destination array to be changed. </param>
#endif
        public static void OrS(CvArr src1, CvScalar value, CvArr dst, CvArr mask)
        {
            if (src1 == null)
                throw new ArgumentNullException("src1");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;
            NativeMethods.cvOrS(src1.CvPtr, value, dst.CvPtr, maskPtr);
        }
Example #26
0
        /// <summary>
        /// ラインイテレータを初期化する
        /// </summary>
        /// <param name="image">対象画像</param>
        /// <param name="pt1">線分の一つ目の端点</param>
        /// <param name="pt2">線分のニつ目の端点</param>
        /// <param name="connectivity">走査した線分の接続性.4または8</param>
        /// <param name="left_to_right">pt1とpt2とは無関係に線分をいつも左から右に走査する(true)か, pt1からpt2への決まった方向で走査するか(false)を指定するフラグ. </param>
        /// <returns></returns>
#else
        /// <summary>
        /// Initializes line iterator
        /// </summary>
        /// <param name="image">Image to sample the line from.  </param>
        /// <param name="pt1">First ending point of the line segment. </param>
        /// <param name="pt2">Second ending point of the line segment. </param>
        /// <param name="connectivity">The scanned line connectivity, 4 or 8. </param>
        /// <param name="left_to_right">The flag, indicating whether the line should be always scanned from the left-most point to the right-most out of pt1 and pt2 (left_to_right=true), or it is scanned in the specified order, from pt1 to pt2 (left_to_right=false). </param>
        /// <returns>The function cvInitLineIterator initializes the line iterator and returns the number of pixels between two end points. Both points must be inside the image. After the iterator has been initialized, all the points on the raster line that connects the two ending points may be retrieved by successive calls of NextLinePoint point. The points on the line are calculated one by one using 4-connected or 8-connected Bresenham algorithm.</returns>
#endif
        public CvLineIterator(CvArr image, CvPoint pt1, CvPoint pt2, PixelConnectivity connectivity, bool left_to_right)
            : this()
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }
            Initialize(image, pt1, pt2, connectivity, left_to_right);
        }
Example #27
0
        /// <summary>
        /// 入力画像中の値が0でないピクセルから,最も近い値が0のピクセルまでの距離を計算する
        /// </summary>
        /// <param name="src">入力画像(8ビット,シングルチャンネル,2値画像)</param>
        /// <param name="dst">距離計算結果をピクセル値として持つ出力画像 (32ビット浮動小数点型,シングルチャンネル)</param>
        /// <param name="distanceType">距離の種類.L1, L2, C か User</param>
        /// <param name="maskSize">距離変換マスクのサイズで,3,5,0 のいずれか. L1,C の場合,このパラメータ値は3に固定される.mask_size==0の場合,距離計算に別の近似無しアルゴリズムが用いられる.</param>
        /// <param name="mask">ユーザ定義の距離の場合はユーザ定義のマスク.3×3のマスクを用いる場合は2つの値(上下シフト値,斜めシフト値)を指定,5×5のマスクを用いる場合は3つの値(上下シフト値,斜めシフト値,ナイト移動シフト値(桂馬飛びのシフト値))を指定する.</param>
        /// <param name="labels">オプション出力.整数ラベルに変換された2次元配列で,src ,dstと同じサイズ.現在は mask_size==3 あるいは 5 のときのみに使用される.</param>
        /// <param name="labelType"></param>
#else
        /// <summary>
        /// Calculates distance to closest zero pixel for all non-zero pixels of source image.
        /// </summary>
        /// <param name="src">Source 8-bit single-channel (binary) image. </param>
        /// <param name="dst">Output image with calculated distances (32-bit floating-point, single-channel). </param>
        /// <param name="distanceType">Type of distance. </param>
        /// <param name="maskSize">Size of distance transform mask; can be 3, 5 or 0. In case of CV_DIST_L1 or CV_DIST_C the parameter is forced to 3, because 3×3 mask gives the same result as 5x5 yet it is faster. When mask_size==0, a different non-approximate algorithm is used to calculate distances. </param>
        /// <param name="mask">User-defined mask in case of user-defined distance, it consists of 2 numbers (horizontal/vertical shift cost, diagonal shift cost) in case of 3x3 mask and 3 numbers (horizontal/vertical shift cost, diagonal shift cost, knight’s move cost) in case of 5x5 mask. </param>
        /// <param name="labels">The optional output 2d array of labels of integer type and the same size as src and dst, can now be used only with mask_size==3 or 5. </param>
        /// <param name="labelType"></param>
#endif
        public static void DistTransform(CvArr src, CvArr dst, DistanceType distanceType, int maskSize, float[] mask, CvArr labels, DistTransformLabelType labelType)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr labelsPtr = (labels == null) ? IntPtr.Zero : labels.CvPtr;
            NativeMethods.cvDistTransform(src.CvPtr, dst.CvPtr, distanceType, maskSize, mask, labelsPtr, labelType);
        }
Example #28
0
        /// <summary>
        /// 隣接ピクセルの形状を決定する指定された構造要素を用いて,入力画像を膨張する. 
        /// この関数はインプレースモード(src=dstである入力)をサポートする.膨張は複数回 (iterations) 繰り返すことができる.
        /// カラー画像の場合は,それぞれのチャンネルが独立に処理される. 
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="element">膨張に用いる構造要素.nullの場合は, 3×3 の矩形形状の構造要素を用いる.</param>
        /// <param name="iterations">膨張の回数</param>
#else
        /// <summary>
        /// Dilates image by using arbitrary structuring element.
        /// </summary>
        /// <param name="src">Source image.</param>
        /// <param name="dst">Destination image. </param>
        /// <param name="element">Structuring element used for erosion. If it is null, a 3x3 rectangular structuring element is used. </param>
        /// <param name="iterations">Number of times erosion is applied. </param>
#endif
        public static void Dilate(CvArr src, CvArr dst, IplConvKernel element, int iterations)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr elemPtr = (element == null) ? IntPtr.Zero : element.CvPtr;
            NativeMethods.cvDilate(src.CvPtr, dst.CvPtr, elemPtr, iterations);
        }
Example #29
0
        /// <summary>
        /// 配列要素の平均値を各チャンネルで独立に計算する.
        /// </summary>
        /// <param name="arr">配列</param>
        /// <param name="mask">オプションの処理マスク</param>
        /// <returns>平均値</returns>
#else
        /// <summary>
        /// Calculates average (mean) of array elements
        /// </summary>
        /// <param name="arr">The array. </param>
        /// <param name="mask">The optional operation mask. </param>
        /// <returns></returns>
#endif
        public static CvScalar Avg(CvArr arr, CvArr mask)
        {
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;

            return(NativeMethods.cvAvg(arr.CvPtr, maskPtr));
        }
Example #30
0
        /// <summary>
        /// Corrects gamma
        /// </summary>
        /// <param name="src"></param>
        /// <param name="dst"></param>
        /// <param name="gamma"></param>
        public void CorrectGamma(CvArr src, CvArr dst, double gamma)
        {
            byte[] lut = new byte[256];
            for (int i = 0; i < lut.Length; i++)
            {
                lut[i] = (byte)(Math.Pow(i / 255.0, 1.0 / gamma) * 255.0);
            }

            Cv.LUT(src, dst, lut);
        }
Example #31
0
        /// <summary>
        /// 二つの配列の要素ごとの差の絶対値を計算する.
        /// dst(I) = abs(src1(I) - src2(I)).
        /// </summary>
        /// <param name="src1">1番目の入力画像</param>
        /// <param name="src2">2番目の入力画像</param>
        /// <param name="dst">出力画像</param>
#else
        /// <summary>
        /// Calculates absolute difference between two arrays
        /// </summary>
        /// <param name="src1">The first source array. </param>
        /// <param name="src2">The second source array. </param>
        /// <param name="dst">The destination array. </param>
#endif
        public static void AbsDiff(CvArr src1, CvArr src2, CvArr dst)
        {
            if (src1 == null)
                throw new ArgumentNullException("src1");
            if (src2 == null)
                throw new ArgumentNullException("src2");
            if (dst == null)
                throw new ArgumentNullException("dst");
            NativeMethods.cvAbsDiff(src1.CvPtr, src2.CvPtr, dst.CvPtr);
        }
Example #32
0
        /// <summary>
        /// 配列の絶対値ノルム(absolute array norm),絶対値差分ノルム(absolute difference norm),相対値差分ノルム(relative difference norm)を計算する
        /// </summary>
        /// <param name="arr1">1番目の入力画像</param>
        /// <param name="arr2">2番目の入力画像.null の場合,arr1の絶対値ノルムが計算され,そうでない場合は,arr1-arr2 の絶対値あるいは相対値ノルムが計算される. </param>
        /// <param name="normType">ノルムのタイプ</param>
        /// <param name="mask">オプションの処理マスク</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Calculates absolute array norm, absolute difference norm or relative difference norm
        /// </summary>
        /// <param name="arr1">The first source image. </param>
        /// <param name="arr2">The second source image. If it is null, the absolute norm of arr1 is calculated, otherwise absolute or relative norm of arr1-arr2 is calculated. </param>
        /// <param name="normType">Type of norm</param>
        /// <param name="mask">The optional operation mask. </param>
        /// <returns></returns>
#endif
        public static double Norm(CvArr arr1, CvArr arr2, NormType normType, CvArr mask)
        {
            if (arr1 == null)
            {
                throw new ArgumentNullException("arr1");
            }
            IntPtr arr2Ptr = (arr2 == null) ? IntPtr.Zero : arr2.CvPtr;
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;

            return(NativeMethods.cvNorm(arr1.CvPtr, arr2Ptr, normType, maskPtr));
        }
Example #33
0
        /// <summary>
        /// 投影係数から元のベクトルを再構築する
        /// </summary>
        /// <param name="proj">入力データ.</param>
        /// <param name="avg">平均ベクトル.もし単一行ベクトルの場合,出力ベクトルがresultの行として保存されていることを意味する.そうでない場合は,単一列ベクトルであり,そのときはresultの列として保存される.</param>
        /// <param name="eigenvects">固有ベクトル(主成分).一つの行が一つのベクトルを意味する.</param>
        /// <param name="result">出力である再構築されたベクトルの行列.</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Reconstructs the original vectors from the projection coefficients
        /// </summary>
        /// <param name="proj">The input data; in the same format as result in cvProjectPCA. </param>
        /// <param name="avg">The mean (average) vector. If it is a single-row vector, it means that the output vectors are stored as rows of result; otherwise, it should be a single-column vector, then the vectors are stored as columns of result. </param>
        /// <param name="eigenvects">The eigenvectors (principal components); one vector per row. </param>
        /// <param name="result">The output matrix of reconstructed vectors. </param>
        /// <returns></returns>
#endif
        public static void BackProjectPCA(CvArr proj, CvArr avg, CvArr eigenvects, CvArr result)
        {
            if (proj == null)
                throw new ArgumentNullException("proj");
            if (avg == null)
                throw new ArgumentNullException("avg");
            if (eigenvects == null)
                throw new ArgumentNullException("eigenvects");
            
            NativeMethods.cvBackProjectPCA(proj.CvPtr, avg.CvPtr, eigenvects.CvPtr, result.CvPtr);
        }
Example #34
0
        /// <summary>
        /// 行列式を返す
        /// </summary>
        /// <param name="mat">入力行列</param>
        /// <returns>行列式</returns>
#else
        /// <summary>
        /// Returns determinant of matrix
        /// </summary>
        /// <param name="mat">The source matrix. </param>
        /// <returns>determinant of the square matrix mat</returns>
#endif
        public static double Det(CvArr mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException(nameof(mat));
            }
            var ret = NativeMethods.cvDet(mat.CvPtr);

            GC.KeepAlive(mat);
            return(ret);
        }
Example #35
0
        /// <summary>
        /// 二つの配列の要素ごとの排他的論理和(XOR)を計算する. 
        /// dst(I)=src1(I)^src2(I) [mask(I)!=0の場合]
        /// </summary>
        /// <param name="src1">1番目の入力配列</param>
        /// <param name="src2">2番目の入力配列</param>
        /// <param name="dst">出力配列</param>
        /// <param name="mask">処理マスク.8ビットシングルチャンネル配列(出力配列のどの要素が変更されるかを指定する). </param>
#else
        /// <summary>
        /// Performs per-element bit-wise "exclusive or" operation on two arrays
        /// </summary>
        /// <param name="src1">The first source array. </param>
        /// <param name="src2">The second source array. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="mask">Operation mask, 8-bit single channel array; specifies elements of destination array to be changed. </param>
#endif
        public static void Xor(CvArr src1, CvArr src2, CvArr dst, CvArr mask)
        {
            if (src1 == null)
                throw new ArgumentNullException("src1");
            if (src2 == null)
                throw new ArgumentNullException("src2");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;
            CvInvoke.cvXor(src1.CvPtr, src2.CvPtr, dst.CvPtr, maskPtr);
        }
Example #36
0
        /// <summary>
        /// 配列要素の平均値を各チャンネルで独立に計算する.
        /// </summary>
        /// <param name="arr">配列</param>
        /// <param name="mask">オプションの処理マスク</param>
        /// <returns>平均値</returns>
#else
        /// <summary>
        /// Calculates average (mean) of array elements
        /// </summary>
        /// <param name="arr">The array. </param>
        /// <param name="mask">The optional operation mask. </param>
        /// <returns></returns>
#endif
        public static CvScalar Avg(CvArr arr, CvArr mask)
        {
            if (arr == null)
            {
                throw new ArgumentNullException(nameof(arr));
            }
            var ret = NativeMethods.cvAvg(arr.CvPtr, ToPtr(mask));

            KeepAlive(arr, mask);
            return(ret);
        }
Example #37
0
        /// <summary>
        /// 行列のトレース(対角成分の和)を返す
        /// </summary>
        /// <param name="mat">入力行列</param>
        /// <returns>対角成分の和</returns>
#else
        /// <summary>
        /// Returns trace of matrix
        /// </summary>
        /// <param name="mat">The source matrix. </param>
        /// <returns>sum of diagonal elements of the matrix src1</returns>
#endif
        public static CvScalar Trace(CvArr mat)
        {
            if (mat == null)
            {
                throw new ArgumentNullException("mat");
            }

            var ret = NativeMethods.cvTrace(mat.CvPtr);

            GC.KeepAlive(mat);
            return(ret);
        }
Example #38
0
        /// <summary>
        /// 配列要素の平均と標準偏差を各チャンネルで独立に計算する.
        /// </summary>
        /// <param name="arr">配列</param>
        /// <param name="mean">計算結果の平均値の出力</param>
        /// <param name="stdDev">計算結果の標準偏差の出力</param>
        /// <param name="mask">オプションの処理マスク</param>
#else
        /// <summary>
        /// Calculates average (mean) of array elements
        /// </summary>
        /// <param name="arr">The array. </param>
        /// <param name="mean">Pointer to the mean value, may be null if it is not needed. </param>
        /// <param name="stdDev">Pointer to the standard deviation. </param>
        /// <param name="mask">The optional operation mask. </param>
#endif
        public static void AvgSdv(CvArr arr, out CvScalar mean, out CvScalar stdDev, CvArr mask)
        {
            if (arr == null)
            {
                throw new ArgumentNullException("arr");
            }
            mean   = new CvScalar();
            stdDev = new CvScalar();
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;

            NativeMethods.cvAvgSdv(arr.CvPtr, ref mean, ref stdDev, maskPtr);
        }
Example #39
0
        /// <summary>
        /// 輪郭の周囲長または曲線の長さを計算する
        /// </summary>
        /// <param name="curve">配列</param>
        /// <param name="slice">曲線の始点と終点.デフォルトでは曲線の全ての長さが計算される.</param>
        /// <param name="isClosed">閉曲線かどうかを示す.次の3つの状態がある:
        /// is_closed=0 - 曲線は閉曲線として扱われない.
        /// is_closed&gt;0 - 曲線は閉曲線として扱われる.
        /// is_closed&lt;0 - 曲線がシーケンスの場合, ((CvSeq*)curve)-&gt;flagsのフラグCV_SEQ_FLAG_CLOSEDから閉曲線かどうかを判別する.そうでない(曲線が点の配列(CvMat*)で表現される)場合,閉曲線として扱われない.
        /// </param>
        /// <returns>輪郭の周囲長または曲線の長さ</returns>
#else
        /// <summary>
        /// Calculates contour perimeter or curve length
        /// </summary>
        /// <param name="curve">Sequence or array of the curve points. </param>
        /// <param name="slice">Starting and ending points of the curve, by default the whole curve length is calculated. </param>
        /// <param name="isClosed">Indicates whether the curve is closed or not. There are 3 cases:
        /// * is_closed=0 - the curve is assumed to be unclosed.
        /// * is_closed&gt;0 - the curve is assumed to be closed.
        /// * is_closed&lt;0 - if curve is sequence, the flag CV_SEQ_FLAG_CLOSED of ((CvSeq*)curve)-&gt;flags is checked to determine if the curve is closed or not, otherwise (curve is represented by array (CvMat*) of points) it is assumed to be unclosed. </param>
        /// <returns></returns>
#endif
        public static double ArcLength(CvArr curve, CvSlice slice, int isClosed)
        {
            if (curve == null)
            {
                throw new ArgumentNullException(nameof(curve));
            }

            double ret = NativeMethods.cvArcLength(curve.CvPtr, slice, isClosed);

            GC.KeepAlive(curve);
            return(ret);
        }
        /// <summary>
        /// 輪郭走査処理の初期化を行う
        /// </summary>
        /// <param name="image">入力画像.8ビットシングルチャンネルの2値化画像. </param>
        /// <param name="storage">抽出された輪郭データの保存領域. </param>
        /// <param name="headerSize">シーケンスヘッダのサイズ. method=CV_CHAIN_CODEの時, >=sizeof(CvChain) ,それ以外の場合 >=sizeof(CvContour). </param>
        /// <param name="mode">抽出モード.</param>
        /// <param name="method">近似手法.cvFindContoursと同様,但し CV_LINK_RUNS は使用不可. </param>
        /// <param name="offset">ROIのオフセット.cvFindContoursを参照. </param>
        /// <returns>輪郭スキャナのポインタ</returns>
#else
        /// <summary>
        /// Initializes contour scanning process
        /// </summary>
        /// <param name="image">The source 8-bit single channel binary image. </param>
        /// <param name="storage">Container of the retrieved contours.</param>
        /// <param name="headerSize">Size of the sequence header, >=sizeof(CvChain) if method=CV_CHAIN_CODE, and >=sizeof(CvContour) otherwise. </param>
        /// <param name="mode">Retrieval mode; see cvFindContours. </param>
        /// <param name="method">Approximation method. It has the same meaning as in cvFindContours, but CV_LINK_RUNS can not be used here. </param>
        /// <param name="offset">ROI offset; see cvFindContours. </param>
        /// <returns>CvContourScanner</returns>
#endif
        public CvContourScanner(CvArr image, CvMemStorage storage, int headerSize, ContourRetrieval mode, ContourChain method, CvPoint offset)
        {
            if (image == null)
            {
                throw new ArgumentNullException(nameof(image));
            }
            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }
            Initialize(image, storage, headerSize, mode, method, offset);
        }
Example #41
0
        /// <summary>
        /// 配列の要素と定数との差の絶対値を計算する.
        /// dst(I) = abs(src(I) - value).
        /// </summary>
        /// <param name="src">1番目の入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="value">スカラー</param>
#else
        /// <summary>
        /// Calculates absolute difference between array and scalar
        /// </summary>
        /// <param name="src">The source array. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="value">The scalar. </param>
#endif
        public static void AbsDiffS(CvArr src, CvArr dst, CvScalar value)
        {
            if (src == null)
            {
                throw new ArgumentNullException("src");
            }
            if (dst == null)
            {
                throw new ArgumentNullException("dst");
            }
            NativeMethods.cvAbsDiffS(src.CvPtr, dst.CvPtr, value);
        }
Example #42
0
        /// <summary>
        /// 配列要素の平均と標準偏差を各チャンネルで独立に計算する.
        /// </summary>
        /// <param name="arr">配列</param>
        /// <param name="mean">計算結果の平均値の出力</param>
        /// <param name="stdDev">計算結果の標準偏差の出力</param>
        /// <param name="mask">オプションの処理マスク</param>
#else
        /// <summary>
        /// Calculates average (mean) of array elements
        /// </summary>
        /// <param name="arr">The array. </param>
        /// <param name="mean">Pointer to the mean value, may be null if it is not needed. </param>
        /// <param name="stdDev">Pointer to the standard deviation. </param>
        /// <param name="mask">The optional operation mask. </param>
#endif
        public static void AvgSdv(CvArr arr, out CvScalar mean, out CvScalar stdDev, CvArr mask)
        {
            if (arr == null)
            {
                throw new ArgumentNullException(nameof(arr));
            }

            mean   = new CvScalar();
            stdDev = new CvScalar();
            NativeMethods.cvAvgSdv(arr.CvPtr, ref mean, ref stdDev, ToPtr(mask));
            KeepAlive(arr, mask);
        }
Example #43
0
        /// <summary>
        /// 半径方向や円周方向のレンズ歪みを補正するために画像を変換する.
        /// </summary>
        /// <param name="src">入力画像(歪みあり)</param>
        /// <param name="dst">出力画像(補正済み)</param>
        /// <param name="intrinsicMatrix">カメラ内部行列 (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">歪み係数ベクトル. 4x1 または 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#else
        /// <summary>
        /// Transforms image to compensate lens distortion.
        /// </summary>
        /// <param name="src">The input (distorted) image. </param>
        /// <param name="dst">The output (corrected) image. </param>
        /// <param name="intrinsicMatrix">The camera matrix (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">The vector of distortion coefficients, 4x1 or 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#endif
        public static void Undistort2(CvArr src, CvArr dst, CvMat intrinsicMatrix, CvMat distortionCoeffs, CvMat newCameraMatrix)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (intrinsicMatrix == null)
                throw new ArgumentNullException("intrinsicMatrix");
            if (distortionCoeffs == null)
                throw new ArgumentNullException("distortionCoeffs");

            IntPtr newCameraMatrixPtr = (newCameraMatrix == null) ? IntPtr.Zero : newCameraMatrix.CvPtr;
            NativeMethods.cvUndistort2(src.CvPtr, dst.CvPtr, intrinsicMatrix.CvPtr, distortionCoeffs.CvPtr, newCameraMatrixPtr);
        }
Example #44
0
        /// <summary>
        /// 半径方向や円周方向のレンズ歪みを補正するために画像を変換する.
        /// </summary>
        /// <param name="src">入力画像(歪みあり)</param>
        /// <param name="dst">出力画像(補正済み)</param>
        /// <param name="intrinsic_matrix">カメラ内部行列 (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortion_coeffs">歪み係数ベクトル. 4x1 または 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="new_camera_matrix"></param>
#else
        /// <summary>
        /// Transforms image to compensate lens distortion.
        /// </summary>
        /// <param name="src">The input (distorted) image. </param>
        /// <param name="dst">The output (corrected) image. </param>
        /// <param name="intrinsic_matrix">The camera matrix (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortion_coeffs">The vector of distortion coefficients, 4x1 or 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="new_camera_matrix"></param>
#endif
        public static void Undistort2(CvArr src, CvArr dst, CvMat intrinsic_matrix, CvMat distortion_coeffs, CvMat new_camera_matrix)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (intrinsic_matrix == null)
                throw new ArgumentNullException("intrinsic_matrix");
            if (distortion_coeffs == null)
                throw new ArgumentNullException("distortion_coeffs");

            IntPtr new_camera_matrix_ptr = (new_camera_matrix == null) ? IntPtr.Zero : new_camera_matrix.CvPtr;
            CvInvoke.cvUndistort2(src.CvPtr, dst.CvPtr, intrinsic_matrix.CvPtr, distortion_coeffs.CvPtr, new_camera_matrix_ptr);
        }
Example #45
0
        /// <summary>
        /// 二つの配列の要素ごとの排他的論理和(XOR)を計算する. 
        /// dst(I)=src1(I)^src2(I) [mask(I)!=0の場合]
        /// </summary>
        /// <param name="src1">1番目の入力配列</param>
        /// <param name="src2">2番目の入力配列</param>
        /// <param name="dst">出力配列</param>
        /// <param name="mask">処理マスク.8ビットシングルチャンネル配列(出力配列のどの要素が変更されるかを指定する). </param>
#else
        /// <summary>
        /// Performs per-element bit-wise "exclusive or" operation on two arrays
        /// </summary>
        /// <param name="src1">The first source array. </param>
        /// <param name="src2">The second source array. </param>
        /// <param name="dst">The destination array. </param>
        /// <param name="mask">Operation mask, 8-bit single channel array; specifies elements of destination array to be changed. </param>
#endif
        public static void Xor(CvArr src1, CvArr src2, CvArr dst, CvArr mask)
        {
            if (src1 == null)
                throw new ArgumentNullException("src1");
            if (src2 == null)
                throw new ArgumentNullException("src2");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr maskPtr = (mask == null) ? IntPtr.Zero : mask.CvPtr;
            NativeMethods.cvXor(src1.CvPtr, src2.CvPtr, dst.CvPtr, maskPtr);

            GC.KeepAlive(src1);
            GC.KeepAlive(src2);
            GC.KeepAlive(dst);
            GC.KeepAlive(mask);
        }
Example #46
0
        /// <summary>
        /// 半径方向や円周方向のレンズ歪みを補正するために画像を変換する.
        /// </summary>
        /// <param name="src">入力画像(歪みあり)</param>
        /// <param name="dst">出力画像(補正済み)</param>
        /// <param name="intrinsicMatrix">カメラ内部行列 (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">歪み係数ベクトル. 4x1 または 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#else
        /// <summary>
        /// Transforms image to compensate lens distortion.
        /// </summary>
        /// <param name="src">The input (distorted) image. </param>
        /// <param name="dst">The output (corrected) image. </param>
        /// <param name="intrinsicMatrix">The camera matrix (A) [fx 0 cx; 0 fy cy; 0 0 1]. </param>
        /// <param name="distortionCoeffs">The vector of distortion coefficients, 4x1 or 1x4 [k1, k2, p1, p2]. </param>
        /// <param name="newCameraMatrix"></param>
#endif
        public static void Undistort2(CvArr src, CvArr dst, CvMat intrinsicMatrix, CvMat distortionCoeffs, CvMat newCameraMatrix)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            if (intrinsicMatrix == null)
                throw new ArgumentNullException("intrinsicMatrix");
            if (distortionCoeffs == null)
                throw new ArgumentNullException("distortionCoeffs");

            NativeMethods.cvUndistort2(
                src.CvPtr, dst.CvPtr, intrinsicMatrix.CvPtr, distortionCoeffs.CvPtr, ToPtr(newCameraMatrix));
            
            GC.KeepAlive(src);
            GC.KeepAlive(dst);
            GC.KeepAlive(intrinsicMatrix);
            GC.KeepAlive(distortionCoeffs);
            GC.KeepAlive(newCameraMatrix);
        }
Example #47
0
        /// <summary>
        /// 枠だけの楕円,もしくは塗りつぶされた楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描かれる画像.</param>
        /// <param name="box">描画したい楕円を囲む矩形領域.</param>
        /// <param name="color">楕円の色.</param>
        /// <param name="thickness">楕円境界線の幅.</param>
        /// <param name="line_type">楕円境界線の種類.</param>
        /// <param name="shift">矩形領域の頂点座標の小数点以下の桁を表すビット数.</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="box">The enclosing box of the ellipse drawn </param>
        /// <param name="color">Ellipse color. </param>
        /// <param name="thickness">Thickness of the ellipse boundary. </param>
        /// <param name="line_type">Type of the ellipse boundary</param>
        /// <param name="shift">Number of fractional bits in the box vertex coordinates. </param>
#endif
        public static void EllipseBox(CvArr img, CvBox2D box, CvScalar color, int thickness, LineType line_type, int shift)
        {
            if (img == null)
            {
                throw new ArgumentNullException("img");
            }

            CvSize axes = new CvSize
            {
                Width = (int)Math.Round(box.Size.Height * 0.5),
                Height = (int)Math.Round(box.Size.Width * 0.5)
            };
            Ellipse(img, box.Center, axes, box.Angle, 0, 360, color, thickness, line_type, shift);
        }
Example #48
0
        /// <summary>
        /// すべての配列要素について自然対数の底(ネイピア数)eのべき乗を求める
        /// </summary>
        /// <param name="src">入力配列</param>
        /// <param name="dst">出力配列.倍精度の浮動小数点型(double),または入力配列と同じタイプでなければならない.</param>
#else
        /// <summary>
        /// Calculates exponent of every array element
        /// </summary>
        /// <param name="src">The source array. </param>
        /// <param name="dst">The destination array, it should have double type or the same type as the source. </param>
#endif
        public static void Exp(CvArr src, CvArr dst)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            CvInvoke.cvExp(src.CvPtr, dst.CvPtr);
        }
Example #49
0
        /// <summary>
        /// Estimate rigid transformation between 2 images or 2 point sets
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <param name="M"></param>
        /// <param name="full_affine"></param>
        /// <returns></returns>
#else
        /// <summary>
        /// Estimate rigid transformation between 2 images or 2 point sets
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <param name="M"></param>
        /// <param name="full_affine"></param>
        /// <returns></returns>
#endif
        public static int EstimateRigidTransform(CvArr A, CvArr B, CvMat M, bool full_affine)
        {
            if (A == null)
                throw new ArgumentNullException("A");
            if (B == null)
                throw new ArgumentNullException("B");
            if (M == null)
                throw new ArgumentNullException("M");

            return CvInvoke.cvEstimateRigidTransform(A.CvPtr, B.CvPtr, M.CvPtr, full_affine);
        }
Example #50
0
        /// <summary>
        /// 隣接ピクセルの形状を決定する指定された構造要素を用いて,入力画像を収縮する. 
        /// この関数はインプレースモード(src=dstである入力)をサポートする.収縮は複数回 (iterations) 繰り返すことができる.
        /// カラー画像の場合は,それぞれのチャンネルが独立に処理される. 
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="element">収縮に用いる構造要素.nullの場合は, 3×3 の矩形形状の構造要素を用いる.</param>
        /// <param name="iterations">収縮の回数</param>
#else
        /// <summary>
        /// Erodes image by using arbitrary structuring element.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="element">Structuring element used for erosion. If it is null, a 3x3 rectangular structuring element is used. </param>
        /// <param name="iterations">Number of times erosion is applied. </param>
#endif
        public static void Erode(CvArr src, CvArr dst, IplConvKernel element, int iterations)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr elem_ptr = (element == null) ? IntPtr.Zero : element.CvPtr;
            CvInvoke.cvErode(src.CvPtr, dst.CvPtr, elem_ptr, iterations);
        }
Example #51
0
        /// <summary>
        /// 隣接ピクセルの形状を決定する指定された構造要素を用いて,入力画像を収縮する. 
        /// この関数はインプレースモード(src=dstである入力)をサポートする.収縮は複数回 (iterations) 繰り返すことができる.
        /// カラー画像の場合は,それぞれのチャンネルが独立に処理される. 
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="element">収縮に用いる構造要素.nullの場合は, 3×3 の矩形形状の構造要素を用いる.</param>
#else
        /// <summary>
        /// Erodes image by using arbitrary structuring element.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="element">Structuring element used for erosion. If it is null, a 3x3 rectangular structuring element is used. </param>
#endif
        public static void Erode(CvArr src, CvArr dst, IplConvKernel element)
        {
            Erode(src, dst, element, 1);
        }
Example #52
0
        /// <summary>
        /// 隣接ピクセルの形状を決定する指定された構造要素を用いて,入力画像を収縮する. 
        /// この関数はインプレースモード(src=dstである入力)をサポートする.収縮は複数回 (iterations) 繰り返すことができる.
        /// カラー画像の場合は,それぞれのチャンネルが独立に処理される. 
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
#else
        /// <summary>
        /// Erodes image by using arbitrary structuring element.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
#endif
        public static void Erode(CvArr src, CvArr dst)
        {
            Erode(src, dst, null);
        }
Example #53
0
        /// <summary>
        /// 画像をエンコードしてバイト列として出力する
        /// </summary>
        /// <param name="ext">出力形式として定義されているファイル拡張子</param>
        /// <param name="image">入力画像</param>
        /// <param name="prms">画像フォーマット固有の各種パラメータ</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Encode image and store the result as a byte vector (single-row 8uC1 matrix)
        /// </summary>
        /// <param name="ext">The file extension that defines the output format</param>
        /// <param name="image">The image to be written</param>
        /// <param name="prms">The format-specific parameters</param>
        /// <returns></returns>
#endif
        public static CvMat EncodeImage(string ext, CvArr image, params ImageEncodingParam[] prms)
        {
            List<int> p = new List<int>();
            if (prms != null)
            {
                foreach (ImageEncodingParam item in prms)
                {
                    p.Add((int)item.EncodingID);
                    p.Add(item.Value);
                }
                return EncodeImage(ext, image, p.ToArray());
            }
            else
            {
                return EncodeImage(ext, image, (int[])null);
            }
        }
Example #54
0
        /// <summary>
        /// 枠だけの楕円,もしくは塗りつぶされた楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描かれる画像.</param>
        /// <param name="box">描画したい楕円を囲む矩形領域.</param>
        /// <param name="color">楕円の色.</param>
        /// <param name="thickness">楕円境界線の幅.</param>
        /// <param name="line_type">楕円境界線の種類.</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="box">The enclosing box of the ellipse drawn </param>
        /// <param name="color">Ellipse color. </param>
        /// <param name="thickness">Thickness of the ellipse boundary. </param>
        /// <param name="line_type">Type of the ellipse boundary</param>
#endif
        public static void EllipseBox(CvArr img, CvBox2D box, CvScalar color, int thickness, LineType line_type)
        {
            EllipseBox(img, box, color, thickness, line_type, 0);
        }
Example #55
0
        /// <summary>
        /// 対称行列の固有値と固有ベクトルを計算する
        /// </summary>
        /// <param name="mat">入力対称正方行列.処理中に変更される.</param>
        /// <param name="evects">固有ベクトルの出力行列.連続した行として保存される. </param>
        /// <param name="evals">固有値ベクトルの出力ベクトル.降順に保存される(もちろん固有値と固有ベクトルの順番は一致する).</param>
        /// <param name="eps">対角化の精度(一般的に,DBL_EPSILON=≈10^-15 で十分である)</param>
        /// <param name="lowindex">求める最大の固有値/固有ベクトルのインデックス</param>
        /// <param name="highindex">求める最小の固有値/固有ベクトルのインデックス</param>
#else
        /// <summary>
        /// Computes eigenvalues and eigenvectors of symmetric matrix
        /// </summary>
        /// <param name="mat">The input symmetric square matrix. It is modified during the processing. </param>
        /// <param name="evects">The output matrix of eigenvectors, stored as a subsequent rows. </param>
        /// <param name="evals">The output vector of eigenvalues, stored in the descending order (order of eigenvalues and eigenvectors is synchronized, of course). </param>
        /// <param name="eps">Accuracy of diagonalization (typically, DBL_EPSILON=≈10-15 is enough). </param>
        /// <param name="lowindex">Optional index of largest eigenvalue/-vector to calculate.</param>
        /// <param name="highindex">Optional index of smallest eigenvalue/-vector to calculate.</param>
#endif
        public static void EigenVV(CvArr mat, CvArr evects, CvArr evals, double eps, int lowindex, int highindex)
        {
            if (mat == null)
                throw new ArgumentNullException("mat");
            if (evects == null)
                throw new ArgumentNullException("evects");
            if (evals == null)
                throw new ArgumentNullException("evals");
            CvInvoke.cvEigenVV(mat.CvPtr, evects.CvPtr, evals.CvPtr, eps, lowindex, highindex);
        }
Example #56
0
        /// <summary>
        /// 枠だけの楕円,楕円弧,もしくは塗りつぶされた扇形の楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描画される画像</param>
        /// <param name="center">楕円の中心</param>
        /// <param name="axes">楕円の軸の長さ</param>
        /// <param name="angle">回転角度</param>
        /// <param name="start_angle">楕円弧の開始角度</param>
        /// <param name="end_angle">楕円弧の終了角度</param>
        /// <param name="color">楕円の色</param>
        /// <param name="thickness">楕円弧の線の幅</param>
        /// <param name="line_type">楕円弧の線の種類</param>
        /// <param name="shift">中心座標と軸の長さの小数点以下の桁を表すビット数</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="center">Center of the ellipse. </param>
        /// <param name="axes">Length of the ellipse axes. </param>
        /// <param name="angle">Rotation angle. </param>
        /// <param name="start_angle">Starting angle of the elliptic arc. </param>
        /// <param name="end_angle">Ending angle of the elliptic arc. </param>
        /// <param name="color">Ellipse color. </param>
        /// <param name="thickness">Thickness of the ellipse arc. </param>
        /// <param name="line_type">Type of the ellipse boundary.</param>
        /// <param name="shift">Number of fractional bits in the center coordinates and axes' values. </param>
#endif
        public static void DrawEllipse(CvArr img, CvPoint center, CvSize axes, double angle, double start_angle, double end_angle, CvScalar color, int thickness, LineType line_type, int shift)
        {
            Ellipse(img, center, axes, angle, start_angle, end_angle, color, thickness, line_type, shift);
        }
Example #57
0
        /// <summary>
        /// 枠だけの楕円,楕円弧,もしくは塗りつぶされた扇形の楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描画される画像</param>
        /// <param name="center">楕円の中心</param>
        /// <param name="axes">楕円の軸の長さ</param>
        /// <param name="angle">回転角度</param>
        /// <param name="start_angle">楕円弧の開始角度</param>
        /// <param name="end_angle">楕円弧の終了角度</param>
        /// <param name="color">楕円の色</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="center">Center of the ellipse. </param>
        /// <param name="axes">Length of the ellipse axes. </param>
        /// <param name="angle">Rotation angle. </param>
        /// <param name="start_angle">Starting angle of the elliptic arc. </param>
        /// <param name="end_angle">Ending angle of the elliptic arc. </param>
        /// <param name="color">Ellipse color. </param>
#endif
        public static void DrawEllipse(CvArr img, CvPoint center, CvSize axes, double angle, double start_angle, double end_angle, CvScalar color)
        {
            Ellipse(img, center, axes, angle, start_angle, end_angle, color, 1, LineType.Link8, 0);
        }
Example #58
0
        /// <summary>
        /// 枠だけの楕円,楕円弧,もしくは塗りつぶされた扇形の楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描画される画像</param>
        /// <param name="center">楕円の中心</param>
        /// <param name="axes">楕円の軸の長さ</param>
        /// <param name="angle">回転角度</param>
        /// <param name="start_angle">楕円弧の開始角度</param>
        /// <param name="end_angle">楕円弧の終了角度</param>
        /// <param name="color">楕円の色</param>
        /// <param name="thickness">楕円弧の線の幅</param>
        /// <param name="line_type">楕円弧の線の種類</param>
        /// <param name="shift">中心座標と軸の長さの小数点以下の桁を表すビット数</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="center">Center of the ellipse. </param>
        /// <param name="axes">Length of the ellipse axes. </param>
        /// <param name="angle">Rotation angle. </param>
        /// <param name="start_angle">Starting angle of the elliptic arc. </param>
        /// <param name="end_angle">Ending angle of the elliptic arc. </param>
        /// <param name="color">Ellipse color. </param>
        /// <param name="thickness">Thickness of the ellipse arc. </param>
        /// <param name="line_type">Type of the ellipse boundary.</param>
        /// <param name="shift">Number of fractional bits in the center coordinates and axes' values. </param>
#endif
        public static void Ellipse(CvArr img, CvPoint center, CvSize axes, double angle, double start_angle, double end_angle, CvScalar color, int thickness, LineType line_type, int shift)
        {
            if (img == null)
            {
                throw new ArgumentNullException("img");
            }
            CvInvoke.cvEllipse(img.CvPtr, center, axes, angle, start_angle, end_angle, color, thickness, line_type, shift);
        }
Example #59
0
        /// <summary>
        /// 枠だけの楕円,もしくは塗りつぶされた楕円を描画する
        /// </summary>
        /// <param name="img">楕円が描かれる画像.</param>
        /// <param name="box">描画したい楕円を囲む矩形領域.</param>
        /// <param name="color">楕円の色.</param>
#else
        /// <summary>
        /// Draws simple or thick elliptic arc or fills ellipse sector
        /// </summary>
        /// <param name="img">Image. </param>
        /// <param name="box">The enclosing box of the ellipse drawn </param>
        /// <param name="color">Ellipse color. </param>
#endif
        public static void EllipseBox(CvArr img, CvBox2D box, CvScalar color)
        {
            EllipseBox(img, box, color, 1, LineType.Link8, 0);
        }
Example #60
0
        /// <summary>
        /// 画像をエンコードしてバイト列として出力する
        /// </summary>
        /// <param name="ext">出力形式として定義されているファイル拡張子</param>
        /// <param name="image">入力画像</param>
        /// <param name="prms">画像フォーマット固有の各種パラメータ</param>
        /// <returns></returns>
#else
        /// <summary>
        /// Encode image and store the result as a byte vector (single-row 8uC1 matrix)
        /// </summary>
        /// <param name="ext">The file extension that defines the output format</param>
        /// <param name="image">The image to be written</param>
        /// <param name="prms">The format-specific parameters</param>
        /// <returns></returns>
#endif
        public static CvMat EncodeImage(string ext, CvArr image, int[] prms)
        {
            if (string.IsNullOrEmpty(ext))
                throw new ArgumentNullException("ext");
            if (image == null)
                throw new ArgumentNullException("image");
            IntPtr ptr = CvInvoke.cvEncodeImage(ext, image.CvPtr, prms);
            if (ptr == IntPtr.Zero)
                return null;
            else
                return new CvMat(ptr, true);
        }