Exemple #1
0
        /// <summary>
        /// Save the current settings to a file.
        /// </summary>
        /// <param name="obj">Acquisition settings</param>
        /// <param name="folderPath">The path to the destination folder.</param>
        /// <returns></returns>
        public bool SaveCurrent(ConfigSetting obj, string folderPath)
        {
            bool res;

            try
            {
                string path = string.Format("{0}\\{1}", folderPath, SETTINGSFILENAME);
                res = Writter.WriteToFile(path, obj);

                //refresh value
                curSettings = obj;

                if (res && OnSettingsSaved != null)
                {
                    OnSettingsSaved(this, new ConfigSettingArgs(obj));
                }
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }

            return(res);
        }
Exemple #2
0
 private void configUpdate(ConfigSetting configSetting)
 {
     this.cfg = configSetting;
 }
Exemple #3
0
 public blobs_ms_compare(ConfigSetting _cfg)
 {
     cfg           = _cfg;
     widthOfCamera = cfg.widthOfCameraView;
 }
Exemple #4
0
 public blobs_ms_compare()
 {
     cfg           = SettingsManager.Instance.GetCurrent(System.Windows.Forms.Application.StartupPath);
     widthOfCamera = cfg.widthOfCameraView;
 }
Exemple #5
0
        // standart report
        public static void CreateStandartReport3(List <Bitmap> list /*,  int[] sample*/)
        {
            GC.Collect();

            MembersMorphoParameters mmp = MembersMorphoParameters.Deserialization();

            int inx = 0;

            Bitmap[]   src   = new Bitmap[list.Count];
            blob_tag[] blobs = new blob_tag[src.Length];

            foreach (Bitmap image in list)
            {
                src[inx++] = image;
            }

            ConfigSetting cfg   = SettingsManager.Instance.GetCurrent(System.Windows.Forms.Application.StartupPath);
            mmxRtfStore   store = new mmxRtfStore();

            store.AddRTF(Application.StartupPath + @"\reports\blank.rtf");


            // draw images
            for (int i = 0; i < src.Length; i++)
            {
                blobs[i] = (blob_tag)src[i].Tag;
                Bitmap bsrc = blobs[i].Image_bgr.Bitmap; //src[i].Clone(new Rectangle(0,0,src[i].Width , src[i].Height), PixelFormat.Format24bppRgb);
                Bitmap bbin = blobs[i].Image_bin.Bitmap;


                if (false && bsrc.Width > cfg.Report.ImgWidth)
                {
                    Size size = new Size(cfg.Report.ImgWidth, cfg.Report.ImgHeigth);
                    bsrc = resize(bsrc, size, true);
                    bbin = resize(bbin, size, false);
                }

                store.AddText((cfg.Report.ImgOriental) ? "  Source / Binarised images:" : "  Source images:");
                store.AddParagraph();
                store.AddImage(bsrc);

                if (!cfg.Report.ImgOriental)
                {
                    store.AddText("  Binarised images:");
                    store.AddParagraph();
                }

                store.AddImage(bbin);
                store.AddParagraph();
            }

            // draw histograms
            string[,] toRep = new string[mmp.countToReport, blobs.Length];
            string[] colNames = new string[mmp.countToReport];
            int      counter  = 0;
            int      j        = 0;

            for (int i = 0; i < 16; i++)
            {
                if (mmp.mp[i].ToReport)
                {
                    string   filtname = FilterName(mmp.mp[i].name, "mkm");
                    string   s        = "Histogram of " + filtname + " of particles ";
                    double[] z        = Filter(mmp.mp[i].name, blobs);

                    colNames[counter] = mmp.mp[i].name;
                    string[] tmp = FilterTable(mmp.mp[i].name, blobs);
                    for (j = 0; j < blobs.Length; j++)
                    {
                        toRep[counter, j] = tmp[j];
                    }
                    counter++;
                    if (z != null)
                    {
                        store.AddHistogram(s, mmp.mp[i].name, "", "", z, 10, 5, 2, cfg.Report.HistoWidth, cfg.Report.HistoHeigth, true);
                        store.AddParagraph();
                    }
                }
            }
            counter--;

            // draw tables
            if (colNames.Length > 0)
            {
                string[] filname = FilterName(colNames, "mkm");
                store.AddTable(toRep, filname, "Morpho Parameters of particles");
            }

            // formula
            //FormulaArea fa = new FormulaArea(blobs, (new CoefRangeXML()).Exec());
            //decimal formula = fa.Exec();
            //store.AddText(fa.Formula, new Font("Courier New", 9, FontStyle.Regular));


            // save rep to tmp file
            store.SaveAndShow();

            GC.Collect();
        }
Exemple #6
0
        public static void CreateLocalReport0(List <Bitmap> srcMaster, List <Bitmap> srcSlave, List <long []> link)
        {
            GC.Collect();

            MembersMorphoParameters mmp   = MembersMorphoParameters.Deserialization();
            ConfigSetting           cfg   = SettingsManager.Instance.GetCurrent(System.Windows.Forms.Application.StartupPath);
            mmxRtfStore             store = new mmxRtfStore();

            blob_tag[] blobsMaster = new blob_tag[srcMaster.Count];
            blob_tag[] blobsSlave  = new blob_tag[srcSlave.Count];

            store.AddRTF(Application.StartupPath + @"\reports\blank.rtf");

            int good = 0;
            int bad  = 0;

            // draw images
            for (int i = 0; i < srcMaster.Count; i++)
            {
                bool isPaire = (link != null && link.Count > i && link[i][1] > -1);

                blobsMaster[i] = (blob_tag)srcMaster[i].Tag;
                Bitmap bsrcMaster = blobsMaster[i].Image_bgr.Bitmap;//srcMaster[i].Clone(new Rectangle(0, 0, srcMaster[i].Width, srcMaster[i].Height), PixelFormat.Format24bppRgb);
                Bitmap bbinMaster = blobsMaster[i].Image_bin.Bitmap;
                Bitmap bsrcSlave  = null;
                Bitmap bbinSlave  = null;

                if (isPaire)
                {
                    Bitmap slaveBitmap = getSlave(srcSlave, link[i][1]);
                    blobsSlave[i] = (blob_tag)slaveBitmap.Tag;
                    bsrcSlave     = blobsSlave[i].Image_bgr.Bitmap;
                    bbinSlave     = blobsSlave[i].Image_bin.Bitmap;
                }

                if (false && bsrcMaster.Width > cfg.Report.ImgWidth)
                {
                    Size size = new Size(cfg.Report.ImgWidth, cfg.Report.ImgHeigth);
                    bsrcMaster = resize(bsrcMaster, size, true);
                    bbinMaster = resize(bbinMaster, size, false);
                    bsrcSlave  = resize(bsrcSlave, size, true);
                    bbinSlave  = resize(bbinSlave, size, false);
                }

                string resultat;
                if (blobsMaster[i].check || (isPaire && blobsSlave[i].check))
                {
                    resultat = "bad";
                    bad++;
                }
                else
                {
                    resultat = "good";
                    good++;
                }
                // make report ...
                {
                    store.AddParagraph();

                    store.AddText($"Sample #{i + 1} is {resultat}");

                    store.AddParagraph();

                    store.AddImage(bsrcMaster);
                    store.AddImage(bbinMaster);
                    store.AddText(" - source / binarised images from camera #1");


                    store.AddParagraph();

                    if (isPaire)
                    {
                        store.AddImage(bsrcSlave);
                        store.AddImage(bbinSlave);
                        store.AddText(" - source / binarised images from camera #2");
                    }

                    //                    store.AddParagraph();
                }
                {
                    string[,] toRep = new string[mmp.countToReport, 2];
                    string[] colNames = new string[mmp.countToReport];
                    int      counter  = 0;
                    for (int ix = 0; ix < 16; ix++)
                    {
                        if (mmp.mp[ix].ToReport)
                        {
                            colNames[counter] = mmp.mp[ix].name;
                            blob_tag[] arr   = (isPaire)? new blob_tag[] { blobsMaster[i], blobsSlave[i] } : new blob_tag[] { blobsMaster[i] };
                            string[]   items = FilterTable(mmp.mp[ix].name, arr);
                            for (int j = 0; j < arr.Length; j++)
                            {
                                toRep[counter, j] = items[j];
                            }
                            counter++;
                        }
                    }
                    counter--;

                    // draw tables
                    if (colNames.Length > 0)
                    {
                        string[] filname = FilterName(colNames, "mkm");
                        store.AddTable(toRep, filname, $"morpho parameters of sample #{i+1}");
                    }
                }
            }


            store.AddParagraph();
            store.AddText($"Total conclusion by report: total detect samples - {srcMaster.Count} ( good - {good }, bad - {bad} )");


            // save rep to tmp file
            store.SaveAndShow();

            GC.Collect();
        }
Exemple #7
0
        /// <summary>
        /// Get the default settings
        /// </summary>
        /// <returns></returns>
        public ConfigSetting GetDefault(bool isFileExist = true)
        {
            ConfigSetting settings = new ConfigSetting();

            return(settings);
        }
Exemple #8
0
 public FormSetBlow(ConfigSetting config)
 {
     InitializeComponent();
     cfg = config;
 }
Exemple #9
0
 public ConfigSettingArgs(ConfigSetting e)
 {
     this.settings = e;
 }