OpenCvSharp.UserInterface.CvWindowEx.CreateTrackbar C# (CSharp) Method

CreateTrackbar() public method

Creates the trackbar and attaches it to this window
public CreateTrackbar ( string name, int value, int count, CvTrackbarCallback onChange ) : TrackbarWithLabel
name string Name of created trackbar.
value int The position of the slider
count int Maximal position of the slider. Minimal position is always 0.
onChange CvTrackbarCallback the function to be called every time the slider changes the position. This function should be prototyped as void Foo(int);
return TrackbarWithLabel
        public TrackbarWithLabel CreateTrackbar(string name, int value, int count, CvTrackbarCallback onChange)
        {
            var t = new TrackbarWithLabel(name, value, count, 0);
            t.Dock = DockStyle.Top;
            t.Trackbar.ValueChanged += (o, e) =>
            {
                int pos = ((TrackBar)o).Value;
                onChange(pos);
            };
            SetClientSize(new System.Drawing.Size(ClientSize.Width, ClientSize.Height + t.Height));
            _panelTrackbar.Height += t.Height;
            _panelTrackbar.Controls.Add(t);
            return t;
        }

Usage Example

コード例 #1
0
ファイル: SeqPartition.cs プロジェクト: qxp1011/opencvsharp
        /// <summary>
        /// 
        /// </summary>
        public SeqPartition()
        {
            CvMemStorage storage = new CvMemStorage(0);
            pointSeq = new CvSeq<CvPoint>(SeqType.EltypeS32C2, CvSeq.SizeOf, storage);
            Random rand = new Random();
            canvas = new IplImage(Width, Height, BitDepth.U8, 3);

            colors = new CvScalar[Count];
            for (int i = 0; i < Count; i++)
            {
                CvPoint pt = new CvPoint
                {
                    X = rand.Next(Width),
                    Y = rand.Next(Height)
                };
                pointSeq.Push(pt);
                int icolor = rand.Next() | 0x00404040;
                colors[i] = Cv.RGB(icolor & 255, (icolor >> 8) & 255, (icolor >> 16) & 255);
            }

            using (window = new CvWindowEx() { Text = "points" })
            {
                window.CreateTrackbar("threshold", 10, 50, OnTrack);
                OnTrack(10);
                CvWindowEx.WaitKey();
            }
        }
All Usage Examples Of OpenCvSharp.UserInterface.CvWindowEx::CreateTrackbar