Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication
This commit is contained in:
commit
f38d8dd085
|
@ -12,6 +12,17 @@ namespace AIParkingApplication
|
|||
private bool isHttpClientDisposabled;
|
||||
private int numberOfRetry;
|
||||
private ApiPath apiPath;
|
||||
public enum VehicleDirection
|
||||
{
|
||||
In,
|
||||
Out
|
||||
}
|
||||
|
||||
public enum ModePlate
|
||||
{
|
||||
Sqare,
|
||||
Long
|
||||
}
|
||||
|
||||
public ApiController(string baseAddress, int numberOfRetry = 5)
|
||||
{
|
||||
|
@ -30,21 +41,21 @@ namespace AIParkingApplication
|
|||
}
|
||||
|
||||
//TODO Old API
|
||||
public async Task<LoginResponseModel> Login(LoginModel loginData)
|
||||
public async Task<LoginDataModel> Login(LoginModel loginData)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/login", loginData);
|
||||
response.EnsureSuccessStatusCode();
|
||||
var loginResult = await response.Content.ReadAsAsync<LoginResponseModel>();
|
||||
var loginResult = await response.Content.ReadAsAsync<LoginDataModel>();
|
||||
return loginResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"SendEngineRequest : {ex.Message}");
|
||||
return new LoginResponseModel
|
||||
return new LoginDataModel
|
||||
{
|
||||
IsLoggedIn = false
|
||||
IsLoginSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +120,42 @@ namespace AIParkingApplication
|
|||
}
|
||||
}
|
||||
|
||||
//Neu Dicrection la Out thi logID la logID lay ve khi check the
|
||||
public async Task<SaveLogRespone> SaveLog(int direction, string cardID, string cameraID, int 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());
|
||||
string PlateFrameImageBase64 = Convert.ToBase64String(PlateFrameImage.ToBytes());
|
||||
string FrameImageBase64 = Convert.ToBase64String(FrameImage.ToBytes());
|
||||
try
|
||||
{
|
||||
var request = new SaveLogParams
|
||||
{
|
||||
Direction = (direction == (int)VehicleDirection.In) ? "in" : "out",
|
||||
LogID = logID,
|
||||
CardID = cardID,
|
||||
TextPlate = textPlate,
|
||||
CameraID = cameraID,
|
||||
ModePlate = (squareOrLong == (int)ModePlate.Sqare) ? "1":"0",
|
||||
TimeVehicleInOrOut = timeInOrOut,
|
||||
PlateImage = plateImageBase64,
|
||||
PlateResultImage = plateImageResultBase64,
|
||||
PlateFrameImage = PlateFrameImageBase64,
|
||||
FrameImage = FrameImageBase64
|
||||
};
|
||||
|
||||
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
|
||||
response.EnsureSuccessStatusCode();
|
||||
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
|
||||
return saveLogRespone;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"SendSaveLogRequest : {ex.Message}");
|
||||
return new SaveLogRespone();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (httpClient != null && !isHttpClientDisposabled)
|
||||
|
@ -119,6 +166,54 @@ namespace AIParkingApplication
|
|||
}
|
||||
}
|
||||
|
||||
public class SaveLogRespone
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
public bool Status { get; set; }
|
||||
|
||||
[JsonProperty("logID")]
|
||||
public int LogID { get; set; }
|
||||
|
||||
[JsonProperty("cost")]
|
||||
public string Cost { get; set; }
|
||||
}
|
||||
|
||||
public class SaveLogParams
|
||||
{
|
||||
[JsonProperty("card")]
|
||||
public string CardID { get; set; }
|
||||
|
||||
[JsonProperty("plate")]
|
||||
public string TextPlate { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public string Direction { get; set; }
|
||||
|
||||
[JsonProperty("mod")]
|
||||
public string ModePlate { get; set; }
|
||||
|
||||
[JsonProperty("log_id")]
|
||||
public string LogID { get; set; }
|
||||
|
||||
[JsonProperty("camera")]
|
||||
public string CameraID { get; set; }
|
||||
|
||||
[JsonProperty("time")]
|
||||
public string TimeVehicleInOrOut { get; set; }
|
||||
|
||||
[JsonProperty("plateImage")]
|
||||
public string PlateImage { get; set; }
|
||||
|
||||
[JsonProperty("plateResultImage")]
|
||||
public string PlateResultImage { get; set; }
|
||||
|
||||
[JsonProperty("plateFrameImage")]
|
||||
public string PlateFrameImage { get; set; }
|
||||
|
||||
[JsonProperty("frameImage")]
|
||||
public string FrameImage { get; set; }
|
||||
}
|
||||
|
||||
public class ApiPath
|
||||
{
|
||||
[JsonProperty("savelogsin")] //wtf is this from server.
|
||||
|
@ -139,11 +234,6 @@ namespace AIParkingApplication
|
|||
|
||||
}
|
||||
|
||||
public class LoginResponseModel
|
||||
{
|
||||
[JsonProperty("")]
|
||||
public bool IsLoggedIn { get; set; }
|
||||
}
|
||||
|
||||
public class PlateLogModel
|
||||
{
|
||||
|
@ -177,4 +267,226 @@ namespace AIParkingApplication
|
|||
[JsonProperty("frameImage")]
|
||||
public string FrameImageBase64 { get; set; }
|
||||
}
|
||||
|
||||
public class LoginDataModel
|
||||
{
|
||||
[JsonProperty("status")]
|
||||
public bool IsLoginSuccess { get; set; }
|
||||
|
||||
[JsonProperty("data")]
|
||||
public Data LoginData { get; set; }
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
[JsonProperty("userID")]
|
||||
public int UserID { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[JsonProperty("configROI")]
|
||||
public bool IsConfigROI { get; set; }
|
||||
|
||||
[JsonProperty("configSystemLogs")]
|
||||
public bool IsSaveSystemLogs { get; set; }
|
||||
|
||||
[JsonProperty("api")]
|
||||
public APIPath APIPath { get; set; }
|
||||
|
||||
[JsonProperty("camera1")]
|
||||
public CameraData CameraData1 { get; set; }
|
||||
|
||||
[JsonProperty("camera2")]
|
||||
public CameraData CameraData2 { get; set; }
|
||||
|
||||
[JsonProperty("camera3")]
|
||||
public CameraData CameraData3 { get; set; }
|
||||
|
||||
[JsonProperty("camera4")]
|
||||
public CameraData CameraData4 { get; set; }
|
||||
|
||||
[JsonProperty("camera5")]
|
||||
public CameraData CameraData5 { get; set; }
|
||||
|
||||
[JsonProperty("camera6")]
|
||||
public CameraData CameraData6 { get; set; }
|
||||
|
||||
[JsonProperty("camera7")]
|
||||
public CameraData CameraData7 { get; set; }
|
||||
|
||||
[JsonProperty("camera8")]
|
||||
public CameraData CameraData8 { get; set; }
|
||||
|
||||
[JsonProperty("statistic")]
|
||||
public Statistics StatisticsData { get; set; }
|
||||
|
||||
[JsonProperty("cascadeConfig")]
|
||||
public CascadeConfig CascadeConfigData { get; set; }
|
||||
|
||||
[JsonProperty("laneConfig")]
|
||||
public LaneConfig LaneConfigData { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class APIPath
|
||||
{
|
||||
[JsonProperty("apiStatistics")]
|
||||
public APIProperties ApiStatistics { get; set; }
|
||||
|
||||
[JsonProperty("apiPlateRecognize")]
|
||||
public APIProperties ApiPlateRecognize { get; set; }
|
||||
|
||||
[JsonProperty("apiCheckCard")]
|
||||
public APIProperties ApiCheckCard { get; set; }
|
||||
|
||||
[JsonProperty("apiSaveLogs")]
|
||||
public APIProperties ApiSaveLogs { get; set; }
|
||||
|
||||
[JsonProperty("apiUpdateLogs")]
|
||||
public APIProperties ApiUpdateLogs { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class APIProperties
|
||||
{
|
||||
[JsonProperty("ip")]
|
||||
public string IP { get; set; }
|
||||
|
||||
[JsonProperty("port")]
|
||||
public string Port { get; set; }
|
||||
|
||||
[JsonProperty("path")]
|
||||
public string Path { get; set; }
|
||||
}
|
||||
|
||||
public class CameraData
|
||||
{
|
||||
[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; }
|
||||
}
|
||||
|
||||
public class CascadeConfig
|
||||
{
|
||||
[JsonProperty("minWidthPlate")]
|
||||
public int MinWidthPlate { get; set; }
|
||||
|
||||
[JsonProperty("maxWidthPlate")]
|
||||
public int MaxWidthPlate { get; set; }
|
||||
|
||||
[JsonProperty("minHeightPlate")]
|
||||
public int MinHeightPlate { get; set; }
|
||||
|
||||
[JsonProperty("maxHeightPlate")]
|
||||
public int MaxHeightPlate { get; set; }
|
||||
|
||||
[JsonProperty("minWidthLongPlate")]
|
||||
public int MinWidthLongPlate { get; set; }
|
||||
|
||||
[JsonProperty("maxWidthLongPlate")]
|
||||
public int MaxWidthLongPlate { get; set; }
|
||||
|
||||
[JsonProperty("minHeightLongPlate")]
|
||||
public int MinHeightLongPlate { get; set; }
|
||||
|
||||
[JsonProperty("maxHeightLongPlate")]
|
||||
public int MaxHeightLongPlate { get; set; }
|
||||
|
||||
[JsonProperty("scaleFactor")]
|
||||
public double ScaleFactor { get; set; }
|
||||
|
||||
[JsonProperty("scaleFactorLong")]
|
||||
public double ScaleFactorLong { get; set; }
|
||||
|
||||
[JsonProperty("minNeighbors")]
|
||||
public double MinNeighbors { get; set; }
|
||||
|
||||
[JsonProperty("minNeighborsLong")]
|
||||
public double MinNeighborsLong { get; set; }
|
||||
|
||||
[JsonProperty("timeOut")]
|
||||
public int TimeOut { get; set; }
|
||||
|
||||
[JsonProperty("logs")]
|
||||
public int Logs { get; set; }
|
||||
}
|
||||
|
||||
public class LaneConfig
|
||||
{
|
||||
[JsonProperty("laneConfig")]
|
||||
public LanePosision Posision { get; set; }
|
||||
}
|
||||
|
||||
public class LanePosision
|
||||
{
|
||||
[JsonProperty("left")]
|
||||
public LaneConfigParam LeftLane { get; set; }
|
||||
|
||||
[JsonProperty("right")]
|
||||
public LaneConfigParam RightLane { get; set; }
|
||||
}
|
||||
|
||||
public class LaneConfigParam
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string LaneName { get; set; }
|
||||
|
||||
[JsonProperty("default")]
|
||||
public string DefaultLane { get; set; }
|
||||
|
||||
[JsonProperty("longPlate")]
|
||||
public bool IsLongPlate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user