1

我的最新项目有问题,我是 kinect 新手,我的编程技能并不出色。我需要我的程序来检测我的棍子(按颜色),所以我可以用它制作激光枪(红线从我的电脑上的棍子中出来)。我在使用这种颜色跟踪时遇到了很多麻烦。到目前为止,我有以下代码:

private void zoekGekleurdeStok(Image<Bgr, Byte> openCVImg)
    {
        pxLock img = new pxLock();

        Bitmap b = BitmapFromWriteableBitmap(colorBitmap);
        DataTable pxLocation = img.GetPixelLocation(b, c);


        if (pxLocation.Rows.Count <= 0) { return; }
        //Setup Rectangle
        int boxWidth = 20;
        int boxHeight = 20;
        //Get Pixel Position
        int iX = Convert.ToInt32(pxLocation.Rows[0]["Column"]);
        int iY = Convert.ToInt32(pxLocation.Rows[0]["Row"]);

        //Configure Rectangle
        //System.Drawing.Rectangle rect = new Rectangle(iX, iY, boxWidth, boxHeight);
        System.Drawing.Rectangle rect = new System.Drawing.Rectangle(iX, iY, boxWidth, boxHeight);
        //Configure Pen Style
        System.Drawing.Pen RedPen = new System.Drawing.Pen(System.Drawing.Color.Red, 2);
        RedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
        //Draw Rectangle
        //e.Graphics.DrawRectangle(RedPen, rect); /  /e.Graphics.FillRectangle(Brushes.Red, rect);

        System.Drawing.Point p3 = new System.Drawing.Point();
        p3.X = iX;
        p3.Y = iY;


        System.Drawing.Point p4 = new System.Drawing.Point();

        p4.X = iX + 30;
        p4.Y = iY + 30;
        LineSegment2D line = new LineSegment2D();
        line.P1 = p3;
        line.P2 = p4;


        openCVImg.Draw(line, new Bgr(System.Drawing.Color.Red), 5);
    }

但是我相信填写我的pxLocation需要很长时间,并且sub一次又一次地被调用。在几天没有产生任何好的代码之后,我想我应该切换到不同的语言或程序?

也许这里的任何人都有这方面的经验。我只想用我的 kinect 做一个简单的颜色跟踪程序。

我希望你们能理解我的解释,我的英语不是很好。我很抱歉。

提前致谢。

4

0 回答 0