Esempio n. 1
0
        public static async Task Main()
        {
            try
            {
                Console.WriteLine($"API = {InferenceEngineLibrary.GetApiVersion()}");

                using var cts = new CancellationTokenSource();
                var ct = cts.Token;

                using var detector = new Detector(@"C:\Users\nickr\Documents\Intel\OpenVINO\openvino_models\intel\face-detection-0104\FP16\face-detection-0104.xml");
                DumpCoreInformation(detector.Core);

                var boundedOptions = new BoundedChannelOptions(MaxFrames)
                {
                    AllowSynchronousContinuations = false, SingleReader = true, SingleWriter = true
                };
                var emptyChannel     = Channel.CreateBounded <RawFrame>(boundedOptions);
                var populatedChannel = Channel.CreateBounded <RawFrame>(boundedOptions);

                var decoderThread = new Thread(() => DecoderThread(emptyChannel.Reader, populatedChannel.Writer, ct));
                decoderThread.Start();

                await detector.ProcessAsync(populatedChannel.Reader, emptyChannel.Writer, "GPU", ct);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex}");
            }
        }
Esempio n. 2
0
        public static async Task Main()
        {
            try
            {
                Console.WriteLine($"API = {InferenceEngineLibrary.GetApiVersion()}");

                using var cts = new CancellationTokenSource();
                var ct = cts.Token;

                using var detector = await Detector.LoadAsync(@"C:\Users\nickr\Documents\Intel\OpenVINO\openvino_models\intel\person-vehicle-bike-detection-crossroad-1016\FP16\person-vehicle-bike-detection-crossroad-1016.xml", ct);

                //using var detector = new Detector(@"C:\Users\nickr\Documents\Intel\OpenVINO\openvino_models\intel\person-vehicle-bike-detection-crossroad-1016\FP16\person-vehicle-bike-detection-crossroad-1016.xml");
                //using var detector = new Detector(@"C:\Users\nickr\Documents\Intel\OpenVINO\openvino_models\intel\face-detection-0104\FP16\face-detection-0104.xml");
                //using var detector = new Detector(@"C:\Users\nickr\Documents\Intel\OpenVINO\openvino_models\intel\face-detection-0104\FP32\face-detection-0104.xml");
                DumpCoreInformation(detector.Core);

                var source = SourceFeeds;
                detector.Initialise("GPU");

                var decoderThreads = source
                                     .Select((source, index) =>
                {
                    var handler = new RawFrameHandler(index, blocking: false);
                    var thread  = new Thread(() => DecoderThread(index, handler, source, ct))
                    {
                        Priority = ThreadPriority.AboveNormal,
                    };
                    thread.Start();
                    return(thread, handler);
                })
                                     .ToArray();

                var handlers = decoderThreads.Select(v => v.handler).ToArray();
                await detector.ProcessAsync(handlers, ct);

                Console.WriteLine("Finished");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex}");
            }
        }