Exemple #1
0
 private void RegisterEvent()
 {
     _eventDetectedCallback = (IntPtr trigger, IntPtr source, int streamId, IntPtr result, IntPtr _) =>
     {
         Detected?.Invoke(this, CreateMovementDetectedEventArgs(result));
     };
 }
Exemple #2
0
        private async void Frame(ThreadPoolTimer timer)
        {
            if (cam.CameraStreamState != CameraStreamState.Streaming)
            {
                return;
            }
            if (!semaphore.Wait(0))
            {
                return;
            }

            try
            {
                const BitmapPixelFormat InputPixelFormat = BitmapPixelFormat.Nv12;
                using (VideoFrame frame = new VideoFrame(InputPixelFormat, (int)properties.Width, (int)properties.Height))
                {
                    await cam.GetPreviewFrameAsync(frame);

                    var faces = await tracker.ProcessNextFrameAsync(frame);

                    var b = frame.SoftwareBitmap;
                    Detected?.Invoke(this, Tuple.Create(faces, b.PixelWidth, b.PixelHeight));
                }
            }
            finally
            {
                semaphore.Release();
            }
        }
        public void DidOutputMetadataObjects(AVCaptureMetadataOutput captureOutput, AVMetadataObject[] metadataObjects, AVCaptureConnection connection)
        {
            if (codeFrame is null || preview is null)
            {
                return;
            }

            if (metadataObjects.Length == 0)
            {
                codeFrame.Frame = CGRect.Empty;
                return;
            }

            var readableObject = metadataObjects[0] as AVMetadataMachineReadableCodeObject;

            if (readableObject.Type != AVMetadataObjectType.QRCode)
            {
                return;
            }

            var qrObject = preview.GetTransformedMetadataObject(readableObject);

            codeFrame.Frame = qrObject.Bounds;

            if (readableObject.StringValue is string value)
            {
                Detected?.Invoke(this, new BarcodeDetectedEventArgs(value));
            }
        }
        private static void OnTick(object state)
        {
            var lastInput = NativeUtils.GetLastInputTime();
            var idleTime  = Environment.TickCount - lastInput;

            if (idleTime >= _timeout && _lastTime < lastInput)
            {
                _lastTime = lastInput;
                Detected?.Invoke(null, EventArgs.Empty);
            }
        }
Exemple #5
0
 internal override void OnEventDetected(IntPtr trigger, IntPtr source, int streamId,
                                        IntPtr result, IntPtr _)
 {
     try
     {
         Detected?.Invoke(this, CreatePersonAppearanceChangedEventArgs(result));
     }
     catch (Exception e)
     {
         MultimediaLog.Error(MediaVisionLog.Tag, "Failed to invoke Recognized event.", e);
     }
 }
Exemple #6
0
        private void TextAPIDetected()
        {
            try
            {
                if (WasDetected)
                {
                    Log.Error("TextAPI sent the register event twice now! Please report to TextAPI author.", Log.PRINT_MESSAGE);
                    return;
                }

                WasDetected = true;
                Detected?.Invoke();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
 /// <summary>
 /// Raises the <see cref="Detected"/> event.
 /// </summary>
 protected virtual void OnDetected()
 {
     Detected?.Invoke(this, EventArgs.Empty);
 }