Android studio 手写输入字体,自动识别

news/2024/10/22 7:15:57/
  • 效果图
    在这里插入图片描述

  • 布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="手写字体识别:"android:textSize="24sp"/><!-- 绘制手势的GestureOverlayView   --><android.gesture.GestureOverlayViewandroid:id="@+id/gestures1"android:layout_width="fill_parent"android:layout_height="fill_parent"android:gestureStrokeType="multiple"android:eventsInterceptionEnabled="false"android:orientation="vertical"/>
</LinearLayout>
  • 处理
import androidx.appcompat.app.AppCompatActivity;import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;import java.util.ArrayList;public class StartActivity3 extends AppCompatActivity implements GestureOverlayView.OnGesturePerformedListener, GestureOverlayView.OnGesturingListener {GestureLibrary mLibrary;GestureOverlayView mDrawGestureView;TextView txt;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_start3);txt = findViewById(R.id.textView1);mDrawGestureView=findViewById(R.id.gestures1);mLibrary = GestureLibraries.fromRawResource(this,R.raw.gestures);if(!mLibrary.load()){finish();}//设置手势可多笔画绘制,默认情况为单笔画绘制mDrawGestureView.setGestureStrokeType(GestureOverlayView.GESTURE_STROKE_TYPE_MULTIPLE);//设置手势的颜色(蓝色)mDrawGestureView.setGestureColor(getResources().getColor(R.color.purple_200));//设置还没未能形成手势绘制是的颜色(红色)mDrawGestureView.setUncertainGestureColor(Color.RED);//设置手势的粗细mDrawGestureView.setGestureStrokeWidth(10);/*手势绘制完成后淡出屏幕的时间间隔,即绘制完手指离开屏幕后相隔多长时间手势从屏幕上消失;* 可以理解为手势绘制完成手指离开屏幕后到调用onGesturePerformed的时间间隔* 默认值为420毫秒,这里设置为2秒*/mDrawGestureView.setFadeOffset(2000);//绑定监听器mDrawGestureView.addOnGesturePerformedListener(this);mDrawGestureView.addOnGesturingListener(this);}@Overridepublic void onGesturingStarted(GestureOverlayView gestureOverlayView) {System.out.println("关于手势开始---");}@Overridepublic void onGesturingEnded(GestureOverlayView gestureOverlayView) {System.out.println("关于手势结束---");}@Overridepublic void onGesturePerformed(GestureOverlayView gestureOverlayView, Gesture gesture) {System.out.println("关于手势执行---"+gesture);ArrayList predictions=mLibrary.recognize(gesture);if(predictions.size()>0){Prediction prediction = (Prediction)predictions.get(0);if(prediction.score > 1.0){Toast.makeText(this,prediction.name,Toast.LENGTH_SHORT).show();txt.append(prediction.name);}}}
}

在这里插入图片描述

  • 手势库

链接:https://pan.baidu.com/s/1yDFBneXG3X8_eBQmysET6g
提取码:xxw3

  • 只能识别字母,没有字体的识别库,那位博友如果有字体库,麻烦分享个链接

http://www.ppmy.cn/news/695529.html

相关文章

快速打开搜狗输入法手写输入(快捷键)

先同时按&#xff1b;X&#xff08;同时按分号键X&#xff09; 然后再按X键

Mac如何设置手写输入?

有的小伙伴在手机上习惯了手写&#xff0c;就跟佐佐提出问题了&#xff0c;到了 Mac 电脑上怎么设置手写输入呢&#xff1f;很多第三方输入法都带有手写输入的功能&#xff0c;其实 Mac 上也自带有手写输入法&#xff0c;利用触控板&#xff0c;可以很方便的实现手写输入&#…

oracle字典在线查字手写,在线字典手写输入

【www.shanpow.com--成语歇后语】 在线字典手写输入篇(一):新华字典手写查字 手写 马的成语 灯谜 疯狂猜成语 【新华字典】可查询汉字20973个,含解释及示例、词性与应用(其中包括3000多个多音字),并可进行“拼音码、五笔码、部首、任意笔画”与汉字互查;支持“同韵字”查询…

电子文档秒变手写文字:这个工具绝了!!

今天给大家带来了一款比较实用的小软件。它能干什么呢&#xff1f;它能让电子文档&#xff08;如word文档等等&#xff09;转换成手写文字图片。 软件名字叫手写模拟器&#xff0c;压缩包大小在59MB左右&#xff0c;免费无广告&#xff0c;是个绿色软件。 软件启动方法很简单&a…

手写.

IOU """ #检测 A: 左下角坐标(left_x,left_y) 右上角坐标(right_x,right_y) B: 左下角坐标(left_x,left_y) 右上角坐标(right_x,right_y) """def IOU(rectangle A, rectangleB):W min(A.right_x, B.right_x) - max(A.left_x, B.left_x)H min(…

android 输入法(包括手写界面)

公司要开发自己的输入法&#xff0c;找了很多例子&#xff0c;都不是自己想要的。android本身的例子不能满足特殊布局的要求&#xff0c;而且没有手写输入&#xff0c;虽然在例子上实现了手写输入但是布局仍然调不好。花了很长时间来分析代码&#xff0c;太累了&#xff0c;决定…

手写识别(一)

文章目录 前言一、环境介绍二、训练模型2.1 前向传播2.2 后向传播2.3 测试模型2.4 提取图像 三、提取参数总结 前言 纸上得来终觉浅&#xff0c;绝知此事要躬行。我们已经学习了神经网络理论知识&#xff0c;从这节课开始试着使用FPGA来部署神经网络模型&#xff0c;实现手写识…

android手写输入

http://www.iteye.com/topic/288045 你可以在线测试&#xff1a; http://quake.3322.org/我最先google到一个开源的手写输入引擎是Tomoe: http://tomoe.sourceforge.jp&#xff0c;它包括识别引擎&#xff0c;整套的用户界面&#xff08;GTK&#xff09;以及SCIM的输入法模块&…