예제 #1
0
        public PredictionBreakDownDisplay(PicesDataBase _dbConn,
                                          PicesDataBaseImage _image,
                                          PicesRaster _raster,
                                          TrainingModel2 _trainingModel,
                                          PicesInstrumentData _instrumentData, /*!<  Instrument data that goes with image, if null will read from database. */
                                          PicesRunLog _runLog
                                          )
        {
            if (_runLog == null)
            {
                runLog = new PicesRunLog();
            }
            else
            {
                runLog = _runLog;
            }

            if (_image == null)
            {
                return;
            }

            fileName       = _image.ImageFileName;
            instrumentData = _instrumentData;
            trainingModel  = _trainingModel;

            PicesRaster raster = _raster;

            if (_dbConn != null)
            {
                if (raster == null)
                {
                    raster = _dbConn.ImageFullSizeFind(fileName);
                }

                if (instrumentData == null)
                {
                    instrumentData = _dbConn.InstrumentDataGetByScanLine(_image.SipperFileName, _image.TopLeftRow);
                }

                dbFeatureVector = _dbConn.FeatureDataRecLoad(fileName);
            }

            if (raster == null)
            {
                return;
            }

            //raster = raster.ConnectedComponent ();

            featureCalcImages = new PicesRasterList();
            featureVector     = new PicesFeatureVector(raster, fileName, featureCalcImages, runLog);
            if (instrumentData != null)
            {
                featureVector.AddInstrumentData(instrumentData);
            }

            InitializeComponent();
        }
        public PredictionBreakDownDisplayDual(PicesDataBase _dbConn,
                                              String _fileName,
                                              TrainingModel2 _trainingModel,
                                              PicesInstrumentData _instrumentData, /**<  Instrument data that goes with image,  if null will read from dtabase. */
                                              PicesRunLog _runLog
                                              )
        {
            if (_runLog == null)
            {
                runLog = new PicesRunLog();
            }
            else
            {
                runLog = _runLog;
            }

            fileName       = _fileName;
            instrumentData = _instrumentData;
            trainingModel  = _trainingModel;

            PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
            PicesRaster   raster = dbConn.ImageFullSizeFind(fileName);

            if (raster == null)
            {
                return;
            }

            if (_dbConn != null)
            {
                dbFeatureVector = _dbConn.FeatureDataRecLoad(_fileName);
                if (instrumentData == null)
                {
                    PicesDataBaseImage image = dbConn.ImageLoad(fileName);
                    if (image != null)
                    {
                        instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow);
                    }
                }
            }

            featureVector = new PicesFeatureVector(raster, fileName, null, runLog);

            if (instrumentData != null)
            {
                featureVector.AddInstrumentData(instrumentData);
            }

            dbConn.Close();
            dbConn = null;
            GC.Collect();

            InitializeComponent();
        }
예제 #3
0
        } /* UpdatedataFields*/

        private void MakePredictions()
        {
            if (!ActiveTrainingLibraries.ModelsAreAvailable())
            {
                // Since there are NO training models loaded;  there is no point doing the work for a prediction.
                return;
            }

            featureVector = dbConn.FeatureDataRecLoad(image);
            if (featureVector == null)
            {
                featureVector = new PicesFeatureVector(raster, image.ImageFileName, null, runLog);
                // Since we had to compute the FeatureDatya from the raster we now need to
                // get the instrument data that matches it.
                if (instrumentData != null)
                {
                    featureVector.AddInstrumentData(instrumentData);
                }

                dbConn.FeatureDataInsertRow(image.SipperFileName, featureVector);
            }

            float esd        = 0.0f;
            float eBv        = 0.0f;
            float filledArea = image.PixelCount;
            float cropWidth  = 3800.0f; // (3900.0f - 200.0f);
            float flowRate2  = 0.5f;

            if (featureVector != null)
            {
                filledArea = featureVector.FilledArea;
            }

            if (sipperFile != null)
            {
                scanRate = sipperFile.ScanRate;
            }

            esd = (float)(2.0 * Math.Sqrt(filledArea * (0.096 / cropWidth) * 1000.0 * (flowRate1 / sipperFile.ScanRate) * 1000.0 / 3.1415926));
            eBv = (float)((4.0 / 3.0) * Math.PI * Math.Pow(Math.Sqrt(filledArea * (chamberWidth / cropWidth) * 1000 * (flowRate1 / scanRate) * 1000.0 / Math.PI), 3));

            PicesPrediction model1Prediction1 = new PicesPrediction(null, 0, 0.0f);
            PicesPrediction model1Prediction2 = new PicesPrediction(null, 0, 0.0f);
            PicesPrediction model2Prediction1 = new PicesPrediction(null, 0, 0.0f);
            PicesPrediction model2Prediction2 = new PicesPrediction(null, 0, 0.0f);

            ActiveTrainingLibraries.MakePredictions(featureVector,
                                                    ref model1Prediction1,
                                                    ref model1Prediction2,
                                                    ref model2Prediction1,
                                                    ref model2Prediction2,
                                                    runLog
                                                    );

            if (model1Prediction1 != null)
            {
                Lib1Pred1Class.Text = model1Prediction1.ClassName;
                Lib1Pred1Prob.Text  = model1Prediction1.Probability.ToString("##0.00%");
                Lib1Pred1Votes.Text = model1Prediction1.Votes.ToString("#,##0");
            }

            if (model1Prediction2 != null)
            {
                Lib1Pred2Class.Text = model1Prediction2.ClassName;
                Lib1Pred2Prob.Text  = model1Prediction2.Probability.ToString("##0.00%");
                Lib1Pred2Votes.Text = model1Prediction2.Votes.ToString("#,##0");
            }

            if (model2Prediction1 != null)
            {
                Lib2Pred1Class.Text = model2Prediction1.ClassName;
                Lib2Pred1Prob.Text  = model2Prediction1.Probability.ToString("##0.00%");
                Lib2Pred1Votes.Text = model2Prediction1.Votes.ToString("#,##0");
            }

            if (model1Prediction2 != null)
            {
                Lib2Pred2Class.Text = model2Prediction2.ClassName;
                Lib2Pred2Prob.Text  = model2Prediction2.Probability.ToString("##0.00%");
                Lib2Pred2Votes.Text = model2Prediction2.Votes.ToString("#,##0");
            }

            if (featureVector != null)
            {
                AreaMMSquare.Text = featureVector.AreaMMSquare.ToString("#,##0.000");
            }

            ESD.Text = esd.ToString("#,##0.00");
            EBv.Text = eBv.ToString("##0.0000");

            return;
        } /* MakePredictions */