Exemplo n.º 1
0
        public void recognize()
        {
            RenderTargetBitmap rtb = new RenderTargetBitmap((int)m_InkCanvas.ActualWidth, (int)m_InkCanvas.ActualHeight, 96d, 96d, PixelFormats.Default);
            DrawingVisual      dv  = new DrawingVisual();

            using (DrawingContext dc = dv.RenderOpen())
            {
                VisualBrush vb = new VisualBrush(m_InkCanvas);
                dc.DrawRectangle(vb, null, new System.Windows.Rect(new System.Windows.Point(), new System.Windows.Size(

                                                                       m_InkCanvas.ActualWidth, m_InkCanvas.ActualHeight)));

                dc.Close();
                rtb.Render(dv);
            }

            int       x      = (int)(sketch.GetBounds().TopLeft.X);
            int       y      = (int)Math.Min(sketch.GetBounds().TopLeft.Y, sketch.GetBounds().TopRight.Y);
            int       width  = (int)(sketch.GetBounds().TopRight.X - sketch.GetBounds().TopLeft.X);
            int       height = (int)(sketch.GetBounds().BottomLeft.Y - sketch.GetBounds().TopLeft.Y);
            Int32Rect rect   = new Int32Rect(x, y, width, height);

            BitmapSource     bs      = new CroppedBitmap(rtb, rect);
            BmpBitmapEncoder encoder = new BmpBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bs));

            FileStream fs = File.Open("Data\\Test.bmp", FileMode.Create);

            encoder.Save(fs);
            fs.Close();

            int pClass;

            double[] probs = UILogic.RecognizeSketch("Data\\Test.bmp", out pClass);

            UILogic.FillSuggestions(probs, m_B1, m_B2, m_B3);
        }
Exemplo n.º 2
0
 private void ExportButton_Click(object sender, RoutedEventArgs e)
 {
     UILogic.ExportBitmap();
 }
Exemplo n.º 3
0
 private void EraserButton_Click(object sender, RoutedEventArgs e)
 {
     UILogic.EnterEraserMode();
 }
Exemplo n.º 4
0
 private void DrawingModeButton_Click(object sender, RoutedEventArgs e)
 {
     UILogic.EnterDrawingMode();
 }
Exemplo n.º 5
0
 private void ClearInkCanvasButton_Click(object sender, RoutedEventArgs e)
 {
     UILogic.ClearInkCanvas();
 }
Exemplo n.º 6
0
 public MainWindow()
 {
     InitializeComponent();
     UILogic.InitGestureRecognition(System.Environment.CurrentDirectory, this);
 }