LaneIn - Add TryCatch For Methods: OverviewCamera_OnOneVideoFrameRequested, PlateCamera_OnOneVideoFrameRequested, OverviewCameraOnVideoFrameReceived, PlateCameraOnVideoFrameReceived

This commit is contained in:
DucDangAnh 2020-06-19 10:13:22 +07:00
parent 2caffc6adf
commit 2bd45cf43f

View File

@ -15,7 +15,8 @@ namespace AIParkingApplication
public LaneIn() public LaneIn()
{ {
InitializeComponent(); InitializeComponent();
string overviewCameraVideo = @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"; //@"C:\HS_test.mp4" string overviewCameraVideo = @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
//string overviewCameraVideo = @"C:\HS_test.mp4";
string plateCameraVideo = @"C:\HS_test.mp4"; string plateCameraVideo = @"C:\HS_test.mp4";
//string plateCameraVideo = @"C:\CongRa_1.mp4"; //string plateCameraVideo = @"C:\CongRa_1.mp4";
@ -35,6 +36,8 @@ namespace AIParkingApplication
} }
private void OverviewCamera_OnOneVideoFrameRequested(Mat videoFrame) private void OverviewCamera_OnOneVideoFrameRequested(Mat videoFrame)
{
try
{ {
pictureBoxOverviewImage.Invoke(new Action(() => pictureBoxOverviewImage.Invoke(new Action(() =>
{ {
@ -42,10 +45,17 @@ namespace AIParkingApplication
pictureBoxOverviewImage.Image = videoFrame.ToBitmap(); pictureBoxOverviewImage.Image = videoFrame.ToBitmap();
})); }));
} }
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
}
private void PlateCamera_OnOneVideoFrameRequested(Mat videoFrame) private void PlateCamera_OnOneVideoFrameRequested(Mat videoFrame)
{ {
Task.Factory.StartNew(new Action(async () => Task.Factory.StartNew(new Action(async () =>
{
try
{ {
var finalPlateResult = await plateProcessor.ProcessPlate(videoFrame); var finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
@ -59,10 +69,17 @@ namespace AIParkingApplication
pictureBoxPlateImage.Image?.Dispose(); pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = finalPlateResult.PlateImage; pictureBoxPlateImage.Image = finalPlateResult.PlateImage;
})); }));
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
})); }));
} }
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame) private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)
{
try
{ {
pictureBoxOverviewVideo.Invoke(new Action(() => pictureBoxOverviewVideo.Invoke(new Action(() =>
{ {
@ -70,8 +87,15 @@ namespace AIParkingApplication
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap(); pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
})); }));
} }
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
}
private void PlateCameraOnVideoFrameReceived(Mat videoFrame) private void PlateCameraOnVideoFrameReceived(Mat videoFrame)
{
try
{ {
pictureBoxPlateVideo.Invoke(new Action(() => pictureBoxPlateVideo.Invoke(new Action(() =>
{ {
@ -79,6 +103,11 @@ namespace AIParkingApplication
pictureBoxPlateVideo.Image = videoFrame.ToBitmap(); pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
})); }));
} }
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
}
private void CaptureAllCamera() private void CaptureAllCamera()
{ {