当前位置: 首页>>代码示例>>Java>>正文


Java Accelerometer类代码示例

本文整理汇总了Java中com.iflytek.cloud.util.Accelerometer的典型用法代码示例。如果您正苦于以下问题:Java Accelerometer类的具体用法?Java Accelerometer怎么用?Java Accelerometer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Accelerometer类属于com.iflytek.cloud.util包,在下文中一共展示了Accelerometer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.iflytek.cloud.util.Accelerometer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	setContentView(R.layout.videover_layout);
	SpeechUtility.createUtility(this, "appid=" + getString(R.string.app_id));
	initUI();
	mFaceRequest = new FaceRequest(this);
	nv21 = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
	buffer = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
	mAcc = new Accelerometer(VideoVerify.this);
	mFaceDetector = FaceDetector.createDetector(VideoVerify.this, null);
	
	//authorid = (EditText)findViewById(R.id.authorid);
	
}
 
开发者ID:JosephPai,项目名称:WithYou,代码行数:17,代码来源:VideoVerify.java

示例2: onCreate

import com.iflytek.cloud.util.Accelerometer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    SpeechUtility.createUtility(this, "appid=58c8e767");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_video);
    initUI();
    nv21 = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
    buffer = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
    mAcc = new Accelerometer(BaseVideoActivity.this);
    mFaceDetector = FaceDetector.createDetector(BaseVideoActivity.this, null);
}
 
开发者ID:tony-Shx,项目名称:Swface,代码行数:12,代码来源:BaseVideoActivity.java

示例3: onCreate

import com.iflytek.cloud.util.Accelerometer; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	SpeechUtility.createUtility(this, "appid=58c8e767");
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_video);
	initUI();
	nv21 = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
	buffer = new byte[PREVIEW_WIDTH * PREVIEW_HEIGHT * 2];
	mAcc = new Accelerometer(VideoRecognise.this);
	mFaceDetector = FaceDetector.createDetector(VideoRecognise.this, null);
}
 
开发者ID:HuaDanJson,项目名称:FaceAI_Android,代码行数:12,代码来源:VideoRecognise.java

示例4: onResume

import com.iflytek.cloud.util.Accelerometer; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();

    if (null != mAcc) {
        mAcc.start();
    }

    mStopTrack = false;
    new Thread(new Runnable() {

        @Override
        public void run() {
            while (!mStopTrack) {
                if (null == nv21) {
                    continue;
                }

                synchronized (nv21) {
                    System.arraycopy(nv21, 0, buffer, 0, nv21.length);
                }

                // 获取手机朝向,返回值0,1,2,3分别表示0,90,180和270度
                int direction = Accelerometer.getDirection();
                boolean frontCamera = (Camera.CameraInfo.CAMERA_FACING_FRONT == mCameraId);
                // 前置摄像头预览显示的是镜像,需要将手机朝向换算成摄相头视角下的朝向。
                // 转换公式:a' = (360 - a)%360,a为人眼视角下的朝向(单位:角度)
                if (frontCamera) {
                    // SDK中使用0,1,2,3,4分别表示0,90,180,270和360度
                    direction = (4 - direction)%4;
                }

                if(mFaceDetector == null) {

                    // 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
                    showTip( "创建对象失败,请确认 libmsc.so 放置正确,\n 且有调用 createUtility 进行初始化" );
                    break;
                }

                String result = mFaceDetector.trackNV21(buffer, PREVIEW_WIDTH, PREVIEW_HEIGHT, isAlign, direction);
                //Log.d(TAG, "result:"+result);

                FaceRect[] faces = ParseResult.parseResult(result);

                Canvas canvas = mFaceSurface.getHolder().lockCanvas();
                if (null == canvas) {
                    continue;
                }

                canvas.drawColor(0, PorterDuff.Mode.CLEAR);
                canvas.setMatrix(mScaleMatrix);

                if( faces == null || faces.length <=0 ) {
                    mFaceSurface.getHolder().unlockCanvasAndPost(canvas);
                    continue;
                }

                if (null != faces && frontCamera == (Camera.CameraInfo.CAMERA_FACING_FRONT == mCameraId)) {
                    for (FaceRect face: faces) {
                        face.bound = PictureUtil.RotateDeg90(face.bound, PREVIEW_WIDTH, PREVIEW_HEIGHT);
                        if (face.point != null) {
                            for (int i = 0; i < face.point.length; i++) {
                                face.point[i] = PictureUtil.RotateDeg90(face.point[i], PREVIEW_WIDTH, PREVIEW_HEIGHT);
                            }
                        }
                        PictureUtil.drawFaceRect(canvas, face, PREVIEW_WIDTH, PREVIEW_HEIGHT,
                                frontCamera, false);
                    }
                } else {
                    Log.d(TAG, "faces:0");
                }

                mFaceSurface.getHolder().unlockCanvasAndPost(canvas);
            }
        }
    }).start();
}
 
开发者ID:tony-Shx,项目名称:Swface,代码行数:78,代码来源:BaseVideoActivity.java

示例5: onResume

import com.iflytek.cloud.util.Accelerometer; //导入依赖的package包/类
@Override
protected void onResume() {
	super.onResume();

	if (null != mAcc) {
		mAcc.start();
	}

	mStopTrack = false;
	new Thread(new Runnable() {

		@Override
		public void run() {
			while (!mStopTrack) {
				if (null == nv21) {
					continue;
				}

				synchronized (nv21) {
					System.arraycopy(nv21, 0, buffer, 0, nv21.length);
				}

				// 获取手机朝向,返回值0,1,2,3分别表示0,90,180和270度
				int direction = Accelerometer.getDirection();
				boolean frontCamera = (CameraInfo.CAMERA_FACING_FRONT == mCameraId);
				// 前置摄像头预览显示的是镜像,需要将手机朝向换算成摄相头视角下的朝向。
				// 转换公式:a' = (360 - a)%360,a为人眼视角下的朝向(单位:角度)
				if (frontCamera) {
					// SDK中使用0,1,2,3,4分别表示0,90,180,270和360度
					direction = (4 - direction) % 4;
				}

				if (mFaceDetector == null) {
					/**
					 * 离线视频流检测功能需要单独下载支持离线人脸的SDK
					 * 请开发者前往语音云官网下载对应SDK
					 */
					// 创建单例失败,与 21001 错误为同样原因,参考 http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=9688
					showTip("创建对象失败,请确认 libmsc.so 放置正确,\n 且有调用 createUtility 进行初始化");
					break;
				}

				String result = mFaceDetector.trackNV21(buffer, PREVIEW_WIDTH, PREVIEW_HEIGHT, isAlign, direction);
				Log.d(TAG, "result:" + result);

				FaceRect[] faces = ParseResult.parseResult(result);

				Canvas canvas = mFaceSurface.getHolder().lockCanvas();
				if (null == canvas) {
					continue;
				}

				canvas.drawColor(0, PorterDuff.Mode.CLEAR);
				canvas.setMatrix(mScaleMatrix);

				if (faces == null || faces.length <= 0) {
					mFaceSurface.getHolder().unlockCanvasAndPost(canvas);
					continue;
				}

				if (null != faces && frontCamera == (CameraInfo.CAMERA_FACING_FRONT == mCameraId)) {
					for (FaceRect face : faces) {
						face.bound = FaceUtil.RotateDeg90(face.bound, PREVIEW_WIDTH, PREVIEW_HEIGHT);
						if (face.point != null) {
							for (int i = 0; i < face.point.length; i++) {
								face.point[i] = FaceUtil.RotateDeg90(face.point[i], PREVIEW_WIDTH, PREVIEW_HEIGHT);
							}
						}
						FaceUtil.drawFaceRect(canvas, face, PREVIEW_WIDTH, PREVIEW_HEIGHT,
								frontCamera, false);
					}
				} else {
					Log.d(TAG, "faces:0");
				}

				mFaceSurface.getHolder().unlockCanvasAndPost(canvas);
			}
		}
	}).start();
}
 
开发者ID:HuaDanJson,项目名称:FaceAI_Android,代码行数:81,代码来源:VideoRecognise.java


注:本文中的com.iflytek.cloud.util.Accelerometer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。