Ejemplo n.º 1
0
        private void ProcessWithCirclesFinder()
        {
            string bmpFile = ImgProcess.FormatBmp(TB_Filepath.Text);

            CirclesFinder f = new CirclesFinder((Bitmap)Bitmap.FromFile(bmpFile));

            TB_OutputPath.Text = Utils.String.FilePostfix(TB_Filepath.Text, "-result").Replace(".jpg", ".bmp");

            int width  = PB_Result.Width;
            int height = PB_Result.Height;

            Bitmap b = f.Draw(TB_OutputPath.Text);

            b = new Bitmap(b, width, height);
            PB_Result.Image = b;

            ImgProcess.Count(f.Rounds);
            string txtFile = TB_OutputPath.Text.Replace(".bmp", ".txt");

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(txtFile, true))
            {
                file.Write(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8}",
                                         "ID", "X", "Y",
                                         "LengthOnX", "DeviationOnX",
                                         "LengthOnY", "DeviationOnY",
                                         "Weight", "DeviationOnWeight") + Environment.NewLine);

                foreach (var round in f.Rounds)
                {
                    file.Write(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8}",
                                             round.Id.ToString("D3"), round.CenterX, round.CenterY,
                                             round.MaxLenLine.Length, round.LenXDiff.ToString("F4"),
                                             round.EndY - round.StartY, round.LenYDiff.ToString("F4"),
                                             round.Weight.ToString(), round.WeightDiff.ToString("F4")));
                    file.Write(Environment.NewLine);
                }

                double radiusStdEv = Utils.Math.StdEv(f.Rounds.Select(x => (double)x.MaxLenLine.Length).ToList());
                file.Write(string.Format("StdEv of Radius: {0}", radiusStdEv));
                file.Write(Environment.NewLine);

                double weightStdEv = Utils.Math.StdEv(f.Rounds.Select(x => (double)x.Weight).ToList());
                file.Write(string.Format("StdEv of Weight: {0}", weightStdEv));
                file.Write(Environment.NewLine);
            }
        }
Ejemplo n.º 2
0
        /* to be obsoleted */
        private void ProcessWithCircleFinder()
        {
            //var rawData = mCamera.Execute(new Command("Read", new Dictionary<string, string> { { "Type", "Raw" } })).Param as Bitmap;

            string resultBmp = Utils.String.FilePostfix(_filePath, "-result");
            string resultTxt = resultBmp.Replace(".bmp", ".txt");

            Bitmap        bmpFile = ImgProcess.Binarize(_filePath);
            CirclesFinder f       = new CirclesFinder(bmpFile);

            LatestImage = f.Draw(resultBmp);

            ImgProcess.Count(f.Rounds);
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(resultTxt, true))
            {
                file.Write(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8}",
                                         "ID", "X", "Y",
                                         "LengthOnX", "DeviationOnX",
                                         "LengthOnY", "DeviationOnY",
                                         "Weight", "DeviationOnWeight") + Environment.NewLine);

                foreach (var round in f.Rounds)
                {
                    file.Write(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8}",
                                             round.Id.ToString("D3"), round.CenterX, round.CenterY,
                                             round.MaxLenLine.Length, round.LenXDiff.ToString("F4"),
                                             round.EndY - round.StartY, round.LenYDiff.ToString("F4"),
                                             round.Weight.ToString(), round.WeightDiff.ToString("F4")));
                    file.Write(Environment.NewLine);
                }

                double radiusStdEv = Utils.Math.StdEv(f.Rounds.Select(x => (double)x.MaxLenLine.Length).ToList());
                file.Write(string.Format("StdEv of Radius: {0}", radiusStdEv));
                file.Write(Environment.NewLine);

                double weightStdEv = Utils.Math.StdEv(f.Rounds.Select(x => (double)x.Weight).ToList());
                file.Write(string.Format("StdEv of Weight: {0}", weightStdEv));
                file.Write(Environment.NewLine);
            }
        }