示例#1
0
        public BatchedCameraWatcherService(ILogger <BatchedCameraWatcherService> logger,
                                           IBatchedDnnDetector detector,
                                           MultiStreamBatchedProcessorPipeline pipeline,
                                           IHostApplicationLifetime appLifetime,
                                           IConfiguration configRoot)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (detector is null)
            {
                throw new ArgumentNullException(nameof(detector));
            }
            if (pipeline is null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            if (appLifetime is null)
            {
                throw new ArgumentNullException(nameof(appLifetime));
            }
            if (configRoot is null)
            {
                throw new ArgumentNullException(nameof(configRoot));
            }

            _logger      = logger;
            _appLifetime = appLifetime;
            _detector    = detector;
            _pipeline    = pipeline;
        }
        public MultiStreamBatchedProcessorPipeline([DisallowNull] ILogger <MultiStreamBatchedProcessorPipeline> logger,
                                                   [DisallowNull] IConfiguration configuration,
                                                   IBatchedDnnDetector detector,
                                                   IEnumerable <IAsyncSingleResultProcessor> resultProcessors)
        {
            if (logger is null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (configuration is null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (resultProcessors is null)
            {
                throw new ArgumentNullException(nameof(resultProcessors));
            }
            if (detector is null)
            {
                throw new ArgumentNullException(nameof(detector));
            }

            _logger           = logger;
            _configuration    = configuration;
            _detector         = detector;
            _resultProcessors = new List <IAsyncSingleResultProcessor>(resultProcessors);

            _streamsConfig = _configuration.GetSection(VideoStreamsConfigCollection.VideoStreamsConfigKey).Get <VideoStreamsConfigCollection>();

            _logger.LogInformation("Loaded configuration for {numberOfStreams} streams:{streamIds}",
                                   _streamsConfig.Count,
                                   String.Join(",", _streamsConfig.Select(s => s.Id)));
        }
        public MultiStreamBatchedProcessorPipeline([DisallowNull] ILogger <MultiStreamBatchedProcessorPipeline> logger,
                                                   IOptions <VideoStreamsOptions> options,
                                                   IOptions <DetectionOptions> detectionOptions,
                                                   HeartbeatHealthCheck <MultiStreamBatchedProcessorPipeline> healthCheck,
                                                   IBatchedDnnDetector detector,
                                                   IEnumerable <IAsyncSingleResultProcessor> resultProcessors) :
            base(logger, options)
        {
            if (resultProcessors is null)
            {
                throw new ArgumentNullException(nameof(resultProcessors));
            }
            if (detector is null)
            {
                throw new ArgumentNullException(nameof(detector));
            }
            if (healthCheck is null)
            {
                throw new ArgumentNullException(nameof(healthCheck));
            }

            _detector         = detector;
            _resultProcessors = new List <IAsyncSingleResultProcessor>(resultProcessors);
            _healthCheck      = healthCheck;

            _streamsConfig    = Options;
            _detectionOptions = GetValidatedOptions(detectionOptions);

            Logger.LogInformation("Loaded configuration for {numberOfStreams} streams:{streamIds}",
                                  _streamsConfig.Count,
                                  String.Join(",", _streamsConfig.Select(s => s.Id)));
        }
        public DnnDetectorChannelTransformer(IBatchedDnnDetector detector,
                                             ChannelReader <IList <VideoFrame> > inputReader, ChannelWriter <AnalysisResult> outputWriter,
                                             ILogger logger) :
            base(inputReader, outputWriter, logger)
        {
            if (detector is null)
            {
                throw new ArgumentNullException(nameof(detector));
            }

            _detector = detector;
            _detector.Initialize();

            SetTransformer(this.DoAnalyzeFrames);
        }
        public DnnDetectorChannelTransformer(IBatchedDnnDetector detector,
                                             float detectionThreshold,
                                             ChannelReader <IList <VideoFrame> > inputReader,
                                             ChannelWriter <IList <VideoFrame> > outputWriter,
                                             IHeartbeatReporter heartbeatReporter,
                                             ILogger logger) :
            base(inputReader, outputWriter, logger)
        {
            if (detector is null)
            {
                throw new ArgumentNullException(nameof(detector));
            }
            if (heartbeatReporter is null)
            {
                throw new ArgumentNullException(nameof(heartbeatReporter));
            }

            _detectionThreshold = detectionThreshold;
            _heartbeatReporter  = heartbeatReporter;
            _detector           = detector;
            _detector.Initialize();
        }