예제 #1
0
        } /* SetLeftCrop */

        private void  SetExtractionStartPoint(object sender, System.EventArgs e)
        {
            if (dbConn == null)
            {
                return;
            }

            uint scanLine = (uint)((displayRowTop + rightMouseRow) * sipperFile.Ratio());

            DialogResult dr = MessageBox.Show(panel, "Set Image Extraction starting Scan-Line to " +
                                              scanLine.ToString("###,###,##0") +
                                              " ?", "Image Extraction Start Point",
                                              MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                PicesSipperFile sf = dbConn.SipperFileRecLoad(dbSipperFile.SipperFileName);
                if (sf == null)
                {
                    MessageBox.Show(panel, "Error retrieving existing SipperFile Entry from database", "Update Starting Extraction Failed", MessageBoxButtons.OK);
                }
                else
                {
                    sf.ExtractionScanLineStart = (uint)scanLine;
                    dbConn.SipperFileUpdate(sf);
                    dbSipperFile.ExtractionScanLineStart = scanLine;
                }
            }
        }
        } /* CreateFeatureDataFileThread */

        void  MakeSureDepthFieldIsIncluded(PicesFeatureVectorList data)
        {
            PicesDataBase dbConn = null;
            PicesRunLog   runLog = new PicesRunLog(dialogMsgQueue);

            data.SortByImageFileName();

            String curSipperFileName  = "";
            float  curSipperFileDepth = 0.0f;


            foreach (PicesFeatureVector fv in data)
            {
                if (fv.Depth == 0.0f)
                {
                    if (dbConn == null)
                    {
                        dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                    }
                    uint   sacnLineNum        = 0;
                    uint   scanCol            = 0;
                    String nextSipperFileName = "";

                    PicesFeatureVector.ParseImageFileName(fv.ExampleFileName, ref nextSipperFileName, ref sacnLineNum, ref scanCol);

                    if (nextSipperFileName != curSipperFileName)
                    {
                        curSipperFileDepth = 0.0f;
                        curSipperFileName  = nextSipperFileName;

                        PicesSipperFile sf = dbConn.SipperFileRecLoad(curSipperFileName);
                        if (sf != null)
                        {
                            curSipperFileDepth = sf.Depth;
                        }
                    }

                    PicesInstrumentData id = dbConn.InstrumentDataGetByScanLine(curSipperFileName, sacnLineNum);
                    if ((id == null) || (id.Depth == 0.0))
                    {
                        fv.Depth = curSipperFileDepth;
                    }
                    else
                    {
                        fv.Depth = id.Depth;
                    }
                }
            }

            if (dbConn != null)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
            }
        } /* MakeSureDepthFieldIsIncluded */
        } /* CreateTuningFeatureFiles */

        void  MakeSureDepthFieldIsIncluded(PicesFeatureVectorList data)
        {
            PicesDataBase dbConn = null;
            PicesRunLog   runLog = new PicesRunLog();

            data.SortByImageFileName();

            String curSipperFileName  = "";
            float  curSipperFileDepth = 0.0f;


            foreach (PicesFeatureVector fv in data)
            {
                if (fv.Depth == 0.0f)
                {
                    String nextSipperFileName = PicesMethods.SipperFileNameFromImageFileName(fv.ExampleFileName);

                    if (nextSipperFileName != curSipperFileName)
                    {
                        curSipperFileDepth = 0.0f;
                        curSipperFileName  = nextSipperFileName;

                        if (dbConn == null)
                        {
                            dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                        }

                        PicesSipperFile sf = dbConn.SipperFileRecLoad(curSipperFileName);
                        if (sf != null)
                        {
                            curSipperFileDepth = sf.Depth;
                        }
                    }

                    if (fv.Depth == 0.0f)
                    {
                        fv.Depth = curSipperFileDepth;
                    }
                }
            }

            if (dbConn != null)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
            }
        } /* MakeSureDepthFieldIsIncluded */
예제 #4
0
        public ImportValidatdClass()
        {
            runLog      = new PicesRunLog();
            mainWinConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            runLogGoalie   = new PicesGoalKeeper("ImportValidatingClass");
            runLogMsgQueue = new Queue <String> ();

            sipperFile   = mainWinConn.SipperFileRecLoad(sipperFileName);
            unknownClass = GetClassFromName(mainWinConn, "UnKnown");

            InitializeComponent();

            SourceDirectory.Text = PicesSipperVariables.HomeDir();
            SourceDirectory.Text = "D:\\Users\\kkramer\\PlanktonCompetition\\trunk\\Data\\";
        }
예제 #5
0
        public ImageViewer(PicesRaster _raster,
                           PicesDataBaseImage _image,
                           PicesClassList _classes
                           )
        {
            runLog  = new PicesRunLog();
            raster  = _raster;
            classes = _classes;
            dbConn  = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
            image   = _image;

            sizeCoordinates = image.SizeCoordinates;

            if (raster == null)
            {
                raster = PicesRaster.GetOrigSipperImage(image.SipperFileName,
                                                        image.ByteOffset,
                                                        image.TopLeftRow,
                                                        image.TopLeftCol,
                                                        image.Height,
                                                        image.Width,
                                                        image.ConnectedPixelDist,
                                                        runLog
                                                        );
            }

            if (raster == null)
            {
                MessageBox.Show("Could not locate source image or SipperFile[" + image.SipperFileName + "]");
                return;
            }

            {
                uint scanLine = image.TopLeftRow;
                scanLine       = 4096 * (uint)(scanLine / 4096);
                instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow);
                sipperFile     = dbConn.SipperFileRecLoad(image.SipperFileName);
            }

            double pixelsPerScanLine = pixelsPerScanLineDefault;


            if (instrumentData != null)
            {
                if (instrumentData.ActiveColumns > 0)
                {
                    pixelsPerScanLine = instrumentData.ActiveColumns;
                }
                if (instrumentData.FlowRate1 > 0.0)
                {
                    flowRate1 = instrumentData.FlowRate1;
                }
            }

            if (sipperFile != null)
            {
                if (sipperFile.ScanRate > 0.0)
                {
                    scanRate = sipperFile.ScanRate;
                }
                deployment = dbConn.SipperDeploymentLoad(sipperFile.CruiseName, sipperFile.StationName, sipperFile.DeploymentNum);
                if (deployment != null)
                {
                    chamberWidth = deployment.ChamberWidth;
                }
            }

            if ((dataFieldAssignments == null) || (DataLabels == null))
            {
                ConfigurationLoad();
            }

            InitializeComponent();
            if (image != null)
            {
                extractionLogEntry = dbConn.LogEntriesSelect(image.ExtractionLogEntryId);
                classLogEntry      = dbConn.LogEntriesSelect(image.ClassLogEntryId);
            }

            mmPerPixelAccrossChamber = chamberWidth * mmPerMeter / pixelsPerScanLine;
            mmPerPixelWithFlow       = mmPerMeter * flowRate1 / scanRate;

            DataLabels    = new Label[4];
            DataLabels[0] = DataLabel0;
            DataLabels[1] = DataLabel1;
            DataLabels[2] = DataLabel2;
            DataLabels[3] = DataLabel3;

            displayDataFields    = new TextBox[4];
            displayDataFields[0] = DataField0;
            displayDataFields[1] = DataField1;
            displayDataFields[2] = DataField2;
            displayDataFields[3] = DataField3;

            UpdateDataFields();

            ImageFileName.Text = image.ImageFileName;
        }
        } /* ProcessSipperFiles*/

        void  ProcessSipperFile(String sfn)
        {
            PicesSipperFile sipperFile = dbConn.SipperFileRecLoad(sfn);

            if (sipperFile == null)
            {
                RunLogAddMsg("\n\n  ***ERROR***      Sipper File[" + sfn + "]  not defined in database.\n\n");
                return;
            }

            if (instrumentDataFileManager == null)
            {
                instrumentDataFileManager = new PicesInstrumentDataFileManager();
            }
            PicesInstrumentDataList data = instrumentDataFileManager.ReExtractInstrumentDataForSipperFile(sfn, sipperFile, runLog);

            if (cancelRequested)
            {
                return;
            }

            if (data == null)
            {
                RunLogAddMsg("\n\n ***ERROR***  Sipper File[" + sfn + "] returned no Instrument Data.\n\n");
                return;
            }

            RunLogAddMsg("Saving Instrument Data;  SipperFileName[" + sfn + "].\n");
            dbConn.InstrumentDataSaveListForOneSipperFile(sfn, data);

            if (cancelRequested)
            {
                return;
            }

            uint lastScanLine = 0;
            {
                RunLogAddMsg("Updating Images Table;  SipperFileName[" + sfn + "].\n");
                int c1 = 0;

                foreach (PicesInstrumentData id in data)
                {
                    if (cancelRequested)
                    {
                        break;
                    }

                    if (id.ScanLine > 0)
                    {
                        dbConn.ImageUpdateInstrumentDataFields(id, sfn, lastScanLine, id.ScanLine);
                    }
                    lastScanLine = id.ScanLine;

                    c1++;
                    if ((c1 % 25) == 0)
                    {
                        RunLogAddMsg("Updating Images Table;  SipperFileName[" + sfn + "]   ScanLine[" + lastScanLine.ToString("###,###,##0") + "]\n");
                    }
                }
            }
        } /* ProcessSipperFile*/
예제 #7
0
        } /* SaveGivenImageList */

        private void  SaveImagesBySipperFiles()
        {
            bool includeStationAndDeploymentInDirName = false;
            bool firstSipperFile = true;

            PicesSipperFileList sipperFiles = null;

            if (String.IsNullOrEmpty(sipperFileName))
            {
                sipperFiles = dbConn.SipperFileLoad(cruise, station, deployment);
            }
            else
            {
                PicesSipperFile sf = dbConn.SipperFileRecLoad(sipperFileName);
                if (sf != null)
                {
                    sipperFiles = new PicesSipperFileList();
                    sipperFiles.Add(sf);
                }
            }

            if (sipperFiles != null)
            {
                String lastCruise     = "";
                String lastStation    = "";
                String lastDeployment = "";
                String dirPath        = "";

                Dictionary <String, int> imagesPerClass = new Dictionary <string, int> ();

                foreach (PicesSipperFile sf in sipperFiles)
                {
                    bool startANewDir = false;
                    if (firstSipperFile)
                    {
                        startANewDir = true;
                    }

                    //else if   (sf.CruiseName != lastCruise)
                    //  startANewDir = true;

                    else if ((includeStationAndDeploymentInDirName) &&
                             ((sf.StationName != lastStation) || (sf.DeploymentNum != lastDeployment))
                             )
                    {
                        startANewDir = true;
                    }

                    if (startANewDir)
                    {
                        lastCruise     = sf.CruiseName;
                        lastStation    = sf.StationName;
                        lastDeployment = sf.DeploymentNum;
                        dirPath        = OSservices.AddSlash(DestinationDirectory.Text);

                        if (includeStationAndDeploymentInDirName)
                        {
                            if (!String.IsNullOrEmpty(lastCruise))
                            {
                                dirPath = OSservices.AddSlash(dirPath) + lastCruise;
                            }

                            if (!String.IsNullOrEmpty(lastStation))
                            {
                                dirPath = OSservices.AddSlash(dirPath) + lastStation;
                            }

                            if (!String.IsNullOrEmpty(lastDeployment))
                            {
                                dirPath = OSservices.AddSlash(dirPath) + lastDeployment;
                            }
                        }

                        OSservices.CreateDirectoryPath(dirPath);
                        imagesPerClass = new Dictionary <string, int> ();
                    }

                    SaveImagesForOneSipperFile(dirPath, sf, imagesPerClass);
                    firstSipperFile = false;
                }
            }
        } /* SaveImagesBySipperFiles */
예제 #8
0
        private void  ExtractDataFromSIPPERFile(String sipperFileName)
        {
            PicesRunLog   runLog = new PicesRunLog();
            PicesDataBase db     = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            PicesSipperFile sf = null;

            if (db == null)
            {
                sf     = new PicesSipperFile(sipperFileName);
                sf.Sp0 = configRec.HeaderRec().SerialPortShortName(0);
                sf.Sp1 = configRec.HeaderRec().SerialPortShortName(1);
                sf.Sp2 = configRec.HeaderRec().SerialPortShortName(2);
                sf.Sp3 = configRec.HeaderRec().SerialPortShortName(3);

                sf.CtdExt0 = configRec.HeaderRec().CtdExt0Code();
                sf.CtdExt1 = configRec.HeaderRec().CtdExt1Code();
                sf.CtdExt2 = configRec.HeaderRec().CtdExt2Code();
                sf.CtdExt3 = configRec.HeaderRec().CtdExt3Code();
            }
            else
            {
                sf = db.SipperFileRecLoad(OSservices.GetRootName(sipperFileName));
                if (sf == null)
                {
                    return;
                }
            }

            byte ctdSensorNum    = 0;
            byte pitchAndRollNum = 1;

            switch (sf.Sp0)
            {
            case  "CTD": ctdSensorNum = 16;  break;

            case  "P-R": pitchAndRollNum = 16;  break;
            }

            switch (sf.Sp1)
            {
            case  "CTD": ctdSensorNum = 17;  break;

            case  "P-R": pitchAndRollNum = 17;  break;
            }

            switch (sf.Sp2)
            {
            case  "CTD": ctdSensorNum = 18;  break;

            case  "P-R": pitchAndRollNum = 18;  break;
            }

            switch (sf.Sp3)
            {
            case  "CTD": ctdSensorNum = 19;  break;

            case  "P-R": pitchAndRollNum = 19;  break;
            }

            BinaryReader fs = null;

            try { fs = new BinaryReader(new FileStream(sipperFileName, FileMode.Open, FileAccess.Read, FileShare.Read)); }
            catch (Exception)  { fs = null; }
            if (fs == null)
            {
                return;
            }

            BuildDecodeRecs();

            bool   eof = false;
            ushort rec = 0;

            try  { rec = fs.ReadUInt16(); }  catch (Exception)  { eof = true; }
            while (!eof)
            {
                Sipper3DecodeRec dr = decodeRecs[rec];
                if (!dr.ImageData())
                {
                    if (dr.SensorNum() == ctdSensorNum)
                    {
                        AddToCTDData(dr.SensorData());
                    }

                    else if (dr.SensorNum() == pitchAndRollNum)
                    {
                        AddToPitchAndRollData(dr.SensorData());
                    }
                }


                try  { rec = fs.ReadUInt16(); }  catch (Exception)  { eof = true; }
            }
        } /* ExtractDataFromSIPPERFile */