Compare commits
No commits in common. "148896423fa11f14c1302c49ecaf1c18ae39078f" and "34fc28a0d8bcb59ee759e4c6449f5d65f7d61edd" have entirely different histories.
148896423f
...
34fc28a0d8
|
@ -10,7 +10,6 @@ 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;
|
||||||
|
@ -22,13 +21,11 @@ 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()
|
||||||
|
@ -48,6 +45,7 @@ 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))
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,53 +63,56 @@ namespace AIParkingApplication
|
||||||
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
||||||
if (cardInfoResult.IsValid)
|
if (cardInfoResult.IsValid)
|
||||||
{
|
{
|
||||||
if (cardInfoResult.Direction == "in")
|
plateCamera.RequestCaptureOneFrame();
|
||||||
|
overviewCamera.RequestCaptureOneFrame();
|
||||||
|
await Task.Delay(200);
|
||||||
|
var plateVideoFrame = plateCamera.CurrentFrame;
|
||||||
|
var overviewVideoFrame = overviewCamera.CurrentFrame;
|
||||||
|
|
||||||
|
pictureBoxOverviewImage.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
plateCamera.RequestCaptureOneFrame();
|
pictureBoxOverviewImage.Image?.Dispose();
|
||||||
overviewCamera.RequestCaptureOneFrame();
|
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
|
||||||
await Task.Delay(200);
|
}));
|
||||||
|
|
||||||
var plateVideoFrame = plateCamera.CurrentFrame;
|
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
||||||
FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode);
|
|
||||||
pictureBoxPlateImage.Invoke(new Action(() =>
|
pictureBoxPlateImage.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
pictureBoxPlateImage.Image?.Dispose();
|
||||||
|
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
|
||||||
|
}));
|
||||||
|
|
||||||
|
var cardInformation = await apiController.GetCardInformation(cardNumber);
|
||||||
|
|
||||||
|
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
||||||
|
|
||||||
|
//TODO check saveLogResult
|
||||||
|
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
|
||||||
|
if (saveLogResult.Status)
|
||||||
|
{
|
||||||
|
if (isAutoOpenDoor)
|
||||||
{
|
{
|
||||||
pictureBoxPlateImage.Image?.Dispose();
|
if (this.doorId == doorId)
|
||||||
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
|
|
||||||
}));
|
|
||||||
|
|
||||||
var overviewVideoFrame = overviewCamera.CurrentFrame;
|
|
||||||
pictureBoxOverviewImage.Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
pictureBoxOverviewImage.Image?.Dispose();
|
|
||||||
pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap();
|
|
||||||
}));
|
|
||||||
|
|
||||||
var cardInformation = await apiController.GetCardInformation(cardNumber);
|
|
||||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
|
||||||
|
|
||||||
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
|
|
||||||
if (saveLogResult.Status)
|
|
||||||
{
|
|
||||||
if (isAutoOpenDoor && this.doorId == doorId)
|
|
||||||
{
|
{
|
||||||
OpenDoor(doorId);
|
var openDoorResult = c3Device.OpenDoor(doorId);
|
||||||
|
if (openDoorResult.HasError)
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
lblRecogizePlateStatus.BackColor = Color.Red;
|
||||||
|
lblRecogizePlateStatus.Text = "KHÔNG THỂ MỞ CỬA";
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
lblRecogizePlateStatus.Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
lblRecogizePlateStatus.BackColor = Color.Red;
|
|
||||||
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ";
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lblRecogizePlateStatus.Invoke(new Action(() =>
|
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
lblRecogizePlateStatus.BackColor = Color.Red;
|
lblRecogizePlateStatus.BackColor = Color.Red;
|
||||||
lblRecogizePlateStatus.Text = "THẺ ĐÃ ĐƯỢC SỬ DỤNG";
|
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ";
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,18 +144,6 @@ namespace AIParkingApplication
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenDoor(int doorId)
|
|
||||||
{
|
|
||||||
if (c3Device.OpenDoor(doorId).HasError)
|
|
||||||
{
|
|
||||||
lblRecogizePlateStatus.Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
lblRecogizePlateStatus.BackColor = Color.Red;
|
|
||||||
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI TỚI THIẾT BỊ MỞ CỬA";
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -23,11 +23,6 @@ namespace AIParkingApplication
|
||||||
plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
|
plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
~PlateDetector()
|
|
||||||
{
|
|
||||||
plateCascadeClassifier?.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mat DetectPlate(Mat frame)
|
public Mat DetectPlate(Mat frame)
|
||||||
{
|
{
|
||||||
Rect[] plateRectsDetected = plateCascadeClassifier.DetectMultiScale(frame, scaleFactor, minNeighbors, HaarDetectionType.ScaleImage, minSizePlate, maxSizePlate);
|
Rect[] plateRectsDetected = plateCascadeClassifier.DetectMultiScale(frame, scaleFactor, minNeighbors, HaarDetectionType.ScaleImage, minSizePlate, maxSizePlate);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user