Exemplo n.º 1
0
        void focus_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (_phoneCamera != null)
            {
                if (_phoneCamera.IsFocusAtPointSupported == true)
                {
                    // Determine the location of the tap.
                    Point tapLocation = e.GetPosition(viewfinderCanvas);

                    // Position the focus brackets with the estimated offsets.
                    focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                    focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                    // Determine the focus point.
                    double focusXPercentage = tapLocation.X / viewfinderCanvas.ActualWidth;
                    double focusYPercentage = tapLocation.Y / viewfinderCanvas.ActualHeight;

                    // Show the focus brackets and focus at point.
                    try
                    {
                        focusBrackets.Visibility = Visibility.Visible;
                        _phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (_phoneCamera != null)
            {
                if (_phoneCamera.IsFocusAtPointSupported == true)
                {
                    Point tapLocation = e.GetPosition(viewfinderCanvas);

                    focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                    focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                    double focusXPercentage = tapLocation.X / viewfinderCanvas.ActualWidth;
                    double focusYPercentage = tapLocation.Y / viewfinderCanvas.ActualHeight;

                    focusBrackets.Visibility = Visibility.Visible;
                    try
                    {
                        _phoneCamera.FocusAtPoint(focusXPercentage, focusYPercentage);
                    }
                    catch (Exception xe)
                    {
                        MessageBox.Show("Can't recognize BarCode");
                        NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Starts a camera auto focus operation on a specific point in the viewfinder, for those devices that support it.
 /// </summary>
 /// <param name="x">The horizontal location in the viewfinder; a value between 0 (left) and 1.0 (right).</param>
 /// <param name="y">The vertical location in the viewfinder; a value between 0 (bottom) and 1.0 (top).</param>
 public void FocusAtPoint(double x, double y)
 {
     if (_photoCamera.IsFocusAtPointSupported)
     {
         try
         {
             _photoCamera.FocusAtPoint(x, y);
         }
         catch
         {
         }
     }
 }
Exemplo n.º 4
0
        // Provide touch focus in the viewfinder.
        void focus_Tapped(object sender, GestureEventArgs e)
        {
            if (cam != null)
            {
                if (cam.IsFocusAtPointSupported == true)
                {
                    try
                    {
                        // Determine location of tap.
                        Point tapLocation = e.GetPosition(viewfinderCanvas);

                        // Position focus brackets with estimated offsets.
                        focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                        focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                        // Determine focus point.
                        double focusXPercentage = tapLocation.X / viewfinderCanvas.Width;
                        double focusYPercentage = tapLocation.Y / viewfinderCanvas.Height;

                        // Show focus brackets and focus at point
                        focusBrackets.Visibility = Visibility.Visible;
                        cam.FocusAtPoint(focusXPercentage, focusYPercentage);

                        // Write a message to the UI.
                        this.Dispatcher.BeginInvoke(delegate()
                        {
                            txtDebug.Text = String.Format("Camera focusing at point: {0:N2} , {1:N2}", focusXPercentage, focusYPercentage);
                        });
                    }
                    catch (Exception focusError)
                    {
                        // Cannot focus when a capture is in progress.
                        this.Dispatcher.BeginInvoke(delegate()
                        {
                            // Write a message to the UI.
                            txtDebug.Text = focusError.Message;
                            // Hide focus brackets.
                            focusBrackets.Visibility = Visibility.Collapsed;
                        });
                    }
                }
                else
                {
                    // Write a message to the UI.
                    this.Dispatcher.BeginInvoke(delegate()
                    {
                        txtDebug.Text = "Camera does not support FocusAtPoint().";
                    });
                }
            }
        }
Exemplo n.º 5
0
 public void Focus(Point point)
 {
     try
     {
         if (_photoCamera.IsFocusAtPointSupported)
         {
             _photoCamera.FocusAtPoint(point.X, point.Y);
         }
         else if (_photoCamera.IsFocusSupported)
         {
             _photoCamera.Focus();
         }
     }
     catch { }
 }
Exemplo n.º 6
0
        public bool takePhoto()
        {
            System.Diagnostics.Debug.WriteLine("takePhoto");
            if (cam == null)
            {
                return(false);
            }
            try
            {
                cam.FocusAtPoint(0.5, 0.5);
            }
            catch
            {
                // Probably still taking a previous photo.
                System.Diagnostics.Debug.WriteLine("fail");
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
        // Provide touch focus in the viewfinder.
        void focus_Tapped(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (cam != null)
            {
                if (cam.IsFocusAtPointSupported == true)
                {
                    try
                    {
                        // Determine location of tap.
                        Point tapLocation = e.GetPosition(viewfinderCanvas);

                        // Position focus brackets with estimated offsets.
                        focusBrackets.SetValue(Canvas.LeftProperty, tapLocation.X - 30);
                        focusBrackets.SetValue(Canvas.TopProperty, tapLocation.Y - 28);

                        // Determine focus point.
                        double focusXPercentage = tapLocation.X / viewfinderCanvas.Width;
                        double focusYPercentage = tapLocation.Y / viewfinderCanvas.Height;

                        // Show focus brackets and focus at point
                        focusBrackets.Visibility = Visibility.Visible;
                        cam.FocusAtPoint(focusXPercentage, focusYPercentage);
                    }
                    catch (Exception ex)
                    {
                        LittleWatson.ReportException(ex);

                        // Cannot focus when a capture is in progress.
                        this.Dispatcher.BeginInvoke(delegate()
                        {
                            // Hide focus brackets.
                            focusBrackets.Visibility = Visibility.Collapsed;
                        });
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void callback(object sender, EventArgs e)
        {
            cam.FocusAtPoint(r, r);
            r = 1 - r;
            cam.Focus();
            textBlock1 = Globals.textBlock2;
            //if (Globals.tickCount % 50 == 0)
            //{
            //    System.Diagnostics.Debug.WriteLine(st.ElapsedMilliseconds/50);
            //    st.Reset();
            //    st.Start();
            //}

            PhotoCamera phCam = (PhotoCamera)cam;

            for (int i = Globals.n1 - 1; i > 0; i--)
            {
                Globals.x1[i] = Globals.x1[i - 1];
            }

            //pauseFramesEvent.WaitOne();
            phCam.GetPreviewBufferArgb32(ARGBPx);
            int tempVal = 0;

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    tempVal += (ARGBPx[j * (int)rect1.Width + i] >> 16) & 0xFF;
                }
            }
            //  tempVal+= (ARGBPx[(int)rect1.Width*(((int)rect1.Height+1)/2 - 50+i)]>>16)&0xFF;
            tempVal        /= 25;
            Globals.x1[0]   = tempVal;
            textBlock1.Text = Globals.x1[0] + "";
            Globals.lpf();
        }
Exemplo n.º 9
0
 void ScannerControl_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     if (_currentCamera != null)
     {
         try
         {
             if (_currentCamera.IsFocusAtPointSupported)
             {
                 var    pt = e.GetPosition(this);
                 double x  = pt.X / this.ActualWidth;
                 double y  = pt.Y / this.ActualHeight;
                 _currentCamera.FocusAtPoint(x, y);
             }
             else if (_currentCamera.IsFocusSupported)
             {
                 _currentCamera.Focus();
             }
         }
         catch (Exception)
         {
             //for many reason focus may fail son we catch the error quietly
         }
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Starts a camera auto focus operation on a specific point in the viewfinder, for those devices that support it.
 /// </summary>
 /// <param name="x">The horizontal location in the viewfinder; a value between 0 (left) and 1.0 (right).</param>
 /// <param name="y">The vertical location in the viewfinder; a value between 0 (top) and 1.0 (bottom).</param>
 /// <remarks>
 /// This method is already protected and only called when the service is currently running.
 /// </remarks>
 protected override void FocusCameraAtPoint(double x, double y)
 {
     _photoCamera.FocusAtPoint(x, y);
 }