没有合适的资源?快使用搜索试试~ 我知道了~
首页AndroidStudio:手势识别
AndroidStudio:手势识别
11 下载量 194 浏览量
更新于2023-05-12
评论 4
收藏 98KB PDF 举报
主要介绍了AndroidStudio手势识别,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
资源详情
资源评论
资源推荐
AndroidStudio:手势识别:手势识别
主要介绍了AndroidStudio手势识别,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友
们下面随着小编来一起学习学习吧
一内容:设计一个手写字体识别程序。
二实现
①建立一个存放手写字体的数据库
②activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gesture:"
android:id="@+id/tv"
android:textSize="24dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="clear"
android:id="@+id/bt"/>
<android.gesture.GestureOverlayView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gestureStrokeType="multiple"
android:eventsInterceptionEnabled="false"
android:orientation="vertical"
android:id="@+id/gesture"></android.gesture.GestureOverlayView>
</LinearLayout
3.MainActivity.java
package com.example.myapplication;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity implements GestureOverlayView.OnGesturePerformedListener {
GestureLibrary mLibrary; //定义手势库对象
GestureOverlayView gest; //定义手势视图对象做画板之用
TextView txt;
Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gest = (GestureOverlayView)findViewById(R.id.gesture);
gest.addOnGesturePerformedListener(this); // 注册手势识别的监听器
txt = (TextView)findViewById(R.id.tv);
mLibrary = GestureLibraries.fromRawResource(this,R.raw.gestures); //加载手势库
bt = (Button)findViewById(R.id.bt);
bt.setOnClickListener(new Click());
if (!mLibrary.load()) {
finish();
}
}
/*根据画的手势识别是否匹配手势库里的手势*/
@Override
public void onGesturePerformed(GestureOverlayView gest, Gesture gesture) {
ArrayList gestList = mLibrary.recognize(gesture); // 从手势库获取手势数据
if (gestList.size() > 0) {
Prediction pred = (Prediction)gestList.get(0);
if (pred.score > 1.0) { // 检索到匹配的手势
Toast.makeText(this,pred.name,Toast.LENGTH_SHORT).show();
txt.append(pred.name);
}
weixin_38699551
- 粉丝: 4
- 资源: 909
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- zigbee-cluster-library-specification
- JSBSim Reference Manual
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0