Exemplo n.º 1
0
        public async Task <ActionResult <Message> > PostMessage(NewUserRegistered message)
        {
            if (!message.messageType.Equals("NewUserRegistered"))
            {
                return(BadRequest());
            }

            var data = await _context.Messages.FindAsync(message.data.UserId);

            if (data != null)
            {
                Notifiy(message.data.UserId, "Same UserId exist");
                return(BadRequest());
            }

            _context.Messages.Add(message.data);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MessageExists(message.data.UserId))
                {
                    Notifiy(message.data.UserId, "Conflit");
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            Notifiy(message.data.UserId, "Created");
            return(CreatedAtAction("GetMessage", new { id = message.data.UserId }, message));
        }
Exemplo n.º 2
0
        private void DisplayCam()
        {
            while (videoCapture.IsOpened)
            {
                Mat frame;
                try
                {
                    frame = videoCapture.QueryFrame();
                }
                catch
                {
                    LibraryDataIO.Instance.UILogger.LogError("Camera stopped.");
                    return;
                }

                var gray = new Mat();

                //Prepares a gray frame and increases its brightness & contrast
                CvInvoke.CvtColor(frame, gray, ColorConversion.Bgr2Gray);
                CvInvoke.EqualizeHist(gray, gray);

                var square = FrameSquarePicture(frame.Bitmap, camSize.Width, camSize.Height);
                FrameGrabbed?.Invoke(this, new FrameGrabbedEventArgs {
                    Frame = square
                });

                frame.Dispose();

                Rectangle[] facesDetected = faceRecognition.DetectFaces(gray);

                //Forget the previously detected face so if no faces were detected in current iteration,
                //the same value wouldn't get stored
                detectedFace = null;

                foreach (Rectangle face in facesDetected)
                {
                    var grayFace = new Mat(gray, face);
                    detectedFace = grayFace.ToImage <Gray, byte>();
                    gray.Dispose();
                    CvInvoke.Resize(detectedFace, detectedFace, new Size(100, 100), 0, 0, Inter.Cubic);

                    if (isTrained)
                    {
                        var label = faceRecognition.Recognize(detectedFace);
                        if (label != "")
                        {
                            tokenSource.Cancel();
                            ExistingUserRecognised?.Invoke(this, new FaceRecognisedEventArgs {
                                Label = label
                            });
                            return;
                        }
                    }

                    if (saved)
                    {
                        NewUserRegistered?.Invoke(this, new FaceRecognisedEventArgs {
                            Label = userLabel
                        });
                        return;
                    }

                    break;
                }
            }
        }
Exemplo n.º 3
0
 private void On(NewUserRegistered @event)
 {
     _isRegistered = true;
 }
Exemplo n.º 4
0
 private void On(NewUserRegistered @event)
 {
     _isRegistered = true;
     //_registeredAt = DateTimeOffset.UtcNow;
 }