Beispiel #1
0
        /// <summary>
        /// 画像のアフィン変換を行う
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="mapMatrix">2×3 変換行列</param>
        /// <param name="flags">補間方法</param>
#else
        /// <summary>
        /// Applies affine transformation to the image.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="mapMatrix">2x3 transformation matrix. </param>
        /// <param name="flags">A combination of interpolation method and the optional flags.</param>
#endif
        public static void WarpAffine(CvArr src, CvArr dst, CvMat mapMatrix, Interpolation flags)
        {
            WarpAffine(src, dst, mapMatrix, flags, CvScalar.ScalarAll(0));
        }
Beispiel #2
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>
#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>
#endif
        public static void DrawContours(CvArr img, CvSeq<CvPoint> contour, CvScalar externalColor, CvScalar holeColor, int maxLevel)
        {
            DrawContours(img, contour, externalColor, holeColor, maxLevel, 1, LineType.Link8, new CvPoint(0, 0));
        }
Beispiel #3
0
        /// <summary>
        /// 画像の透視変換を行う.
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="mapMatrix">3×3 の変換行列</param>
        /// <param name="flags">補間方法</param>
        /// <param name="fillval">対応の取れない点に対して与える値</param>
#else
        /// <summary>
        /// Applies perspective transformation to the image.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="mapMatrix">3x3 transformation matrix. </param>
        /// <param name="flags">A combination of interpolation method and the optional flags.</param>
        /// <param name="fillval">A value used to fill outliers. </param>
#endif
        public static void WarpPerspective(CvArr src, CvArr dst, CvMat mapMatrix, Interpolation flags, CvScalar fillval)
        {
            if (src == null)
            {
                throw new ArgumentNullException("src");
            }
            if (dst == null)
            {
                throw new ArgumentNullException("dst");
            }
            if (mapMatrix == null)
            {
                throw new ArgumentNullException("mapMatrix");
            }
            NativeMethods.cvWarpPerspective(src.CvPtr, dst.CvPtr, mapMatrix.CvPtr, flags, fillval);

            GC.KeepAlive(src);
            GC.KeepAlive(dst);
            GC.KeepAlive(mapMatrix);
        }
Beispiel #4
0
        /// <summary>
        /// 画像のアフィン変換を行う
        /// </summary>
        /// <param name="src">入力画像</param>
        /// <param name="dst">出力画像</param>
        /// <param name="mapMatrix">2×3 変換行列</param>
#else
        /// <summary>
        /// Applies affine transformation to the image.
        /// </summary>
        /// <param name="src">Source image. </param>
        /// <param name="dst">Destination image. </param>
        /// <param name="mapMatrix">2x3 transformation matrix. </param>
#endif
        public static void WarpAffine(CvArr src, CvArr dst, CvMat mapMatrix)
        {
            WarpAffine(src, dst, mapMatrix, Interpolation.Linear | Interpolation.FillOutliers, CvScalar.ScalarAll(0));
        }
Beispiel #5
0
        public void DrawMarker(int x, int y, CvScalar color, MarkerStyle style, int size, LineType lineType, int thickness)
        {
            int r = size / 2;

            switch (style)
            {
            case MarkerStyle.CircleLine:
                Circle(x, y, r, color, thickness, lineType);
                break;

            case MarkerStyle.CircleFilled:
                Circle(x, y, r, color, -1, lineType);
                break;

            case MarkerStyle.Cross:
                Line(x, y - r, x, y + r, color, thickness, lineType);
                Line(x - r, y, x + r, y, color, thickness, lineType);
                break;

            case MarkerStyle.TiltedCross:
                Line(x - r, y - r, x + r, y + r, color, thickness, lineType);
                Line(x + r, y - r, x - r, y + r, color, thickness, lineType);
                break;

            case MarkerStyle.CircleAndCross:
                Circle(x, y, r, color, thickness, lineType);
                Line(x, y - r, x, y + r, color, thickness, lineType);
                Line(x - r, y, x + r, y, color, thickness, lineType);
                break;

            case MarkerStyle.CircleAndTiltedCross:
                Circle(x, y, r, color, thickness, lineType);
                Line(x - r, y - r, x + r, y + r, color, thickness, lineType);
                Line(x + r, y - r, x - r, y + r, color, thickness, lineType);
                break;

            case MarkerStyle.DiamondLine:
            case MarkerStyle.DiamondFilled:
            {
                int       r2  = (int)(size * Math.Sqrt(2) / 2.0);
                CvPoint[] pts = new CvPoint[]
                {
                    new CvPoint(x, y - r2),
                    new CvPoint(x + r2, y),
                    new CvPoint(x, y + r2),
                    new CvPoint(x - r2, y),
                };
                switch (style)
                {
                case MarkerStyle.DiamondLine:
                    PolyLine(new CvPoint[][] { pts }, true, color, thickness, lineType); break;

                case MarkerStyle.DiamondFilled:
                    FillConvexPoly(pts, color, lineType); break;
                }
            }
            break;

            case MarkerStyle.SquareLine:
            case MarkerStyle.SquareFilled:
            {
                CvPoint[] pts = new CvPoint[]
                {
                    new CvPoint(x - r, y - r),
                    new CvPoint(x + r, y - r),
                    new CvPoint(x + r, y + r),
                    new CvPoint(x - r, y + r),
                };
                switch (style)
                {
                case MarkerStyle.SquareLine:
                    PolyLine(new CvPoint[][] { pts }, true, color, thickness, lineType); break;

                case MarkerStyle.SquareFilled:
                    FillConvexPoly(pts, color, lineType); break;
                }
            }
            break;

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #6
0
        /// <summary>
        /// 配列の各要素とスカラーとのビット単位の排他的論理和(XOR)を計算する.
        /// 実際の計算の前に,スカラーは配列と同じタイプに変換される.浮動小数点型配列の場合,それらのビット表現が処理に使われる.
        /// dst(I)=src(I)^value
        /// </summary>
        /// <param name="src1">入力配列</param>
        /// <param name="value">処理に用いるスカラー</param>
        /// <param name="dst">出力配列</param>
#else
        /// <summary>
        /// Performs per-element bit-wise "exclusive or" operation on 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>
#endif
        public static void XorS(CvArr src1, CvScalar value, CvArr dst)
        {
            XorS(src1, value, dst, null);
        }
Beispiel #7
0
#pragma warning disable 1591
        #region DrawMarker
        public void DrawMarker(int x, int y, CvScalar color)
        {
            DrawMarker(x, y, color, MarkerStyle.Cross, 10, LineType.Link8, 1);
        }
Beispiel #8
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)
        {
            AbsDiffS(src, dst, CvScalar.ScalarAll(0));
        }
Beispiel #9
0
        /// <summary>
        /// 画像上にテキストを描画する際に利用されるフォントを作成します.
        /// </summary>
        /// <param name="nameFont">フォント名. 指定のフォントが見つからなければ,デフォルトフォントが利用されます.</param>
        /// <param name="pointSize">ォントサイズ.これが,未指定,または0以下の値の場合,フォンとのポイントサイズはシステム依存のデフォルト値にセットされます.通常は,12ポイントです.</param>
        /// <param name="color">BGRA で表現されるフォントカラー.</param>
        /// <param name="weight">フォントの太さ</param>
#else
        /// <summary>
        /// Create the font to be used to draw text on an image
        /// </summary>
        /// <param name="nameFont">Name of the font. The name should match the name of a system font (such as ``Times’‘). If the font is not found, a default one will be used.</param>
        /// <param name="pointSize">Size of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.</param>
        /// <param name="color">Color of the font in BGRA – A = 255 is fully transparent. Use the macro CV _ RGB for simplicity.</param>
        /// <param name="weight">The operation flags</param>
#endif
        public CvFontQt(string nameFont, int pointSize, CvScalar color, FontWeight weight)
            : this(nameFont, pointSize, color, weight, FontStyle.Normal, 0)
        {
        }
Beispiel #10
0
        /// <summary>
        /// 一様または正規分布の乱数で出力配列を埋める
        /// </summary>
        /// <param name="rng">cvRNGによって初期化されたRNGの状態</param>
        /// <param name="distType">分布のタイプ</param>
        /// <param name="param1">分布の第一パラメータ.一様分布では,発生する乱数の下限値(この値を含む)である. 正規分布では,乱数の平均値である.</param>
        /// <param name="param2">分布の第二パラメータ.一様分布では,発生する乱数の上限値(この値は含まない)である. 正規分布では,乱数の標準偏差である.</param>
#else
        /// <summary>
        /// Fills array with random numbers and updates the RNG state
        /// </summary>
        /// <param name="rng">RNG state initialized by cvRNG. </param>
        /// <param name="distType">Distribution type.</param>
        /// <param name="param1">The first parameter of distribution. In case of uniform distribution it is the inclusive lower boundary of random numbers range. In case of normal distribution it is the mean value of random numbers. </param>
        /// <param name="param2">The second parameter of distribution. In case of uniform distribution it is the exclusive upper boundary of random numbers range. In case of normal distribution it is the standard deviation of random numbers. </param>
#endif
        public void RandArr(CvRNG rng, DistributionType distType, CvScalar param1, CvScalar param2)
        {
            Cv.RandArr(rng, this, distType, param1, param2);
        }
Beispiel #11
0
        /// <summary>
        /// 画像上にテキストを描画する際に利用されるフォントを作成します.
        /// </summary>
        /// <param name="nameFont">フォント名. 指定のフォントが見つからなければ,デフォルトフォントが利用されます.</param>
        /// <param name="pointSize">ォントサイズ.これが,未指定,または0以下の値の場合,フォンとのポイントサイズはシステム依存のデフォルト値にセットされます.通常は,12ポイントです.</param>
#else
        /// <summary>
        /// Create the font to be used to draw text on an image
        /// </summary>
        /// <param name="nameFont">Name of the font. The name should match the name of a system font (such as ``Times’‘). If the font is not found, a default one will be used.</param>
        /// <param name="pointSize">Size of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.</param>
#endif
        public CvFontQt(string nameFont, int pointSize)
            : this(nameFont, pointSize, CvScalar.ScalarAll(0), FontWeight.Normal, FontStyle.Normal, 0)
        {
        }
Beispiel #12
0
        /// <summary>
        /// 画像上にテキストを描画する際に利用されるフォントを作成します.
        /// </summary>
        /// <param name="nameFont">フォント名. 指定のフォントが見つからなければ,デフォルトフォントが利用されます.</param>
#else
        /// <summary>
        /// Create the font to be used to draw text on an image
        /// </summary>
        /// <param name="nameFont">Name of the font. The name should match the name of a system font (such as ``Times’‘). If the font is not found, a default one will be used.</param>
#endif
        public CvFontQt(string nameFont)
            : this(nameFont, -1, CvScalar.ScalarAll(0), FontWeight.Normal, FontStyle.Normal, 0)
        {
        }
Beispiel #13
0
        /// <summary>
        /// 一様または正規分布の乱数で出力配列を埋める
        /// </summary>
        /// <param name="arr">出力配列</param>
        /// <param name="dist_type">分布のタイプ</param>
        /// <param name="param1">分布の第一パラメータ.一様分布では,発生する乱数の下限値(この値を含む)である. 正規分布では,乱数の平均値である.</param>
        /// <param name="param2">分布の第二パラメータ.一様分布では,発生する乱数の上限値(この値は含まない)である. 正規分布では,乱数の標準偏差である.</param>
#else
        /// <summary>
        /// Fills array with random numbers and updates the RNG state
        /// </summary>
        /// <param name="arr">The destination array. </param>
        /// <param name="dist_type">Distribution type.</param>
        /// <param name="param1">The first parameter of distribution. In case of uniform distribution it is the inclusive lower boundary of random numbers range. In case of normal distribution it is the mean value of random numbers. </param>
        /// <param name="param2">The second parameter of distribution. In case of uniform distribution it is the exclusive upper boundary of random numbers range. In case of normal distribution it is the standard deviation of random numbers. </param>
#endif
        public void RandArr(CvArr arr, DistributionType dist_type, CvScalar param1, CvScalar param2)
        {
            Cv.RandArr(this, arr, dist_type, param1, param2);
        }
Beispiel #14
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>
#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>
#endif
        public static void DrawContours(CvArr img, CvSeq<CvPoint> contour, CvScalar externalColor, CvScalar holeColor, int maxLevel, int thickness, LineType lineType)
        {
            DrawContours(img, contour, externalColor, holeColor, maxLevel, thickness, lineType, new CvPoint(0, 0));
        }
Beispiel #15
0
 public void DrawMarker(int x, int y, CvScalar color, MarkerStyle style, int size, LineType lineType)
 {
     DrawMarker(x, y, color, style, size, LineType.Link8, 1);
 }
Beispiel #16
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);
        }
Beispiel #17
0
        /// <summary>
        /// 配列要素の平均と標準偏差を各チャンネルで独立に計算する.
        /// </summary>
        /// <param name="arr">配列</param>
        /// <param name="mean">計算結果の平均値の出力</param>
        /// <param name="stdDev">計算結果の標準偏差の出力</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>
#endif
        public static void AvgSdv(CvArr arr, out CvScalar mean, out CvScalar stdDev)
        {
            AvgSdv(arr, out mean, out stdDev, null);
        }