Exemple #1
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     rThread.Dispose();
     if (MBmaster != null)
     {
         MBmaster.Dispose();
         MBmaster = null;
     }
     UdpClass.del_socket();
 }
Exemple #2
0
 private void CloseLaser_Click(object sender, EventArgs e)
 {
     UdpClass.set_laser_state(false);
 }
Exemple #3
0
        unsafe void getData()
        {
            float tx, tz, max, min, cv;
            int   cc = 0, ci = 0;

            //      sorted = new PointF[920 / n];
            filters = new PointF[920 / n];
            int b = UdpClass.rec_init(ref p);

            while (true)
            {
                int c = UdpClass.rec_cam_line_data(x, z, ref p);
                if (c == 1)
                {
                    sb.Clear();
                    lock (this)
                    {
                        fixed(float *px = x, pz = z)
                        {
                            float *ppx = px;
                            float *ppz = pz;

                            for (int i = 0; i < 920; i += n)
                            {
                                if (i < 920 - n)
                                {
                                    float *ppxk = ppx + n;
                                    float *ppzk = ppz + n;
                                    for (int k = i + 5; k < 920; k += n)
                                    {
                                        if (*ppx > *ppxk)
                                        {
                                            tx = *ppx;
                                            *ppx  = *ppxk;
                                            *ppxk = tx;
                                            tz = *ppz;
                                            *ppz  = *ppzk;
                                            *ppzk = tz;
                                        }
                                        ppxk += n;
                                        ppzk += n;
                                    }
                                }
                                cv = 0;
                                cc = 0;
                                //中位值平均滤波法
                                min = *ppz;
                                max = *ppz;
                                for (int j = -m; j <= m; j++)
                                {
                                    ci = j * n;
                                    if (ci + i < 920 && ci + i >= 0)
                                    {
                                        cv += ppz[ci];
                                        if (ppz[ci] > max)
                                        {
                                            max = ppz[ci];
                                        }
                                        if (ppz[ci] < min)
                                        {
                                            min = ppz[ci];
                                        }
                                        cc++;
                                    }
                                }
                                cv = (cv - min - max) / (cc - 2);

                                /*
                                 * //Mean
                                 * for (int j = -m; j <= m; j++)
                                 * {
                                 *  ci = j * n;
                                 *  if (ci + i < 920 && ci + i >= 0)
                                 *  {
                                 *      cv += ppz[ci];
                                 *      cc++;
                                 *  }
                                 * }
                                 * cv = cv / cc;*/

                                sb.Append(string.Format("{2}:x = {0} z = {1}\r\n", *ppx, -*ppz, i / n));

                                filters[i / n].X = (float)((*ppx * 2 + 30) * MajorTicY + margin);
                                filters[i / n].Y = (float)(pnlCanvas.Height - margin - (-cv + 40) * MajorTicY);
                                ppx += n;
                                ppz += n;
                            }
                        }

                        cnt++;
                        //    sorted = dps.OrderBy(p => p.Y).ToArray();
                        //    filter(sorted);
                        richTextBox1.BeginInvoke(new EventHandler(delegate
                        {
                            try
                            {
                                richTextBox1.Text = sb.ToString();
                            }
                            catch { }
                        }));
                        pnlCanvas.BeginInvoke(new EventHandler(delegate
                        {
                            Draw();
                        }));
                    }
                    Thread.Sleep(10);
                }
            }
        }
Exemple #4
0
 private void OpenLaser_Click(object sender, EventArgs e)
 {
     UdpClass.set_laser_state(true);
 }