Esempio n. 1
0
        public void Stop()
        {
            if (!Running)
            {
                return;
            }
            lock (myLock)
            {
                if (!Running)
                {
                    return;
                }

                Running = false;

                streamingCancelTokenSource?.Cancel();
                StreamingThread?.Abort();
                ImageProcessingThread?.Abort();

                while (!FrameQueue.IsEmpty && FrameQueue.TryDequeue(out SpeedometerFrame f))
                {
                    f.Frame.Dispose();
                }

                speedMeasurer = null;

                OnStop(this, null);
            }
        }
Esempio n. 2
0
        public void Start()
        {
            if (Running)
            {
                return;
            }
            lock (myLock)
            {
                if (Running)
                {
                    return;
                }

                Running = true;

                lastReportedSpeedKPH = null;

                while (!FrameQueue.IsEmpty && FrameQueue.TryDequeue(out SpeedometerFrame f))
                {
                    f.Frame.Dispose();
                }

                streamingCancelTokenSource = new CancellationTokenSource();

                speedMeasurer = new SpeedMeasurer();
                speedMeasurer.HighlightTrackedObjects = HighlightTrackedObjects;

                StreamingThread = new Thread(streamingThreadLoop);
                StreamingThread.IsBackground = true;
                StreamingThread.Name         = "Stream";
                StreamingThread.Start();

                ImageProcessingThread = new Thread(imageProcessingThreadLoop);
                ImageProcessingThread.IsBackground = true;
                ImageProcessingThread.Name         = "ImgProc";
                ImageProcessingThread.Start();
            }
        }