Camera - use videoCapture as a field.
This commit is contained in:
parent
5259eba6b5
commit
f63da8a968
|
@ -10,6 +10,7 @@ namespace AIParkingApplication
|
||||||
private string streamUrl;
|
private string streamUrl;
|
||||||
private volatile bool isFrameRequested;
|
private volatile bool isFrameRequested;
|
||||||
private Thread readStreamThread;
|
private Thread readStreamThread;
|
||||||
|
private VideoCapture videoCapture;
|
||||||
public volatile Mat CurrentFrame;
|
public volatile Mat CurrentFrame;
|
||||||
|
|
||||||
public event CameraEvent OnVideoFrameReceived;
|
public event CameraEvent OnVideoFrameReceived;
|
||||||
|
@ -21,11 +22,13 @@ namespace AIParkingApplication
|
||||||
isFrameRequested = false;
|
isFrameRequested = false;
|
||||||
readStreamThread = new Thread(new ThreadStart(ReadVideoStream));
|
readStreamThread = new Thread(new ThreadStart(ReadVideoStream));
|
||||||
readStreamThread.IsBackground = true;
|
readStreamThread.IsBackground = true;
|
||||||
|
videoCapture = new VideoCapture();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Camera()
|
~Camera()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
videoCapture.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
|
@ -45,7 +48,6 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
public void ReadVideoStream()
|
public void ReadVideoStream()
|
||||||
{
|
{
|
||||||
VideoCapture videoCapture = new VideoCapture(); //TODO: Need to dispose this videoCapture?
|
|
||||||
Mat videoFrame = new Mat();
|
Mat videoFrame = new Mat();
|
||||||
if (!videoCapture.Open(streamUrl))
|
if (!videoCapture.Open(streamUrl))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user