zoukankan      html  css  js  c++  java
  • Software Testing:简要描述领你印象最深的error在你的项目

     

    problem:

    In a program that uses Opencv for image processing. My goal is to use the camera to identify the precise coordinates of multiple balls. But because of the light, in the identification process, the coordinates of the ball sometimes accurate sometimes sometimes inaccurate, in order to make each identified the ball coordinates can be more accurate. We need to each ball to identify the coordinates of the average to get a more accurate coordinates.

    I use the following way to average the ball coordinates.

    First, we should save the coordinates identified this time to the array ballpre [], and then to the next time to identify the ball in the process, with the coordinates (x, y) and ballpre [] coordinates in the calculation of the distance. The minimum distance is to identify the coordinates of a same small ball, and then add them together. Finally using the sum of coordinates divided by the number of times identified by the coordinates.

    At first I thought that my method was right, but at the time of the run, I found that the result was wrong.

    Why this error impress I most?

    Because this problem I spent a lot of time, at first thought that the algorithm error, and constantly to check the algorithm and grammar. There is another reason that this project is submitted in my first time to participate in the competition.

    How did I find it?    What is the error?

    And then I print out the data every time, analyze it, I found that the reason is that some of the ball in a recognition process has not been identified, so it is divided by the number of identification should not be the total number of identification.

     

    Solution:Add an array to control the number of times the ball is recognized. We use the elements in this array as the denominator of the above formula.

    The following is the specific code:

     

    for (int i = 0; i < MIN(count_x, 20); i++)

            {

                if (ci == 0)

                {

                    xx1[i] = x[i];

                    yy1[i] = y[i];

                    sum_x[i] += x[i];

                    sum_y[i] += y[i];

                    for (int i = 0; i < count_x; i++)

                    {

                        sumx[i] = 1;

                    }

                    for (int i = count_x; i < 100; i++)

                    {

                        sumx[i] = 0;

                    }

                }

                for (int j = 0; j < count_x; j++)

                {

                    //float * q = (float *)cvGetSeqElem(cir, j);

                    if (ci > 0)

                    {

                        double a = pow(x[j] - xx1[i], 2) + pow(y[j] - yy1[i], 2);

                        if (cvRound(sqrt(a)) <= 15)

                        {

                            //cout << cvRound(q[0]) << "   " << x1[i] << endl;

                            //cout << cvRound(q[1]) << "   " << y1[i] << endl;

                            //cout << "sqrt(a)" << sqrt(a) << endl;

                            sum_x[i] += x[j];

                            sum_y[i] += y[j];

                            sumx[i]++;

                            break;

                        }

                        if (j == count_x&&cvRound(sqrt(a)) > 15)

                        {

                            sum_x[j] += x[j];

                            sum_y[j] += y[j];

                            sumx[j]++;

                        }

                    }

     

                }

               

                            xx[i] = sum_x[i] / sumx[i];

                            yy[i] = sum_y[i] / sumx[i];

                           

     

                        }

     

                   }

  • 相关阅读:
    气象数据集数据和相关源码
    农产品质量追溯系统/质量安全追溯系统
    Nutch2.x 演示抓取第一个网站
    Nutch的配置以及动态网站的抓取
    leach-matlab
    leach协议matlab仿真代码
    无线传感器网络数据融合技术
    无线传感器网络数据融合概述
    No pressure, no diamonds.
    Hibernate缓存应用的积累与总结
  • 原文地址:https://www.cnblogs.com/mjm212/p/6441795.html
Copyright © 2011-2022 走看看