LaneIn - Remove using Task For Event: PlateCamera_OnOneVideoFrameRequested

This commit is contained in:
DucDangAnh 2020-06-25 11:03:03 +07:00
parent a7fe049f15
commit 7529efa6d2

View File

@ -106,45 +106,42 @@ namespace AIParkingApplication
}
}
private void PlateCamera_OnOneVideoFrameRequested(Mat videoFrame)
private async void PlateCamera_OnOneVideoFrameRequested(Mat videoFrame)
{
Task.Factory.StartNew(new Action(async () =>
try
{
try
{
//TODO: check size before resizing
Cv2.Resize(videoFrame, videoFrame, new Size(1280, 720));
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
//TODO: check size before resizing
Cv2.Resize(videoFrame, videoFrame, new Size(1280, 720));
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
{
if (isRetryModeUntilOk) //TODO: TestMode
{
if (isRetryModeUntilOk) //TODO: TestMode
{
Thread.Sleep(500);
CaptureAllCamera();
}
else
{
Console.WriteLine("PlateCamera_OnOneVideoFrameRequested Retry Mode");
Thread.Sleep(1000);
overviewCamera.RequestCaptureOneFrame();
finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
}
Thread.Sleep(500);
CaptureAllCamera();
}
pictureBoxPlateImage.Invoke(new Action(() =>
else
{
pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = finalPlateResult.PlateImage;
}));
Console.WriteLine("PlateCamera_OnOneVideoFrameRequested Retry Mode");
Thread.Sleep(1000);
overviewCamera.RequestCaptureOneFrame();
finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
}
}
ShowCardInfoOnUI("224", finalPlateResult.PlateString, "Thẻ tháng", DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
}
catch (Exception ex)
pictureBoxPlateImage.Invoke(new Action(() =>
{
Console.WriteLine($"PlateCamera_OnOneVideoFrameRequested\texMessage: {ex.Message}");
}
}));
pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = finalPlateResult.PlateImage;
}));
ShowCardInfoOnUI("224", finalPlateResult.PlateString, "Thẻ tháng", DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
}
catch (Exception ex)
{
Console.WriteLine($"PlateCamera_OnOneVideoFrameRequested\texMessage: {ex.Message}");
}
}
public void Stop()