当前位置: 首页>>代码示例>>C#>>正文


C# CvScalar类代码示例

本文整理汇总了C#中CvScalar的典型用法代码示例。如果您正苦于以下问题:C# CvScalar类的具体用法?C# CvScalar怎么用?C# CvScalar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CvScalar类属于命名空间,在下文中一共展示了CvScalar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Capture

    private IEnumerator Capture()
    {
        while (true) {
            var width = _webCamTexture.width;
            var height = _webCamTexture.height;
            var pixels = _webCamTexture.GetPixels();
            Parallel.For(0, height, i =>
            {
                for (var j = 0; j < width; j++)
                {
                    var pixel = pixels[j + i * width];
                    var col = new CvScalar
                    {
                        Val0 = (double)pixel.b * 255,
                        Val1 = (double)pixel.g * 255,
                        Val2 = (double)pixel.r * 255
                    };

                    _iplImage.Set2D(i, j, col);
                }
            });
            if (OnFrameReady != null) OnFrameReady.Invoke(_iplImage);
            yield return null;
        }
    }
开发者ID:redflasher,项目名称:unity-opencvsharp,代码行数:25,代码来源:WebCamTextureProxy.cs

示例2: CvMatProxy

 public CvMatProxy(CvScalar[,] data, int rows, int cols, int elemChannels)
 {
     Data = data;
     Rows = rows;
     Cols = cols;
     ElemChannels = elemChannels;
 }
开发者ID:0sv,项目名称:opencvsharp,代码行数:7,代码来源:CvMatDebuggerVisualizer.cs

示例3: AbsDiffS

        /// <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);
        }
开发者ID:jorik041,项目名称:opencvsharp,代码行数:23,代码来源:Cv_A.cs

示例4: color2

        public void color2()
        {
            Double H2 = decimal.ToDouble(numericUpDown4.Value);
            Double S2 = decimal.ToDouble(numericUpDown5.Value);
            Double V2 = decimal.ToDouble(numericUpDown6.Value);

            int[] rgb2 = HSVtoRGB((int)H2, (int)S2, (int)V2);
            
            CvScalar hsv2 = new CvScalar(rgb2[2], rgb2[1], rgb2[0]);
            IplImage ipl2 = fnc(mat2, hsv2);
            
            Bitmap bmp2 = BitmapConverter.ToBitmap(ipl2);
            pictureBox2.Image = bmp2;
        }
开发者ID:Kizyu08,项目名称:presentation_assist_tool,代码行数:14,代码来源:settings.cs

示例5: color1

        public void color1()
        {
            Double H1 = decimal.ToDouble(numericUpDown1.Value);
            Double S1 = decimal.ToDouble(numericUpDown2.Value);
            Double V1 = decimal.ToDouble(numericUpDown3.Value);

            int[] rgb1 = HSVtoRGB((int)H1, (int)S1, (int)V1);

            CvScalar hsv1 = new CvScalar(rgb1[2], rgb1[1], rgb1[0]);
            IplImage ipl1 =  fnc(mat1, hsv1);

            Bitmap bmp1 = BitmapConverter.ToBitmap(ipl1);
            pictureBox1.Image = bmp1;
        }
开发者ID:Kizyu08,项目名称:presentation_assist_tool,代码行数:14,代码来源:settings.cs

示例6: LocatePoint

        /// <summary>
        /// 
        /// </summary>
        /// <param name="subdiv"></param>
        /// <param name="fp"></param>
        /// <param name="img"></param>
        /// <param name="active_color"></param>
        private void LocatePoint(CvSubdiv2D subdiv, CvPoint2D32f fp, IplImage img, CvScalar active_color)
        {
            CvSubdiv2DEdge e;
            CvSubdiv2DEdge e0 = 0;

            subdiv.Locate(fp, out e0);

            if (e0 != 0)
            {
                e = e0;
                do
                {
                    //Console.WriteLine(e);
                    DrawSubdivEdge(img, e, active_color);
                    e = e.GetEdge(CvNextEdgeType.NextAroundLeft);                    
                }
                while (e != e0);
            }

            DrawSubdivPoint(img, fp, active_color);
        }
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:28,代码来源:Delaunay.cs

示例7: FromTextureToIplImage

    void FromTextureToIplImage(IplImage imageIpl)
    {
        int imH = imHeight;

        for (int v = 0; v < imHeight; ++v)
        {
            for (int u = 0; u < imWidth; ++u)
            {

                CvScalar col = new CvScalar();
                col.Val0 = (double)webcamTexture.GetPixel(u, v).b * 255;
                col.Val1 = (double)webcamTexture.GetPixel(u, v).g * 255;
                col.Val2 = (double)webcamTexture.GetPixel(u, v).r * 255;

                imH = imHeight - v - 1;
                imageIpl.Set2D(imH, u, col);
            
            }
        }
      
    }
开发者ID:MaksimSychugov,项目名称:SpaceshipGesture,代码行数:21,代码来源:WebCamera.cs

示例8: Texture2DToMat

    // Convert the Texture2D type of Unity to OpenCV's CvMat
    // This uses Adcock's parallel C# code to parallelize the conversion and make it faster
    // I found the code execution dropped from 180 msec per frame to 70 msec per frame with parallelization
    void Texture2DToMat(Texture2D tex, Mat m)
    {
        //float startTime = Time.realtimeSinceStartup;

        Color[] pixels = tex.GetPixels();

        // Parallel for loop
        Parallel.For(0, imHeight, i =>
        {
            for (var j = 0; j < imWidth; j++)
            {

                var pixel = pixels[j + i * imWidth];
                var col = new CvScalar
                {
                    Val0 = (double)pixel.b * 255,
                    Val1 = (double)pixel.g * 255,
                    Val2 = (double)pixel.r * 255
                };

                m.Set(i, j, col);
            }
        });

        //				CvScalar col;
        //				Color pixel;
        //				int i, j;
        //
        //				// Non-parallelized code
        //				for (i = 0; i < imHeight; i++) {
        //						for (j = 0; j < imWidth; j++) {
        //								pixel = pixels [j + i * imWidth];
        //
        //								col = new CvScalar
        //								{
        //									Val0 = (double)pixel.b * 255,
        //									Val1 = (double)pixel.g * 255,
        //									Val2 = (double)pixel.r * 255
        //								};
        //
        //								videoSourceImage.Set2D (i, j, col);
        //						}
        //
        //				}

        // Flip up/down dimension and right/left dimension
        if (!FlipUpDownAxis && FlipLeftRightAxis)
            m.Flip(FlipMode.XY);
        else if (!FlipUpDownAxis)
            m.Flip(FlipMode.X);
        else if (FlipLeftRightAxis)
            m.Flip(FlipMode.Y);

        // Test difference in time between parallel and non-parallel code
        //Debug.Log (Time.realtimeSinceStartup - startTime);
    }
开发者ID:Titoulion,项目名称:Shoal,代码行数:59,代码来源:KinectOpenCvDetector.cs

示例9: DrawThresholdImage

    // Draw Thesholded Image
    void DrawThresholdImage(CvMat _img)
    {
        // The HSV (hue, saturation, and value) range for thresholding
        // Hue, Saturation, Value or HSV is a color model that describes colors (hue or tint)
        // in terms of their shade (saturation or amount of gray)
        //	and their brightness (value or luminance).
        // In openCV, the ranges for HSV are:
        // Hue range is [0,179], Saturation range is [0,255] and Value range is [0,255]
        // CvScalar(H, S, V)

        CvScalar _cvScalarFrom = new CvScalar(_hueLow, _satLow, 0),
        _cvScalarTo = new CvScalar(_hueHigh, _satHigh, 255);
        Cv.ShowImage("HSV Thresholded Image", GetThresholdedImage(_img, _cvScalarFrom, _cvScalarTo));
    }
开发者ID:Titoulion,项目名称:Shoal,代码行数:15,代码来源:VideoCaptureScript.cs

示例10: EllipseBox

        /// <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);
        }
开发者ID:sanglin307,项目名称:UnityOpenCV,代码行数:22,代码来源:Cv_E.cs

示例11: DrawEllipse

        /// <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);
        }
开发者ID:sanglin307,项目名称:UnityOpenCV,代码行数:32,代码来源:Cv_E.cs

示例12: Ellipse

        /// <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);
        }
开发者ID:sanglin307,项目名称:UnityOpenCV,代码行数:36,代码来源:Cv_E.cs

示例13: gpu_Stream_enqueueMemSet

 public static extern void gpu_Stream_enqueueMemSet(IntPtr obj, IntPtr src, CvScalar val);
开发者ID:NHisato,项目名称:opencvsharp,代码行数:1,代码来源:NativeMethods_gpu.cs

示例14: CvFontQt

        /// <summary>
        /// 画像上にテキストを描画する際に利用されるフォントを作成します.
        /// </summary>
        /// <param name="nameFont">フォント名. 指定のフォントが見つからなければ,デフォルトフォントが利用されます.</param>
        /// <param name="pointSize">ォントサイズ.これが,未指定,または0以下の値の場合,フォンとのポイントサイズはシステム依存のデフォルト値にセットされます.通常は,12ポイントです.</param>
        /// <param name="color">BGRA で表現されるフォントカラー.</param>
        /// <param name="weight">フォントの太さ</param>
        /// <param name="style">処理フラグ</param>
        /// <param name="spacing">文字間のスペース.正負の値が利用できます.</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>
        /// <param name="style">The operation flags</param>
        /// <param name="spacing">Spacing between characters. Can be negative or positive.</param>
#endif
        public CvFontQt(string nameFont, int pointSize, CvScalar color, FontWeight weight, FontStyle style, int spacing)
        {
            if (nameFont == null)
                throw new ArgumentNullException("nameFont");

            ptr = base.AllocMemory(SizeOf);
            WCvFont font = CvInvoke.cvFontQt(nameFont, pointSize, color, weight, style, spacing);
            using (ScopedGCHandle gch = new ScopedGCHandle(font, GCHandleType.Pinned))
            {
                Util.CopyMemory(ptr, gch.AddrOfPinnedObject(), SizeOf);
            }
        }
开发者ID:neoxeo,项目名称:opencvsharp,代码行数:32,代码来源:CvFontQt.cs

示例15: cvSetND

 public static extern void cvSetND(IntPtr arr, int[] idx, CvScalar value);
开发者ID:sanglin307,项目名称:UnityOpenCV,代码行数:1,代码来源:CvInvoke.cs


注:本文中的CvScalar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。