/// <summary> /// Initialize the ImageSet by creating the master list of images, starting its background image loading thread, and then creating the master index that maps the organization of the dataset. /// </summary> /// <param name="bSilentLoad">Specifies to load the data silently without status output.</param> /// <param name="bUseUniqueLabelIndexes">Optionally, specifies to use unique label indexes which is slightly slower, but ensures each label is hit per epoch equally (default = true).</param> /// <param name="bUseUniqueImageIndexes">Optionally, specifies to use unique image indexes which is slightly slower, but ensures each image is hit per epoch (default = true).</param> /// <param name="nMaxLoadCount">Optionally, specifies to automaticall start the image refresh which only applies when the number of images loaded into memory is less than the actual number of images (default = false).</param> /// <returns>Once initialized, the default query state for the image set is returned. This method may be called multiple times and each time returns a new QueryState.</returns> public QueryState Initialize(bool bSilentLoad, bool bUseUniqueLabelIndexes = true, bool bUseUniqueImageIndexes = true, int nMaxLoadCount = 0) { if (m_masterList == null) { m_masterList = new MasterList(m_random, m_log, m_src, m_factory, m_rgAbort, nMaxLoadCount); if (OnCalculateImageMean != null) { m_masterList.OnCalculateImageMean += OnCalculateImageMean; } if (m_loadMethod == IMAGEDB_LOAD_METHOD.LOAD_ALL || m_loadMethod == IMAGEDB_LOAD_METHOD.LOAD_EXTERNAL || m_loadMethod == IMAGEDB_LOAD_METHOD.LOAD_ON_DEMAND_BACKGROUND) { m_masterList.Load(bSilentLoad); } } if (m_masterIdx == null || m_masterIdx.LoadLimit != nMaxLoadCount) { m_masterIdx = new MasterIndexes(m_random, m_src, nMaxLoadCount); } QueryState state = new QueryState(m_masterIdx, bUseUniqueLabelIndexes, bUseUniqueImageIndexes); if (m_loadMethod == IMAGEDB_LOAD_METHOD.LOAD_ALL) { m_masterList.WaitForLoadingToComplete(m_rgAbort); } return(state); }
/// <summary> /// The constructor. /// </summary> /// <param name="master">Specifies the MasterIndexes to copy.</param> /// <param name="bUseUniqueLabelIndexes">Optionally, specifies to use unique label indexes which is slightly slower, but ensures each label is hit per epoch equally (default = true).</param> /// <param name="bUseUniqueImageIndexes">Optionally, specifies to use unique image indexes which is slightly slower, but ensures each image is hit per epoch (default = true).</param> /// <param name="sort">Optionally, specifies the ordering to use on the indexes (default = BYIDX).</param> public QueryState(MasterIndexes master, bool bUseUniqueLabelIndexes = true, bool bUseUniqueImageIndexes = true, IMGDB_SORT sort = IMGDB_SORT.BYIDX) : base(master, sort) { m_master = master; m_stat = new LabelStats(master.LabelCount); m_bUseUniqueLabelIndexes = bUseUniqueLabelIndexes; m_bUseUniqueImageIndexes = bUseUniqueImageIndexes; foreach (LabelDescriptor label in m_src.Labels) { m_stat.Add(label); } }
/// <summary> /// The constructor used to copy another MasterIndexes and optionally specify a sorting for the indexes. /// </summary> /// <param name="idx">Specifies the MasterIndexes to copy.</param> /// <param name="sort">Optionally, specifies a sorting to use on the indexes.</param> public MasterIndexes(MasterIndexes idx, IMGDB_SORT sort) { m_sort = sort; m_src = idx.m_src; m_random = idx.m_random; m_nLoadLimit = idx.m_nLoadLimit; m_factory = new DatasetFactory(idx.m_factory); m_index = idx.m_index.Clone(sort); m_rgLabels = new LabelIndex(idx.m_rgLabels); m_boosted = idx.m_boosted.Clone(sort); m_rgLabelsBoosted = new LabelIndex(idx.m_rgLabelsBoosted); }
/// <summary> /// Releases the resouces used. /// </summary> /// <param name="bDisposing">Set to <i>true</i> when called by Dispose()</param> protected override void Dispose(bool bDisposing) { m_evtCancel.Set(); if (m_masterIdx != null) { m_masterIdx.Dispose(); m_masterIdx = null; } if (m_masterList != null) { m_masterList.Dispose(); m_masterList = null; } base.Dispose(bDisposing); }
/// <summary> /// Verify the loaded images against the master indexes. /// </summary> /// <param name="idx">Specifies the master indexes.</param> public void Verify(MasterIndexes idx) { if (idx.RawIndexes.Count != m_rgImages.Length) { throw new Exception("The index count should match the image count!"); } List <int> rgObservedIdx = new List <int>(); for (int i = 0; i < m_rgImages.Length; i++) { if (rgObservedIdx.Contains(m_rgImages[i].Index)) { throw new Exception("Duplicate image index found! Your dataset may be corrupt."); } if (idx.RawIndexes[i].Index != m_rgImages[i].Index) { throw new Exception("The image indexs do not match! You may need to re-index the image list."); } rgObservedIdx.Add(m_rgImages[i].Index); } }