|
@@ -33,7 +33,7 @@ namespace ImpulseVision
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
private VideoCapture Capture;
|
|
|
private CascadeClassifier HaarCascade;
|
|
|
- private Image<Bgr, Byte> bgrFrame = null;
|
|
|
+ private Image<Bgr, Byte> BgrFrame = null;
|
|
|
private Image<Gray, Byte> DetectedFace = null;
|
|
|
private List<FaceData> FaceList = new List<FaceData>();
|
|
|
private VectorOfMat ImageList = new VectorOfMat();
|
|
@@ -43,6 +43,7 @@ namespace ImpulseVision
|
|
|
private EigenFaceRecognizer recognizer;
|
|
|
private Timer CaptureTimer;
|
|
|
#region FaceName
|
|
|
+ private string UserName = string.Empty;
|
|
|
private string faceName;
|
|
|
public string FaceName
|
|
|
{
|
|
@@ -51,7 +52,7 @@ namespace ImpulseVision
|
|
|
{
|
|
|
faceName = value.ToUpper();
|
|
|
|
|
|
- this.Text = faceName;
|
|
|
+ UserName = faceName;
|
|
|
//PbxFaces.Invoke(DispatcherPriority.Normal, new Action(() => { lblFaceName.Content = faceName; }));
|
|
|
NotifyPropertyChanged();
|
|
|
}
|
|
@@ -150,13 +151,21 @@ namespace ImpulseVision
|
|
|
/// </summary>
|
|
|
private void ProcessFrame()
|
|
|
{
|
|
|
- bgrFrame = Capture.QueryFrame().ToImage<Bgr, Byte>().Flip(FlipType.Horizontal);
|
|
|
+ BgrFrame = Capture.QueryFrame().ToImage<Bgr, Byte>().Flip(FlipType.Horizontal);
|
|
|
|
|
|
- if (bgrFrame != null)
|
|
|
+ Pen PenForFace = new Pen(Brushes.Red, 5);
|
|
|
+ Brush BrushForFace = Brushes.White;
|
|
|
+ Font MyFont = new Font("Segoe UI Variable Small Semibol; 14pt; style=Bold", 14, FontStyle.Regular);
|
|
|
+
|
|
|
+ Brush BrushInfo = Brushes.White;
|
|
|
+ Pen PenInfo = new Pen(Brushes.White, 4);
|
|
|
+
|
|
|
+
|
|
|
+ if (BgrFrame != null)
|
|
|
{
|
|
|
try
|
|
|
{//for emgu cv bug
|
|
|
- Image<Gray, byte> grayframe = bgrFrame.Convert<Gray, byte>();
|
|
|
+ Image<Gray, byte> grayframe = BgrFrame.Convert<Gray, byte>();
|
|
|
|
|
|
Rectangle[] Faces = HaarCascade.DetectMultiScale(grayframe, 1.2, 10, new System.Drawing.Size(50, 50), new System.Drawing.Size(200, 200));
|
|
|
|
|
@@ -164,12 +173,12 @@ namespace ImpulseVision
|
|
|
FaceName = "No face detected";
|
|
|
foreach (var face in Faces)
|
|
|
{
|
|
|
- bgrFrame.Draw(face, new Bgr(53, 23, 247), 2);
|
|
|
- DetectedFace = bgrFrame.Copy(face).Convert<Gray, byte>();
|
|
|
+ BgrFrame.Draw(face, new Bgr(53, 23, 247), 2);
|
|
|
+ DetectedFace = BgrFrame.Copy(face).Convert<Gray, byte>();
|
|
|
FaceRecognition();
|
|
|
break;
|
|
|
}
|
|
|
- CameraCapture = bgrFrame.ToBitmap();
|
|
|
+ CameraCapture = BgrFrame.ToBitmap();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -338,18 +347,18 @@ where ID = '{IdUser}'";
|
|
|
|
|
|
SCon.Close();
|
|
|
|
|
|
- string FolderNameForUser = string.Empty;
|
|
|
+ string PhotoName = string.Empty;
|
|
|
for (int i = 0; i < LstUsers.Count; i++)
|
|
|
{
|
|
|
if (LstUsers[i].UserID == IdUser)
|
|
|
{
|
|
|
- FolderNameForUser = LstUsers[i].FIO.Split(' ')[1] + LstUsers[i].PassportSeria + LstUsers[i].PassportNum;
|
|
|
+ PhotoName = LstUsers[i].FIO.Split(' ')[1] + LstUsers[i].PassportSeria + LstUsers[i].PassportNum;
|
|
|
}
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
//удалить из папки фотографию пользователя
|
|
|
- File.Delete(Application.StartupPath + "\\TrainedImages\\" + $"{FolderNameForUser}.bmp");
|
|
|
+ File.Delete(Application.StartupPath + Config.FacePhotosPath + $"{PhotoName}.bmp");
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -626,7 +635,7 @@ where ID = '{IdUser}'";
|
|
|
|
|
|
if (Capture != null)
|
|
|
{
|
|
|
- bgrFrame = null;
|
|
|
+ BgrFrame = null;
|
|
|
Capture.Stop();
|
|
|
Capture.Dispose();
|
|
|
Capture = null;
|