diff --git a/AIParkingApplication/Camera.cs b/AIParkingApplication/Camera.cs index c357559..18dc6b3 100644 --- a/AIParkingApplication/Camera.cs +++ b/AIParkingApplication/Camera.cs @@ -20,9 +20,9 @@ namespace AIParkingApplication { this.streamUrl = streamUrl; isFrameRequested = false; + videoCapture = new VideoCapture(); readStreamThread = new Thread(new ThreadStart(ReadVideoStream)); readStreamThread.IsBackground = true; - videoCapture = new VideoCapture(); } ~Camera() @@ -48,13 +48,13 @@ namespace AIParkingApplication public void ReadVideoStream() { - Mat videoFrame = new Mat(); if (!videoCapture.Open(streamUrl)) { OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH)); return; } + Mat videoFrame = new Mat(); while (true) { Thread.Sleep(50); //Stream Thread Sleep @@ -69,6 +69,10 @@ namespace AIParkingApplication isFrameRequested = false; } } + else + { + OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH)); + } } }