コード例 #1
0
ファイル: RegistrationService.cs プロジェクト: hcilab-um/tPad
        /// <summary>
        /// This method receives the image from the camera and finds the location of the device.
        /// Location defined as the page, the X and Y coordinates wihtin the page in cms, and the rotation angle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void CustomUpdateMonitorReading(object sender, NotifyContextMonitorListenersEventArgs e)
        {
            if (e.Type != typeof(System.Drawing.Bitmap))
            return;
              if (isProcessStopped)
            return;
              if (Container == null || Controller == null)
            return;
              if (Device.State == StackingState.StackedOnTop)
            return;

              if (TPadCore.UseFeatureTracking)
              {
            if (sender is SimCameraMonitor)
            {
              if (Tracker == null)
            Tracker = (sender as SimCameraMonitor).Tracker;

              if (temp_SimCaptureToSourceImageRatio != Controller.SimCaptureToSourceImageRatio)
              {
            temp_SimCaptureToSourceImageRatio = Controller.SimCaptureToSourceImageRatio;
            Tracker.computeWarpMatrix(temp_SimCaptureToSourceImageRatio);
              }

              status = Tracker.detectLocation(false, status);
              GetLocationFromTracker();
            }
            else if (sender is CameraMonitor)
            {
              if (Tracker == null)
            Tracker = (sender as CameraMonitor).Tracker;

              if (Tracker == null)
            return;

              //start feature tracking
              //Stopwatch sw = new Stopwatch();
              //sw.Start();
              status = Tracker.detectLocation(true, status);
              //sw.Stop();
              //Console.WriteLine("Elapsed={0} ", sw.ElapsedMilliseconds);
              GetLocationFromTracker();
            }
              }
              else {
            location = new TPadLocation();
            location.Status = LocationStatus.Located;
            location.RotationAngle = ClampedAngle(Controller.RotationAngle);
            location.LocationCm = new Point(Controller.Location.X / Controller.WidthFactor, Controller.Location.Y / Controller.HeightFactor);
            location.Document = Controller.ActualDocument;
            location.PageIndex = Controller.ActualPage;
              }

              NotifyContextServiceListeners(this, new NotifyContextServiceListenersEventArgs(typeof(TPadLocation), location));
        }
コード例 #2
0
        private void ProcessAreaTriggers(TPadLocation tPadLocation, Point locationPx)
        {
            if (tPadLocation.PageIndex != 2)
            return;

              Rect deviceCenterArea = new Rect(new Point(-100, -100), new Size(200, 200));
              deviceCenterArea.Offset(locationPx.X, locationPx.Y);

              Point areaTrigger = new Point(950, 1200);

              if (deviceCenterArea.Contains(areaTrigger))
              {
            //if (isPlaying)
            //  return;

            System.Windows.Interop.HwndSource hwndSource = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
            System.Windows.Interop.HwndTarget hwndTarget = hwndSource.CompositionTarget;
            hwndTarget.RenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;

            //Console.WriteLine("meVideo.Play();");
            meVideo.Visibility = System.Windows.Visibility.Visible;
            meVideo.Play();
            isPlaying = true;
              }
              else if (isPlaying)
              {
            //Console.WriteLine("meVideo.Pause();");
            //meVideo.Visibility = System.Windows.Visibility.Collapsed;
            //meVideo.Pause();
            //isPlaying = false;
              }
        }
コード例 #3
0
ファイル: RegistrationService.cs プロジェクト: hcilab-um/tPad
        private void GetLocationFromTracker()
        {
            //status -1: not detected, status 1: location detected,
              //status 0: previous image and current image are the same -> no new location computation necessary
              if (status == 1)
              {
            trigger = 0;

            location = new TPadLocation();
            location.Status = LocationStatus.Located;
            location.RotationAngle = ClampedAngle(Tracker.RotationAngle);

            Point locationPx = new Point(Tracker.LocationPxM.X / Controller.SimCaptureToSourceImageRatio,
             Tracker.LocationPxM.Y / Controller.SimCaptureToSourceImageRatio);
            location.LocationCm = new Point((float)(locationPx.X / Controller.WidthFactor),
              (float)(locationPx.Y / Controller.HeightFactor));

            //TODO: get Document object from featureTracker
            location.Document = Controller.ActualDocument;
            location.PageIndex = Tracker.PageIdx;
              }
              else if (status == -1 && trigger > 10)
              {
            location = new TPadLocation();
            location.Status = LocationStatus.NotLocated;
              }
              else if (status == -1)
              {
            trigger++;
              }
        }
コード例 #4
0
        private void LoadDocument(TPadLocation newLocation)
        {
            if (newLocation.Document == null)
            throw new Exception("Document cannot be null");

              if (!DbDocuments.ContainsKey(newLocation.Document.ID))
              {
            Dispatcher.Invoke(DispatcherPriority.Render,
            (Action)delegate()
            {
              DocumentLoader loader = new DocumentLoader();
              ActiveReaderDocument lookup = loader.LoadDocument(newLocation.Document);
              DbDocuments.Add(lookup.ID, lookup);
            });
              }

              //1- Loads the layers should they exist in disk
              ActualDocument = DbDocuments[newLocation.Document.ID];
              PdfHelper = new PDFContentHelper(ActualDocument.FileName);
              PdfHelper.LoadLayersFromDisk(ActualDocument, Core.Device.ID);

              //3- Load layers for current page
              ActualPage = newLocation.PageIndex;
              LoadLayersToPage(ActualDocument, ActualPage);
        }