Compare commits
No commits in common. "5bcea0ba3fcbb8a288286f9c291b9bf241584c00" and "963bba78a8e31f8347415985e44e3b7074f3ba7f" have entirely different histories.
5bcea0ba3f
...
963bba78a8
|
@ -80,7 +80,6 @@
|
|||
<Compile Include="AppConstant.cs" />
|
||||
<Compile Include="C3DeviceController.cs" />
|
||||
<Compile Include="Camera.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="ILane.cs" />
|
||||
<Compile Include="LaneIn.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
|
|
@ -12,6 +12,18 @@ namespace AIParkingApplication
|
|||
private bool isHttpClientDisposabled;
|
||||
private int numberOfRetry;
|
||||
|
||||
public enum LaneDirection
|
||||
{
|
||||
In,
|
||||
Out
|
||||
}
|
||||
|
||||
public enum ModePlate
|
||||
{
|
||||
Sqare,
|
||||
Long
|
||||
}
|
||||
|
||||
public ApiController(string baseAddress, int numberOfRetry = 5)
|
||||
{
|
||||
httpClient = new HttpClient
|
||||
|
@ -28,6 +40,7 @@ namespace AIParkingApplication
|
|||
Dispose();
|
||||
}
|
||||
|
||||
//TODO Old API
|
||||
public async Task<LoginDataModel> Login(LoginModel loginData)
|
||||
{
|
||||
try
|
||||
|
@ -39,7 +52,7 @@ namespace AIParkingApplication
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Login Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
||||
Console.WriteLine($"SendEngineRequest : {ex.Message}");
|
||||
return new LoginDataModel
|
||||
{
|
||||
IsLoginSuccess = false
|
||||
|
@ -53,27 +66,43 @@ namespace AIParkingApplication
|
|||
{
|
||||
HttpResponseMessage response = await httpClient.GetAsync("/api/statistics");
|
||||
response.EnsureSuccessStatusCode();
|
||||
Statistic.ParkInfo parkingInfo = await response.Content.ReadAsAsync<Statistic.ParkInfo>();
|
||||
Statistic.ParkInfo parkInfo = await response.Content.ReadAsAsync<Statistic.ParkInfo>();
|
||||
|
||||
if (string.IsNullOrEmpty(parkingInfo.TotalIn))
|
||||
if (string.IsNullOrEmpty(parkInfo.TotalIn))
|
||||
{
|
||||
parkingInfo.TotalIn = "0";
|
||||
parkInfo.TotalIn = "0";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(parkingInfo.TotalOut))
|
||||
if (string.IsNullOrEmpty(parkInfo.TotalOut))
|
||||
{
|
||||
parkingInfo.TotalOut = "0";
|
||||
parkInfo.TotalOut = "0";
|
||||
}
|
||||
return parkingInfo;
|
||||
return parkInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
||||
Console.WriteLine($"SendApiStatisticRequest : {ex.Message}");
|
||||
return new Statistic.ParkInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CardInformation> GetCardInformation(string cardNumber)
|
||||
public async void GetApiPathFromServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = new PlateRequestEngineModel
|
||||
{
|
||||
};
|
||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/get-from-frame", request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"SendEngineRequest : {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CardValidation> CheckCard(string cardNumber)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -83,18 +112,18 @@ namespace AIParkingApplication
|
|||
};
|
||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/check-card", request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var cardValication = await response.Content.ReadAsAsync<CardInformation>();
|
||||
var cardValication = await response.Content.ReadAsAsync<CardValidation>();
|
||||
return cardValication;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
||||
return new CardInformation();
|
||||
Console.WriteLine($"SendCheckCardRequest : {ex.Message}");
|
||||
return new CardValidation();
|
||||
}
|
||||
}
|
||||
|
||||
//Neu Dicrection la Out thi logID la logID lay ve khi check the
|
||||
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat PlateFrameImage, Mat FrameImage, string logID = "")
|
||||
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, ModePlate squareOrLong, string timeInOrOut, string textPlate, Mat plateImage, Mat plateImageResult, Mat PlateFrameImage, Mat FrameImage, string logID = "")
|
||||
{
|
||||
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
|
||||
string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes());
|
||||
|
@ -104,13 +133,13 @@ namespace AIParkingApplication
|
|||
{
|
||||
var request = new SaveLogModel
|
||||
{
|
||||
Direction = direction == LaneDirection.In ? "in" : "out",
|
||||
Direction = (direction == LaneDirection.In) ? "in" : "out",
|
||||
LogID = logID,
|
||||
CardID = cardID,
|
||||
TextPlate = plateString,
|
||||
TextPlate = textPlate,
|
||||
CameraID = cameraID,
|
||||
ModePlate = plateType == PlateType.Square ? "1":"0",
|
||||
Timestamp = timestamp,
|
||||
ModePlate = (squareOrLong == ModePlate.Sqare) ? "1":"0",
|
||||
TimeVehicleInOrOut = timeInOrOut,
|
||||
PlateImage = plateImageBase64,
|
||||
PlateResultImage = plateImageResultBase64,
|
||||
PlateFrameImage = PlateFrameImageBase64,
|
||||
|
@ -124,7 +153,7 @@ namespace AIParkingApplication
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)} \t {ex.Message}");
|
||||
Console.WriteLine($"SendSaveLogRequest : {ex.Message}");
|
||||
return new SaveLogRespone();
|
||||
}
|
||||
}
|
||||
|
@ -138,15 +167,14 @@ namespace AIParkingApplication
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Check card validation API Data Model
|
||||
#region Check card validation API
|
||||
public class CardModel
|
||||
{
|
||||
[JsonProperty("card")]
|
||||
public string CardNumber { get; set; }
|
||||
}
|
||||
|
||||
public class CardInformation
|
||||
public class CardValidation
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
public bool IsValid { get; set; }
|
||||
|
@ -192,7 +220,8 @@ namespace AIParkingApplication
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Save Log API Data Model
|
||||
|
||||
#region Save Log API
|
||||
public class SaveLogRespone
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
|
@ -226,7 +255,7 @@ namespace AIParkingApplication
|
|||
public string CameraID { get; set; }
|
||||
|
||||
[JsonProperty("time")]
|
||||
public string Timestamp { get; set; }
|
||||
public string TimeVehicleInOrOut { get; set; }
|
||||
|
||||
[JsonProperty("plateImage")]
|
||||
public string PlateImage { get; set; }
|
||||
|
@ -242,7 +271,8 @@ namespace AIParkingApplication
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region Get Config API Data Model
|
||||
|
||||
#region Get Config API
|
||||
public class LoginModel
|
||||
{
|
||||
[JsonProperty("username")]
|
||||
|
@ -310,6 +340,8 @@ namespace AIParkingApplication
|
|||
|
||||
[JsonProperty("laneConfig")]
|
||||
public LaneConfig LaneConfigData { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region API Path
|
||||
|
@ -329,6 +361,7 @@ namespace AIParkingApplication
|
|||
|
||||
[JsonProperty("apiUpdateLogs")]
|
||||
public APIProperties ApiUpdateLogs { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class APIProperties
|
||||
|
@ -348,73 +381,54 @@ namespace AIParkingApplication
|
|||
{
|
||||
[JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonProperty("gate")]
|
||||
public int Gate { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonProperty("stream_url")]
|
||||
public string Stream_url { get; set; }
|
||||
|
||||
[JsonProperty("minWidth")]
|
||||
public double MinWidth { get; set; }
|
||||
|
||||
[JsonProperty("maxWidth")]
|
||||
public double MaxWidth { get; set; }
|
||||
|
||||
[JsonProperty("minHeight")]
|
||||
public double MinHeight { get; set; }
|
||||
|
||||
[JsonProperty("maxHeight")]
|
||||
public double MaxHeight { get; set; }
|
||||
|
||||
[JsonProperty("scaleFactor")]
|
||||
public double ScaleFactor { get; set; }
|
||||
|
||||
[JsonProperty("minNeighbors")]
|
||||
public double MinNeighbors { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public double Status { get; set; }
|
||||
|
||||
[JsonProperty("isRecognizeCamera")]
|
||||
public bool IsRecognizeCamera { get; set; }
|
||||
|
||||
[JsonProperty("isLongPlate")]
|
||||
public bool IsLongPlate { get; set; }
|
||||
|
||||
[JsonProperty("stt")]
|
||||
public int Stt { get; set; }
|
||||
|
||||
[JsonProperty("roi_config")]
|
||||
public string Roi_config { get; set; }
|
||||
|
||||
[JsonProperty("created_at")]
|
||||
public int Created_at { get; set; }
|
||||
|
||||
[JsonProperty("modified_at")]
|
||||
public int Modified_at { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class Statistics
|
||||
{
|
||||
[JsonProperty("moto")]
|
||||
public string Moto { get; set; }
|
||||
|
||||
[JsonProperty("oto")]
|
||||
public string Oto { get; set; }
|
||||
|
||||
[JsonProperty("vip")]
|
||||
public string Vip { get; set; }
|
||||
|
||||
[JsonProperty("total_in")]
|
||||
public string Total_in { get; set; }
|
||||
|
||||
[JsonProperty("total_out")]
|
||||
public string Total_out { get; set; }
|
||||
}
|
||||
|
@ -492,7 +506,6 @@ namespace AIParkingApplication
|
|||
public bool IsLongPlate { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace AIParkingApplication
|
|||
public volatile Mat CurrentFrame;
|
||||
|
||||
public event CameraEvent OnVideoFrameReceived;
|
||||
public event CameraEvent OnOneVideoFrameRequested;
|
||||
public event CameraEvent OnOpenVideoStreamFailed;
|
||||
|
||||
public Camera(string streamUrl)
|
||||
|
@ -64,6 +65,7 @@ namespace AIParkingApplication
|
|||
if (isFrameRequested)
|
||||
{
|
||||
CurrentFrame = videoFrame;
|
||||
OnOneVideoFrameRequested?.Invoke(videoFrame);
|
||||
isFrameRequested = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
namespace AIParkingApplication
|
||||
{
|
||||
public enum PlateType
|
||||
{
|
||||
Square,
|
||||
Long
|
||||
}
|
||||
|
||||
public enum LaneDirection
|
||||
{
|
||||
In,
|
||||
Out
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ namespace AIParkingApplication
|
|||
|
||||
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
|
||||
{
|
||||
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
|
||||
var cardInfoResult = await apiController.CheckCard(cardNumber);
|
||||
if (cardInfoResult.IsValid)
|
||||
{
|
||||
plateCamera.RequestCaptureOneFrame();
|
||||
|
@ -80,41 +80,20 @@ namespace AIParkingApplication
|
|||
pictureBoxPlateImage.Invoke(new Action(() =>
|
||||
{
|
||||
pictureBoxPlateImage.Image?.Dispose();
|
||||
pictureBoxPlateImage.Image = result.PlateImage.ToBitmap();
|
||||
pictureBoxPlateImage.Image = result.PlateImage;
|
||||
}));
|
||||
|
||||
var cardInformation = await apiController.GetCardInformation(cardNumber);
|
||||
var cardValidation = await apiController.CheckCard(cardNumber);
|
||||
|
||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
|
||||
ShowCardInfoOnUI(cardNumber, result.PlateString, cardValidation.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)
|
||||
{
|
||||
if (isAutoOpenDoor)
|
||||
if (this.doorId == doorId)
|
||||
{
|
||||
if (this.doorId == 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";
|
||||
}));
|
||||
}
|
||||
}
|
||||
c3Device.OpenDoor(doorId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lblRecogizePlateStatus.Invoke(new Action(() =>
|
||||
{
|
||||
lblRecogizePlateStatus.BackColor = Color.Red;
|
||||
lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ";
|
||||
}));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -166,9 +145,8 @@ namespace AIParkingApplication
|
|||
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
|
||||
return new FinalPlateResult
|
||||
{
|
||||
PlateImage = frame,
|
||||
PlateString = string.Empty,
|
||||
PlateType = PlateType.Square
|
||||
PlateImage = frame.ToBitmap(),
|
||||
PlateString = string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,6 +81,12 @@ namespace AIParkingApplication
|
|||
}
|
||||
}
|
||||
|
||||
public enum PlateType
|
||||
{
|
||||
Square,
|
||||
Long
|
||||
}
|
||||
|
||||
public static class PlateDetectorConstant
|
||||
{
|
||||
public const string SQUARE_PLATE_WEIGHT_FILENAME = "plate.xml";
|
||||
|
|
|
@ -36,26 +36,24 @@ namespace AIParkingApplication
|
|||
|
||||
//TODO: Check if plateDetected empty
|
||||
OcrResult plateOcrResultFromEngine = await Util.SendEngineRequestAsync(plateDetected, plateType);
|
||||
Mat finalPlateImage;
|
||||
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.Ocr) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64))
|
||||
Bitmap finalPlateImage;
|
||||
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.Ocr) && !string.IsNullOrEmpty(plateOcrResultFromEngine.Plate))
|
||||
{
|
||||
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.PlateImageBase64);
|
||||
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.Plate);
|
||||
using (var ms = new MemoryStream(imageData))
|
||||
{
|
||||
Bitmap image = new Bitmap(ms);
|
||||
finalPlateImage = BitmapConverter.ToMat(image);
|
||||
finalPlateImage = new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finalPlateImage = plateDetected;
|
||||
finalPlateImage = plateDetected.ToBitmap();
|
||||
}
|
||||
|
||||
return new FinalPlateResult
|
||||
{
|
||||
PlateString = plateOcrResultFromEngine.Ocr,
|
||||
PlateImage = finalPlateImage,
|
||||
PlateType = plateType
|
||||
PlateImage = finalPlateImage
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -86,8 +84,7 @@ namespace AIParkingApplication
|
|||
return new FinalPlateResult
|
||||
{
|
||||
PlateString = string.Empty,
|
||||
PlateImage = frame,
|
||||
PlateType = PlateType.Square
|
||||
PlateImage = frame.ToBitmap()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +105,6 @@ namespace AIParkingApplication
|
|||
public class FinalPlateResult
|
||||
{
|
||||
public string PlateString { get; set; }
|
||||
public Mat PlateImage { get; set; }
|
||||
public PlateType PlateType { get; set; }
|
||||
public Bitmap PlateImage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace AIParkingApplication
|
|||
public string Ocr { get; set; }
|
||||
|
||||
[JsonProperty("plate")]
|
||||
public string PlateImageBase64 { get; set; }
|
||||
public string Plate { get; set; }
|
||||
}
|
||||
|
||||
public static class UtilConstant
|
||||
|
|
Loading…
Reference in New Issue
Block a user