• 大小: 177KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: c#源码  

资源简介

c#源码手写识别,比较基础,做手写键盘需要单独处理 主要识别通过 Microsoft.Ink.dll

资源截图

代码片段和文件信息

using Microsoft.Ink;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Handwriting
{
    public partial class Form1 : Form
    {

        InkCollector ic;
        RecognizerContext rct;
              string FullCACText;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {
            ic = new InkCollector(ink_here.Handle);
            this.ic.Stroke += new InkCollectorStrokeEventHandler(ic_Stroke);
            ic.Enabled = true;
            ink_();

            this.rct.RecognitionWithAlternates += new RecognizerContextRecognitionWithAlternatesEventHandler(rct_RecognitionWithAlternates);
            //单字识别
            rct.RecognitionFlags = RecognitionModes.WordMode;
            rct.Strokes = ic.Ink.Strokes;
        }

        void rct_RecognitionWithAlternates(object sender RecognizerContextRecognitionWithAlternatesEventArgs e)
        {

            string ResultString = ““;
            RecognitionAlternates alts;

            if (e.RecognitionStatus == RecognitionStatus.NoError)
            {
                alts = e.Result.GetAlternatesFromSelection();
                Console.WriteLine(alts.Count);
                foreach (RecognitionAlternate alt in alts)
                {
                    ResultString = ResultString + alt.ToString() + “ “;
                }
            }
            FullCACText = ResultString.Trim();
            Console.WriteLine(FullCACText);
            Control.CheckForIllegalCrossThreadCalls = false;
            GetString(FullCACText);
            Control.CheckForIllegalCrossThreadCalls = true;

        }

        private void GetString(string txt)
        {
            string[] str_temp = txt.Split(‘ ‘);
            string str_temp1 = “shibie_“;
            string str_temp2 = ““;
            if (str_temp.Length > 0)
            {
                for (int i = 0; i < str_temp.Length; i++)
                {
                    str_temp2 = str_temp1 + i.ToString();
                    Control[] con_temp = panel2.Controls.Find(str_temp2 true);
                    if (con_temp.Length > 0)
                    {
                        Button btn = (Button)(con_temp[0]);
                        btn.Text = str_temp[i];
                    }
                }
            }
        }

        void ic_Stroke(object sender InkCollectorStrokeEventArgs e)
        {
            rct.StopBackgroundRecognition();
            rct.Strokes.Add(e.Stroke);
            rct.BackgroundRecognizeWithAlternates(0);
        }

        private void ink_()
        {
            Recognizers recos = new Recognizers();
            Recognizer chineseReco = recos.GetDefaultRecognizer();

            rct = chineseReco.Create

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      15872  2018-09-13 11:46  Handwriting\bin\Release\Handwriting.exe

     文件      26112  2018-09-13 11:46  Handwriting\bin\Release\Handwriting.pdb

     文件      24224  2018-09-13 11:47  Handwriting\bin\Release\Handwriting.vshost.exe

     文件        490  2018-04-12 07:35  Handwriting\bin\Release\Handwriting.vshost.exe.manifest

     文件     507904  2012-08-10 23:13  Handwriting\bin\Release\Microsoft.Ink.dll

     文件       5745  2018-09-13 11:46  Handwriting\Form1.cs

     文件      13448  2018-09-13 11:46  Handwriting\Form1.Designer.cs

     文件       6211  2018-09-13 11:46  Handwriting\Form1.resx

     文件       3994  2018-09-11 15:28  Handwriting\Handwriting.csproj

     文件       6869  2018-09-11 15:20  Handwriting\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       6327  2018-09-11 15:22  Handwriting\obj\Release\DesignTimeResolveAssemblyReferences.cache

     文件       6968  2018-09-11 15:22  Handwriting\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache

     文件        695  2018-09-13 11:47  Handwriting\obj\Release\Handwriting.csproj.FileListAbsolute.txt

     文件        977  2018-09-13 11:46  Handwriting\obj\Release\Handwriting.csproj.GenerateResource.Cache

     文件      15872  2018-09-13 11:46  Handwriting\obj\Release\Handwriting.exe

     文件        180  2018-09-13 11:46  Handwriting\obj\Release\Handwriting.Form1.resources

     文件      26112  2018-09-13 11:46  Handwriting\obj\Release\Handwriting.pdb

     文件        180  2018-09-13 11:46  Handwriting\obj\Release\Handwriting.Properties.Resources.resources

     文件        492  2018-09-11 15:20  Handwriting\Program.cs

     文件       1346  2018-09-11 15:20  Handwriting\Properties\AssemblyInfo.cs

     文件       2874  2018-09-11 15:20  Handwriting\Properties\Resources.Designer.cs

     文件       5612  2018-09-11 15:20  Handwriting\Properties\Resources.resx

     文件       1098  2018-09-11 15:20  Handwriting\Properties\Settings.Designer.cs

     文件        249  2018-09-11 15:20  Handwriting\Properties\Settings.settings

     目录          0  2018-09-11 15:20  Handwriting\obj\Debug\TempPE

     目录          0  2018-09-11 15:20  Handwriting\obj\Release\TempPE

     目录          0  2018-09-11 15:20  Handwriting\bin\Debug

     目录          0  2018-09-13 11:46  Handwriting\bin\Release

     目录          0  2018-09-11 15:20  Handwriting\obj\Debug

     目录          0  2018-09-13 11:46  Handwriting\obj\Release

............此处省略7个文件信息

评论

共有 条评论