|
|
@@ -106,6 +106,8 @@ namespace ImpulseVision
|
|
|
//хранение информации о выбранном пользователе
|
|
|
UserItem CurrentUser = null;
|
|
|
|
|
|
+ TileOvals CurrentOvals = null;
|
|
|
+
|
|
|
SqlConnection SCon = new SqlConnection(Properties.Settings.Default.ImpulseVisionAppConnectionString);
|
|
|
//список с пользователями системы
|
|
|
List<Users> LstUsers = new List<Users>();
|
|
|
@@ -190,8 +192,6 @@ namespace ImpulseVision
|
|
|
|
|
|
HaarCascade = new CascadeClassifier(Config.HaarCascadePath);
|
|
|
FaceList.Clear();
|
|
|
- string line;
|
|
|
- FaceData faceInstance = null;
|
|
|
|
|
|
// Create empty directory / file for face data if it doesn't exist
|
|
|
if (!Directory.Exists(Config.FacePhotosPath))
|
|
|
@@ -199,42 +199,7 @@ namespace ImpulseVision
|
|
|
Directory.CreateDirectory(Config.FacePhotosPath);
|
|
|
}
|
|
|
|
|
|
- //if (!File.Exists(Config.FaceListTextFile))
|
|
|
- //{
|
|
|
- // string text = "Cannot find face data file:\n\n";
|
|
|
- // text += Config.FaceListTextFile + "\n\n";
|
|
|
- // text += "If this is your first time running the app, an empty file will be created for you.";
|
|
|
- // DialogResult result = MessageBox.Show(text, "Warning",
|
|
|
- // MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
- // switch (result)
|
|
|
- // {
|
|
|
- // case DialogResult.OK:
|
|
|
- // String dirName = Path.GetDirectoryName(Config.FaceListTextFile);
|
|
|
- // Directory.CreateDirectory(dirName);
|
|
|
- // File.Create(Config.FaceListTextFile).Close();
|
|
|
- // break;
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
- //StreamReader reader = new StreamReader(Config.FaceListTextFile);
|
|
|
- //int i = 0;
|
|
|
- //while ((line = reader.ReadLine()) != null)
|
|
|
- //{
|
|
|
- // string[] lineParts = line.Split(':');
|
|
|
- // faceInstance = new FaceData();
|
|
|
- // faceInstance.FaceImage = new Image<Gray, byte>(Config.FacePhotosPath + lineParts[0] + Config.ImageFileExtension);
|
|
|
- // faceInstance.PersonName = lineParts[1];
|
|
|
- // FaceList.Add(faceInstance);
|
|
|
- //}
|
|
|
- //foreach (var face in FaceList)
|
|
|
- //{
|
|
|
- // ImageList.Push(face.FaceImage.Mat);
|
|
|
- // NameList.Add(face.PersonName);
|
|
|
- // LabelList.Push(new[] { i++ });
|
|
|
- //}
|
|
|
- //reader.Close();
|
|
|
-
|
|
|
- // Train recogniser
|
|
|
+ // Тренировать изображения
|
|
|
if (ImageList.Size > 0)
|
|
|
{
|
|
|
recognizer = new EigenFaceRecognizer(ImageList.Size);
|
|
|
@@ -284,6 +249,9 @@ namespace ImpulseVision
|
|
|
CmbCams.Visible = false;
|
|
|
TslSelCamText.Visible = false;
|
|
|
|
|
|
+ CmbSortDate.SelectedIndex = 0;
|
|
|
+ DtpFiniteDate.Value = DateTime.Now.Date;
|
|
|
+
|
|
|
GetUsersFromDB();
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -356,33 +324,6 @@ where ID = '{IdUser}'";
|
|
|
|
|
|
MessageBox.Show("Пользователь безвозвратно удалён из системы!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// получение информации об идентификаторах пользователей и путях доступа к их фотографиям
|
|
|
- /// </summary>
|
|
|
- private void GetPicturesPath()
|
|
|
- {
|
|
|
- SCon.Open();
|
|
|
- string Query1 = $@"select UserID,Picture
|
|
|
- from FaceImages";
|
|
|
- SqlCommand Cmd = new SqlCommand(Query1, SCon);
|
|
|
- SqlDataReader Res = Cmd.ExecuteReader();
|
|
|
- if (Res.HasRows)
|
|
|
- {
|
|
|
- LstUserPictures.Clear();
|
|
|
- while (Res.Read())
|
|
|
- {
|
|
|
- Pictures Pic = new Pictures();
|
|
|
- Pic.UserID = Res["UserID"].ToString();
|
|
|
- Pic.PicturePath = Res["Picture"].ToString();
|
|
|
- LstUserPictures.Add(Pic);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- MessageBox.Show("Не удалось получить информацию об изображениях!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
- }
|
|
|
- SCon.Close();
|
|
|
- }
|
|
|
|
|
|
/// <summary>
|
|
|
/// показ окна добавления
|
|
|
@@ -640,23 +581,7 @@ where ID = '{IdUser}'";
|
|
|
TableLayoutWorks.BackColor = Color.Gray;
|
|
|
IsWorking = false;
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// переключение цветов кнопок включения/выключения
|
|
|
- /// </summary>
|
|
|
- /// <param name="IsWorking">статус работы камеры</param>
|
|
|
- private void ColorRegular(bool IsWorking)
|
|
|
- {
|
|
|
- if(IsWorking)
|
|
|
- {
|
|
|
- BtnAddUser.BackColor = Color.LightGreen;
|
|
|
- BtnEditUser.BackColor = Color.White;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BtnAddUser.BackColor = Color.White;
|
|
|
- BtnEditUser.BackColor = Color.LightPink;
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// сохранение информации для нового пользователя
|
|
|
/// </summary>
|
|
|
@@ -668,7 +593,7 @@ where ID = '{IdUser}'";
|
|
|
return;
|
|
|
}
|
|
|
string PhotoPath = string.Empty;
|
|
|
- ProgressTrain.Value = 10;
|
|
|
+ ProgressOperation.Value = 10;
|
|
|
TslStatus.Text = "Добавление нового пользователя...";
|
|
|
|
|
|
bool Flag = TbxLastname.Text.Trim() == "" || TbxFirstname.Text.Trim() == "" || TbxPasportSeria.Text.Trim() == "" || TbxPasportNum.Text.Trim() == "" || TbxPhone.Text.Trim() == "";
|
|
|
@@ -689,7 +614,7 @@ where PassportSeria = '{TbxPasportSeria.Text.Trim()}' and PassportNum = '{TbxPas
|
|
|
{
|
|
|
MessageBox.Show("Данные паспорта указаны неверно!", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
SCon.Close();
|
|
|
- ProgressTrain.Value = 0;
|
|
|
+ ProgressOperation.Value = 0;
|
|
|
return;
|
|
|
}
|
|
|
SCon.Close();
|
|
|
@@ -728,7 +653,7 @@ where PassportSeria = '{TbxPasportSeria.Text.Trim()}' and PassportNum = '{TbxPas
|
|
|
|
|
|
TslStatus.Text = "Сохранение данных о пользователе...";
|
|
|
|
|
|
- ProgressTrain.Value = 50;
|
|
|
+ ProgressOperation.Value = 50;
|
|
|
TslStatus.Text = "Добавление нового пользователя...";
|
|
|
//сохранение пути до фотографии
|
|
|
SCon.Open();
|
|
|
@@ -744,73 +669,8 @@ values ({AddingUserID},'{PhotoPath}')";
|
|
|
TimerSaving.Start();
|
|
|
|
|
|
TslStatus.Text = "Готов";
|
|
|
- ProgressTrain.Value = 100;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// тренировка изображения
|
|
|
- /// </summary>
|
|
|
- /// <returns>результат тренировки (true или false)</returns>
|
|
|
- /*
|
|
|
- private void TrainImageFromDir()
|
|
|
- {
|
|
|
- int CountImage = 0;
|
|
|
- //порог
|
|
|
- double Threshold = 10000;
|
|
|
-
|
|
|
- LstTrainedFaces.Clear();
|
|
|
- PersonLabes.Clear();
|
|
|
- LstPersonNames.Clear();
|
|
|
-
|
|
|
- try
|
|
|
- {
|
|
|
- //ProgressTrain.Value += 15;
|
|
|
- string MyPath = Directory.GetCurrentDirectory() + @"\TrainedImages\";
|
|
|
- string[] Files = Directory.GetFiles(MyPath, "*.jpg", SearchOption.AllDirectories);
|
|
|
-
|
|
|
- int n = Files.Length;
|
|
|
-
|
|
|
- foreach (string file in Files)
|
|
|
- {
|
|
|
- //ProgressTrain.Value += (int)PlusDigit;
|
|
|
-
|
|
|
- Image<Gray, Byte> TrainedImage = new Image<Gray, Byte>(file);
|
|
|
- //добавить обученное изображение
|
|
|
- LstTrainedFaces.Add(TrainedImage);
|
|
|
- PersonLabes.Add(CountImage);
|
|
|
-
|
|
|
- string CurrentFileName = Path.GetFileName(file);
|
|
|
- string Name = CurrentFileName.Remove(CurrentFileName.IndexOf("_"), CurrentFileName.Length - CurrentFileName.IndexOf("_"));
|
|
|
- //(0, CurrentFileName.Length - CurrentFileName.IndexOf("_") + 1);
|
|
|
- //добавить имя
|
|
|
- LstPersonNames.Add(Name);
|
|
|
-
|
|
|
- CountImage++;
|
|
|
- }
|
|
|
- if (CountImage == 0)
|
|
|
- {
|
|
|
- IsTrained = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- //тренировка изображения
|
|
|
- Recognizer = new EigenFaceRecognizer(CountImage, Threshold);
|
|
|
- Recognizer.Train(LstTrainedFaces.ToArray(), PersonLabes.ToArray());
|
|
|
-
|
|
|
- //ProgressTrain.Value += 100 - ProgressTrain.Value;
|
|
|
-
|
|
|
- //записать, что обучен
|
|
|
- IsTrained = true;
|
|
|
-
|
|
|
- MessageBox.Show("Тренировка изображений выполнена!");
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- IsTrained = false;
|
|
|
- }
|
|
|
-
|
|
|
+ ProgressOperation.Value = 100;
|
|
|
}
|
|
|
- */
|
|
|
-
|
|
|
|
|
|
private void CmbCams_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -882,10 +742,10 @@ values ({AddingUserID},'{PhotoPath}')";
|
|
|
}
|
|
|
HtBefore.Except(HtAfter);
|
|
|
|
|
|
- ProgressTrain.Value = 0;
|
|
|
+ ProgressOperation.Value = 0;
|
|
|
TslStatus.Text = $"Устройство: {string.Join(" ",HtBefore)} - отключено";
|
|
|
await Task.Delay(1000);
|
|
|
- ProgressTrain.Value = 100;
|
|
|
+ ProgressOperation.Value = 100;
|
|
|
TslStatus.Text = "Готов";
|
|
|
}
|
|
|
/// <summary>
|
|
|
@@ -895,24 +755,24 @@ values ({AddingUserID},'{PhotoPath}')";
|
|
|
async void StatusAddNewDevice(DsDevice[] Cams)
|
|
|
{
|
|
|
TslStatus.Text = "Добавление нового устройства..";
|
|
|
- ProgressTrain.Value = 0;
|
|
|
- while(ProgressTrain.Value < 100)
|
|
|
+ ProgressOperation.Value = 0;
|
|
|
+ while(ProgressOperation.Value < 100)
|
|
|
{
|
|
|
- ProgressTrain.Value += 5;
|
|
|
+ ProgressOperation.Value += 5;
|
|
|
await Task.Delay(50);
|
|
|
}
|
|
|
TslStatus.Text = "Добавлено новое устройство";
|
|
|
await Task.Delay(1000);
|
|
|
TslStatus.Text = $"{Cams[Cams.Length-1].Name}";
|
|
|
await Task.Delay(1000);
|
|
|
- ProgressTrain.Value = 100;
|
|
|
+ ProgressOperation.Value = 100;
|
|
|
TslStatus.Text = "Готов";
|
|
|
}
|
|
|
|
|
|
private void BtnCheck_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
TslStatus.Text = "Подождите.. выполняется анализ лица..";
|
|
|
- ProgressTrain.Value = 45;
|
|
|
+ ProgressOperation.Value = 45;
|
|
|
//TrainImageFromDir();
|
|
|
|
|
|
//FaceDifferent();
|
|
|
@@ -1022,6 +882,8 @@ values ({AddingUserID},'{PhotoPath}')";
|
|
|
BtnAddUser.Enabled = true;
|
|
|
BtnInfoTraffic.Enabled = true;
|
|
|
|
|
|
+ TslStatus.Text = "Готов";
|
|
|
+ ProgressOperation.Value = 100;
|
|
|
}
|
|
|
|
|
|
private void BtnEditUser_Click(object sender, EventArgs e)
|
|
|
@@ -1047,7 +909,156 @@ values ({AddingUserID},'{PhotoPath}')";
|
|
|
|
|
|
private void BtnInfoTraffic_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
+ GetJournalVisits();
|
|
|
TabPages.SelectTab(3);
|
|
|
+ TmAnim.Enabled = true;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// получение из БД списка посещений
|
|
|
+ /// </summary>
|
|
|
+ private void GetJournalVisits()
|
|
|
+ {
|
|
|
+ TslStatus.Text = "Загрузка данных...";
|
|
|
+ ProgressOperation.Value = 10;
|
|
|
+
|
|
|
+ SCon.Open();
|
|
|
+ string QueryGetVisits = $@"set dateformat dmy
|
|
|
+select Users.ID,Users.Lastname +' '+ Users.Firstname + ' '+Users.Patronymic as FIO,TimeEntrance,TimeExit,
|
|
|
+[Date],Identification
|
|
|
+from UserTraffic ut join Users on ut.UserID = Users.ID
|
|
|
+";
|
|
|
+ if(DtpFiniteDate.Visible)
|
|
|
+ {
|
|
|
+ QueryGetVisits += $" where [Date] = '{DtpFiniteDate.Value.Date}'";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ QueryGetVisits += $" where [Date] between '{DtpDateStart.Value.Date}' and '{DtpDateEnd.Value.Date}'";
|
|
|
+ }
|
|
|
+ SqlCommand Cmd = new SqlCommand(QueryGetVisits, SCon);
|
|
|
+ SqlDataReader Res = Cmd.ExecuteReader();
|
|
|
+
|
|
|
+ ProgressOperation.Value = 30;
|
|
|
+
|
|
|
+ TabJournal.Controls.Clear();
|
|
|
+ if (Res.HasRows)
|
|
|
+ {
|
|
|
+ while (Res.Read())
|
|
|
+ {
|
|
|
+ TileOvals Ovals = new TileOvals();
|
|
|
+ Ovals.UserID = Res["ID"].ToString();
|
|
|
+ Ovals.LblNameUser.Text = Res["FIO"].ToString();
|
|
|
+ Ovals.LblTimeEntrance.Text = Res["TimeEntrance"].ToString();
|
|
|
+ Ovals.LblTimeExit.Text = Res["TimeExit"].ToString();
|
|
|
+ Ovals.IsIdentification = Res["Identification"].ToString();
|
|
|
+ Ovals.LblDate.Text = DateTime.Parse(Res["Date"].ToString()).ToString("dd.MM.yyyy");
|
|
|
+
|
|
|
+ Ovals.Click += Ovals_Click;
|
|
|
+ Ovals.LblDate.Click += OvalsObject_Click;
|
|
|
+ Ovals.LblNameUser.Click += OvalsObject_Click;
|
|
|
+ Ovals.LblTimeEntrance.Click += OvalsObject_Click;
|
|
|
+ Ovals.LblTimeExit.Click += OvalsObject_Click;
|
|
|
+ Ovals.RPanelName.Click += OvalsObject_Click;
|
|
|
+ Ovals.RPanelTimeEntrance.Click += OvalsObject_Click;
|
|
|
+ Ovals.RPanelTimeExit.Click += OvalsObject_Click;
|
|
|
+ Ovals.RPanelDate.Click += OvalsObject_Click;
|
|
|
+
|
|
|
+ TabJournal.Controls.Add(Ovals);
|
|
|
+ if (TabJournal.Controls.Count == 1)
|
|
|
+ {
|
|
|
+ CurrentOvals = Ovals;
|
|
|
+ CurrentOvals.RPanelDate.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelName.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeEntrance.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeExit.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //MessageBox.Show("При выбранных параметрах сортировки, результаты отсутствуют! Выберите новые параметры и повторите попытку.", "ImpulseVision", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
|
+ //SCon.Close();
|
|
|
+ //return;
|
|
|
+ }
|
|
|
+ SCon.Close();
|
|
|
+
|
|
|
+ TslStatus.Text = "Готов";
|
|
|
+ ProgressOperation.Value = 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OvalsObject_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ //CurrentOvals = (sender as Control).Parent as TileOvals;
|
|
|
+
|
|
|
+ CurrentOvals.RPanelDate.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelName.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelTimeEntrance.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelTimeExit.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+
|
|
|
+ CurrentOvals = ((sender as Control).Parent as RPanel).Parent as TileOvals;
|
|
|
+
|
|
|
+ CurrentOvals.RPanelDate.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelName.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeEntrance.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeExit.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Ovals_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ CurrentOvals.RPanelDate.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelName.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelTimeEntrance.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+ CurrentOvals.RPanelTimeExit.BackColor = Color.FromArgb(184, 184, 255);
|
|
|
+
|
|
|
+ CurrentOvals = sender as TileOvals;
|
|
|
+
|
|
|
+ CurrentOvals.RPanelDate.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelName.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeEntrance.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ CurrentOvals.RPanelTimeExit.BackColor = ColorTranslator.FromHtml("#C3EB78");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CmbSortDate_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PanelPeriod.Visible = CmbSortDate.SelectedIndex == 1;
|
|
|
+ DtpFiniteDate.Visible = CmbSortDate.SelectedIndex == 0;
|
|
|
+ }
|
|
|
+ int LocX = 0;
|
|
|
+ private void TmAnim_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ //LocX = LblTest.Location.X;
|
|
|
+ //LocX++;
|
|
|
+ //LblTest.Location = new Point(LocX, LblTest.Location.Y);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void BtnJournal_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ TabJournal.Controls.Clear();
|
|
|
+ for (int i = 0; i < 10; i++)
|
|
|
+ {
|
|
|
+ TileOvals Ovals = new TileOvals();
|
|
|
+ Ovals.LblNameUser.Text = "Иванов Иван Иванович";
|
|
|
+ Ovals.LblTimeEntrance.Text = "13:15:00";
|
|
|
+ Ovals.LblTimeExit.Text = "13:48:59";
|
|
|
+ Ovals.LblDate.Text = "26.04.2023";
|
|
|
+ TabJournal.Controls.Add(Ovals);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DtpFiniteDate_ValueChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ GetJournalVisits();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DtpDateStart_ValueChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ GetJournalVisits();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void DtpDateEnd_ValueChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ GetJournalVisits();
|
|
|
}
|
|
|
}
|
|
|
}
|