From f63da8a968d80b5825445a5ba980faca92dda89d Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Mon, 29 Jun 2020 15:02:31 +0700 Subject: [PATCH] Camera - use videoCapture as a field. --- AIParkingApplication/Camera.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AIParkingApplication/Camera.cs b/AIParkingApplication/Camera.cs index 0d4c5ec..bef745d 100644 --- a/AIParkingApplication/Camera.cs +++ b/AIParkingApplication/Camera.cs @@ -10,6 +10,7 @@ namespace AIParkingApplication private string streamUrl; private volatile bool isFrameRequested; private Thread readStreamThread; + private VideoCapture videoCapture; public volatile Mat CurrentFrame; public event CameraEvent OnVideoFrameReceived; @@ -21,11 +22,13 @@ namespace AIParkingApplication isFrameRequested = false; readStreamThread = new Thread(new ThreadStart(ReadVideoStream)); readStreamThread.IsBackground = true; + videoCapture = new VideoCapture(); } ~Camera() { Stop(); + videoCapture.Dispose(); } public void Start() @@ -45,7 +48,6 @@ namespace AIParkingApplication public void ReadVideoStream() { - VideoCapture videoCapture = new VideoCapture(); //TODO: Need to dispose this videoCapture? Mat videoFrame = new Mat(); if (!videoCapture.Open(streamUrl)) {