예제 #1
0
 public State(int index, RawFrameHandler rawFrameHandler, RawFrame frame, FrameDecoder decoder, IntPtr buffer)
 {
     Index           = index;
     RawFrameHandler = rawFrameHandler;
     Frame           = frame;
     Decoder         = decoder;
     Buffer          = buffer;
 }
예제 #2
0
 private static void DecoderThread(int index, RawFrameHandler handler, string source, CancellationToken ct)
 {
     using var decoder = new RawVideoDecoder(source, handler, index);
     try
     {
         decoder.ProcessingLoop(ct);
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine($"Error in decoder thread: {ex}");
     }
     finally
     {
         Console.WriteLine("Processing finished");
         handler.Finished(index);
     }
 }
예제 #3
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}");
            }
        }