Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 计算二值图像中物体的角度c_C#_Emgucv - Fatal编程技术网

C# 计算二值图像中物体的角度c

C# 计算二值图像中物体的角度c,c#,emgucv,C#,Emgucv,我需要计算以下裁剪图像的角度。 所以我开发了CemguCV和openCV代码来计算角度 就在这里, 对于线的选定像素 在执行上述代码后,程序显示角度值的一些值,但每次运行时,它给出不同的答案,有时给出不正确的答案。请帮我找到解决这个问题的方法。你能解释一下你到底想确定哪个角度吗?你到底想做什么还不清楚。我需要在上图中计算膝盖的角度。[在链接中]你能解释一下你到底想确定哪个角度吗?你到底想做什么还很不清楚。我需要计算上图中膝盖的角度。[在链接中] public ArrayList getLine

我需要计算以下裁剪图像的角度。

所以我开发了CemguCV和openCV代码来计算角度

就在这里,

对于线的选定像素


在执行上述代码后,程序显示角度值的一些值,但每次运行时,它给出不同的答案,有时给出不正确的答案。请帮我找到解决这个问题的方法。

你能解释一下你到底想确定哪个角度吗?你到底想做什么还不清楚。我需要在上图中计算膝盖的角度。[在链接中]你能解释一下你到底想确定哪个角度吗?你到底想做什么还很不清楚。我需要计算上图中膝盖的角度。[在链接中]
public ArrayList getLinepixels()
{
   //bi.RotateFlip(RotateFlipType.Rotate90FlipXY);
    testPicBox.Image = bi;
    Color pixelColor;
    ArrayList list = new ArrayList();
    for (int y=0; y <bi.Height; y++)
    {
        int count=0;
        for (int x = 0; x < bi.Width; x++)
        {

            pixelColor = bi.GetPixel(x, y);
            if (pixelColor.R == 255 && pixelColor.G == 255 && pixelColor.B == 255)
            {
                count++;
                if (count == 1)
                {
                    Point p1 = new Point(x, y);
                    list.Add(p1);
                    drawPoint(x, y);
                    break;
                }
            }
        }
        int a = list.Count;
       // label2.Text = a.ToString();
    }
public ArrayList minimizePixels(ArrayList minimizeArL)
{
    mlist = new ArrayList();
    int minimizeArlCount = minimizeArL.Count;

    for (int i = 2; i < minimizeArlCount; i++)
    {
        if (i == 2)
        {
            mlist.Add(minimizeArL[i]);
        }
        else if (i == minimizeArlCount - 2)
        {
            mlist.Add(minimizeArL[i]);
        }
        else if (i == (minimizeArlCount / 2) / 2)
        {
            mlist.Add(minimizeArL[i]);
        }
        else if (i == (minimizeArlCount / 2) + ((minimizeArlCount / 2) / 2))
        {
            mlist.Add(minimizeArL[i]);
        }
    }
public void calculateAngle(ArrayList angleList)
{
    minimizePixels(getLinepixels());

    int firstRowX = ((Point)mlist[0]).X;
    int firstRowY = ((Point)mlist[0]).Y;

    int secondRowX = ((Point)mlist[1]).X;
    int secondRowY = ((Point)mlist[1]).Y;

    int thirdRowX = ((Point)mlist[2]).X;
    int thirdRowY = ((Point)mlist[2]).Y;

    int fourthRowX = ((Point)mlist[3]).X;
    int fourthRowY = ((Point)mlist[3]).Y;

    double tanTheta;
    double tanAlfa;
    double ang;

    tanTheta = Math.Atan2((Math.Abs(secondRowY - firstRowY)), (Math.Abs(secondRowX - firstRowX)));
    tanAlfa = Math.Atan2((Math.Abs(fourthRowY - thirdRowY)), (Math.Abs(fourthRowX - thirdRowX)));
    ang = (tanTheta + tanAlfa) * (180 / Math.PI);

    metroLabel1_angle.Text = Convert.ToString(ang);
}