示例#1
0
        /// <summary>
        /// The AnnotatedDataLayer constructor.
        /// </summary>
        /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param>
        /// <param name="log">Specifies the Log for output.</param>
        /// <param name="p">provides LayerParameter annotated_data_param.</param>
        /// <param name="db">Specifies the external database to use.</param>
        /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param>
        public AnnotatedDataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabase db, CancelEvent evtCancel)
            : base(cuda, log, p, db, evtCancel)
        {
            m_type = LayerParameter.LayerType.ANNOTATED_DATA;

            Tuple <IMGDB_LABEL_SELECTION_METHOD, IMGDB_IMAGE_SELECTION_METHOD> kvSel = db.GetSelectionMethod();
            IMGDB_IMAGE_SELECTION_METHOD imgSel = kvSel.Item2;

            if (m_param.data_param.enable_pair_selection.HasValue)
            {
                if (m_param.data_param.enable_pair_selection.Value)
                {
                    imgSel |= IMGDB_IMAGE_SELECTION_METHOD.PAIR;
                }
                else
                {
                    imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.PAIR);
                }
            }

            if (m_param.data_param.enable_random_selection.HasValue)
            {
                if (m_param.data_param.enable_random_selection.Value)
                {
                    imgSel |= IMGDB_IMAGE_SELECTION_METHOD.RANDOM;
                }
                else
                {
                    imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.RANDOM);
                }
            }

            db.SetSelectionMethod(null, imgSel);

            m_db = new data.DB(db);
            m_db.Open(p.data_param.source);
            m_cursor = m_db.NewCursor();

            if (p.data_param.display_timing)
            {
                m_swTimerBatch       = new Stopwatch();
                m_swTimerTransaction = new Stopwatch();
            }
        }
示例#2
0
        /// <summary>
        /// The AnnotatedDataLayer constructor.
        /// </summary>
        /// <param name="cuda">Specifies the CudaDnn connection to Cuda.</param>
        /// <param name="log">Specifies the Log for output.</param>
        /// <param name="p">provides LayerParameter annotated_data_param.</param>
        /// <param name="db">Specifies the external database to use.</param>
        /// <param name="evtCancel">Specifies the CancelEvent used to cancel any pre-fetching operations.</param>
        public AnnotatedDataLayer(CudaDnn <T> cuda, Log log, LayerParameter p, IXImageDatabase db, CancelEvent evtCancel)
            : base(cuda, log, p, db, evtCancel)
        {
            m_type = LayerParameter.LayerType.ANNOTATED_DATA;

            Tuple <IMGDB_LABEL_SELECTION_METHOD, IMGDB_IMAGE_SELECTION_METHOD> kvSel = db.GetSelectionMethod();
            IMGDB_IMAGE_SELECTION_METHOD imgSel = kvSel.Item2;

            if (m_param.data_param.enable_pair_selection.HasValue)
            {
                if (m_param.data_param.enable_pair_selection.Value)
                {
                    imgSel |= IMGDB_IMAGE_SELECTION_METHOD.PAIR;
                }
                else
                {
                    imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.PAIR);
                }
            }

            if (m_param.data_param.enable_random_selection.HasValue)
            {
                if (m_param.data_param.enable_random_selection.Value)
                {
                    imgSel |= IMGDB_IMAGE_SELECTION_METHOD.RANDOM;
                }
                else
                {
                    imgSel &= (~IMGDB_IMAGE_SELECTION_METHOD.RANDOM);
                }
            }

            if (!db.GetLoadImageDataCriteria())
            {
                m_log.WriteError(new Exception("The 'Load Image Data Criteria' must be set to TRUE in order to load the Annotation data."));
            }

            db.SetSelectionMethod(null, imgSel);

            m_db = new data.DB(db);
            m_db.Open(p.data_param.source);
            m_cursor = m_db.NewCursor();

            if (p.data_param.display_timing)
            {
                m_swTimerBatch       = new Stopwatch();
                m_swTimerTransaction = new Stopwatch();
            }

            m_sampler = new SsdSampler <T>(cuda, log);
        }