基于SnapDragonBoard410C的手势识别

来源:互联网 发布:开源网络行为管理 编辑:程序博客网 时间:2024/05/17 01:49

目前在物联网的领域里有许多的交互手段,例如语音交互,手势交互,手柄交互。今天我们就来了解下啥是手势交互!措辞有点糙,请大家见谅。

First:we should download a SDK package from internet.it’s called Touch3D
接下来主要是是向大家介绍这个SDK 是如何集成到我们的应用当中去。

       mCameraEventListener = new CameraEventListener();        mImageRotationListener = new RotationListener();        // Create camera wrapper to handle camera functionality        mCameraWrapper = new CameraWrapper();        // Create touchless wrapper to handle gesture functionality        mTouchlessA3DWrapper = new TouchlessA3DWrapper(new TouchlessEventListener());        // Create helper for managing camera image rotation.        mImageRotationHelper = new ImageRotationHelper(this);

在oncreat中我们先把mTouchlessA3DWrapper对象先实例化。

 private class TouchlessEventListener implements TouchlessA3DWrapper.TouchlessEventListener {        @Override        public void openHandFound() {            // Dispatch UI updates to UI thread            runOnUiThread(new Runnable() {                @Override                public void run() {                    mPoseView.showOpenHand();                }            });        }        @Override        public void closedHandFound() {            // Dispatch UI updates to UI thread            runOnUiThread(new Runnable() {                @Override                public void run() {                    mPoseView.showClosedHand();                }            });        }        @Override        public void pinchFound() {            // Dispatch UI updates to UI thread            runOnUiThread(new Runnable() {                @Override                public void run() {                    mPoseView.showPinch();                }            });        }        @Override        public void thumbsUpFound() {            // Dispatch UI updates to UI thread            runOnUiThread(new Runnable() {                @Override                public void run() {                    mPoseView.showThumbsUp();                }            });        }        @Override        public void poseLost() {            // Dispatch UI updates to UI thread            runOnUiThread(new Runnable() {                @Override                public void run() {                    mPoseView.hideHand();                }            });        }        @Override        public void onError(final Exception e) {            Log.e(LOG_TAG, "TouchlessEventListener.onError: ", e);            // Dispatch event to main queue to update UI            runOnUiThread(new Runnable() {                @Override                public void run() {                    Toast.makeText(TouchlessWorldActivity.this,                            "Error reported from touchless engine. See logs for more info.",                            Toast.LENGTH_LONG).show();                }            });        }    }

PoseView是我们自定的view用于显示手势识别成功后显示相应的图片。
CameraWrapper这个类当中主要是封装我们一些操作Camera的一些方法和数据回调。

 private class ImageAvailableListener implements ImageReader.OnImageAvailableListener {        @Override        public void onImageAvailable(ImageReader imageReader) {            Image image = imageReader.acquireLatestImage();            if (image != null) {                int imageWidth = image.getWidth();                int imageHeight = image.getHeight();                //Get Y-plane of the YUV_420_888 image.                Image.Plane yPlane = image.getPlanes()[0];                //Copy plane to a new byte array, skipping row stride.                byte[] bytes = copyPlaneDataToPackedByteArray(yPlane, imageWidth, imageHeight);                //Convert timestamp to milliseconds.                long timestampMilliseconds = (long)(image.getTimestamp() / 1e6f);                if(mCameraEventListener != null) {                    mCameraEventListener.onFrame(bytes, image.getWidth(), image.getHeight(), timestampMilliseconds);//回调数据给Activity!                }                // Return image to image reader for reuse.                image.close();            }        }        private byte[] copyPlaneDataToPackedByteArray(Image.Plane yPlane, int imageWidth, int imageHeight) {            // Create destination buffer            byte[] bytes = new byte[imageWidth * imageHeight];            ByteBuffer buffer = yPlane.getBuffer();            int strideSkip = yPlane.getRowStride() - imageWidth;            // For every row of destination image            for (int row = 0; buffer.hasRemaining(); row += imageWidth) {                // Copy bytes to destination                buffer.get(bytes, row, imageWidth);                // On last row we mus make sure we have room for the stride skip                if(buffer.hasRemaining()) {                    // Skip stride                    buffer.position(buffer.position() + strideSkip);                }            }            return bytes;        }    }

TouchlessA3DWrapper这个类主要是封装了一些手势识别的操作!

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 孩子情商低怎么办 孩子没有自信心怎么办 孩子没有信心怎么办 孩子胆子小怎么办 孩子缺乏自信怎么办 孩子不自信怎么办 孩子逆反严重怎么办 小学生写字不好看怎么办 小学语文成绩差怎么办 高中计算能力差怎么办 小学生成绩差怎么办 一年级成绩不好怎么办 儿童记忆力差怎么办 普法考试不及格怎么办 网络成瘾怎么办 小孩子网瘾怎么办 小孩沉迷手机怎么办 青少年睡眠不好怎么办 职业资格取消后怎么办 三相缺一相怎么办 电机缺相怎么办 三相电缺相怎么办 左右脸不对称怎么办 脸很不对称怎么办 面部不对称怎么办 三相电偏相怎么办 发电机启动不了怎么办 功率因数超前怎么办 三相电流不平衡怎么办 初中生复读学籍怎么办 不动精子56.6怎么办 精子头部缺陷怎么办 精子畸形高怎么办 遇到水逆怎么办 椎动脉硬化怎么办 严重脑供血不足怎么办 椎基底动脉怎么办 基底动脉狭窄怎么办 得了腔隙性脑梗怎么办 腔隙性脑梗塞怎么办 店铺被释放怎么办