} /* SaveImagesBySipperFiles */ private void SaveImagesForOneSipperFile(String dirPath, PicesSipperFile sf, Dictionary <string, int> imagesPerClass ) { uint lastImageId = 0; sipperFileName = sf.SipperFileName; while (!cancelRequested) { int limit = -1; if (mlClass == null) { // With out the Class Key; mySql will probably not be able to restart the query from a known spot and // get all the images that is intended. So in this case we want to retrieve all images that meet the // criteria from this SIPPER file. limit = -1; } PicesDataBaseImageList nextBunch = dbConn.ImagesQuery (null, // ImageGroup sipperFileName, mlClass, classKeyToUse, probMin, probMax, sizeMin, sizeMax, depthMin, depthMax, lastImageId, limit, false // false = Don't load Thumbnail images. ); if ((nextBunch == null) || (nextBunch.Count < 1)) { break; } SaveOneBatchOfImages(dirPath, imagesPerClass, nextBunch); lastImageId = nextBunch[nextBunch.Count - 1].ImageId; nextBunch = null; if ((nextBunch == null) || (nextBunch.Count < limit) || (limit < 0)) { // Since we loaded less images than 'limit' was set for we are done loading images from this sipperFileName. break; } nextBunch = null; } } /* SaveImagesForOneSipperFile */
} /* SaveSampleImages */ private PicesDataBaseImageList RetrievePlanktonDataBySipperFiles() { PicesDataBaseImageList data = new PicesDataBaseImageList(); String[] sipperFileNames = null; if (String.IsNullOrEmpty(sipperFileName)) { sipperFileNames = dbConn.SipperFileGetList(cruise, station, deployment); } else { sipperFileNames = new String[1]; sipperFileNames[0] = sipperFileName; } if (sipperFileNames != null) { for (int idx = 0; (idx < sipperFileNames.Length) && (!cancelRequested); idx++) { String curSipperFileName = sipperFileNames[idx]; backGroundStatus = "Loading[" + (idx + 1).ToString() + " of " + sipperFileNames.Length.ToString() + "] File[" + curSipperFileName + "]"; PicesDataBaseImageList dataThisSipperFile = dbConn.ImagesQuery(null, curSipperFileName, mlClass, classKeyToUse, probMin, probMax, sizeMin, sizeMax, depthMin, depthMax, 0, // Restart ImageId -1, // limit (Max number of images). false // false = Do not include Thumbnail. ); if (dataThisSipperFile != null) { imagesLoaded += (uint)dataThisSipperFile.Count; foreach (PicesDataBaseImage i in dataThisSipperFile) { data.Add(i); } } } } return(data); } /* RetrievePlanktonDataBySipperFiles */
} /* CancelHarvestingProcess */ private List <ImageEntry> LoadAllImages(PicesDataBase threadConn) { RunLogAddMsg("Loading Source Images\n"); List <ImageEntry> allImages = new List <ImageEntry> (); foreach (String sipperFileName in sipperFileNames) { if (cancelHarvesting) { break; } RunLogAddMsg("Loading Sipper File[" + sipperFileName + "]" + "\n"); PicesDataBaseImageList images = threadConn.ImagesQuery(null, // ImageGroup sipperFileName, selClass, // classKeyToUse, // 0.0f, 1.0f, // Prob Min and Max sizeMin, sizeMax, // Size Min and Max 0, 0, // Depth Min and Max 0, // restartImageFileName -1, // limit to load -1 = Load All false // false = Don't load thumbnail ); if (images == null) { RunLogAddMsg("Loading Sipper File[" + sipperFileName + "] No images found in database." + "\n"); } else { foreach (PicesDataBaseImage i in images) { float depth = i.Depth; if (depth >= minimumDepth) { allImages.Add(new ImageEntry(i.ImageId, depth)); } } RunLogAddMsg("Loading Sipper File[" + sipperFileName + "] [" + images.Count.ToString("##,###,##0") + "] Loaded" + "\n"); } } return(allImages); } /* LoadAllImages */
} /* LoadImagesForSelectedGroup */ private void LoadImagesForOneSipperFile(String sipperFileName) { curSipperFileName = sipperFileName; uint lastImageId = restartImageId; while (!cancelRequested) { int limit = 100; if (mlClass == null) { // With out the Class Key; mySql will probably not be able to restart the query from a know spot and // get all the images that is intended. So in this case we want to retrieve all images that meet the // criteria from this SIPPER file. limit = -1; } PicesDataBaseImageList nextBunch = dbConn.ImagesQuery (null, // ImageGroup sipperFileName, mlClass, classKeyToUse, probMin, probMax, sizeMin, sizeMax, depthMin, depthMax, lastImageId, limit, true // Load Thumbnail image also. ); if ((nextBunch == null) || (nextBunch.Count < 1)) { return; } blocker.StartBlock(); if (loadedImages == null) { loadedImages = new PicesDataBaseImageList(); } uint largestImageId = nextBunch[0].ImageId; foreach (PicesDataBaseImage i in nextBunch) { if (i.ImageId != lastImageId) { loadedImages.Add(i); imagesLoadedCount++; } if (i.ImageId > largestImageId) { largestImageId = i.ImageId; } } lastImageId = largestImageId; blocker.EndBlock(); if ((nextBunch.Count < limit) || (limit < 0)) { // Sine we loaded less images than 'limit' was set for we are done loading images from this sipperFileName. break; } nextBunch = null; } curSipperFileName = ""; } /* LoadImagesForOneSipperFile */