本港台开奖现场直播 j2开奖直播报码现场
当前位置: 新闻频道 > IT新闻 >

IT之家学院:使用语义理解来解决智能照相机拍摄(2)

时间:2017-08-05 06:04来源:本港台现场报码 作者:118KJ 点击:
在MessageConst.SERVER_ACTION_RETURN_RESULT消息中,通过解析服务器返回的json字符串,可以找到modifier这个字段的值,如果是take_photo表示拍照,如果是switch_camera表示

在MessageConst.SERVER_ACTION_RETURN_RESULT消息中,通过解析服务器返回的json字符串,可以找到modifier这个字段的值,如果是take_photo表示拍照,如果是switch_camera表示切换摄像头。

当用户说拍照或者茄子的时候,服务器返回如下json字符串:

[

{

"desc_obj": {

"status": 0

},

"semantic": [

{

"app": "camera",

"input": "拍照",

"slots": [

],

"modifier": [

"take_photo"

],

"customer": "58df512384ae11f0bb7b487e"

}

],

"type": "camera"

}

]

这个拍照,茄子等语法都是自己定义的,atv,详细请看:

olami开放平台语法编写简介:

olami开放平台语法官方介绍:https://cn.olami.ai/wiki/?mp=nli&content=nli2.html

2.人脸识别FaceView.java

public class FaceView extends View {

private Camera.Face[] mFaces;

private Paint mPaint;

private Matrix matrix = new Matrix();

private RectF mRectF = new RectF();

private Handler mHandler;

private long mCurrentTime;

public void setFaces(Camera.Face[] faces) {

mFaces = faces;

invalidate();

}

public FaceView(Context context) {

super(context);

init(context);

}

public FaceView(Context context, AttributeSet attrs) {

super(context, attrs);

init(context);

}

public FaceView(Context context, AttributeSet attrs, int defStyleAttr) {

super(context, attrs, defStyleAttr);

init(context);

}

public void init(Context context) {

mPaint = new Paint();

mPaint.setColor(Color.RED);

mPaint.setStrokeWidth(5f);

mPaint.setStyle(Paint.Style.STROKE);

}

public void setHandler(Handler handler)

{

mHandler = handler;

}

@Override

protected void onDraw(Canvas canvas) {

super.onDraw(canvas);

if (mFaces == null || mFaces.length < 0) {

return;

}

//准备矩形框

MainActivity.prepareMatrix(matrix, false, 270, getWidth(), getHeight());

canvas.save();

matrix.postRotate(0);

canvas.rotate(-0);

RectF tempRectF = new RectF();

long tempTime = System.currentTimeMillis();

for (int i = 0; i < mFaces.length; i++) {

mRectF.set(mFaces[i].rect);//获取face矩形框值

float temp = mRectF.top;

mRectF.top = -mRectF.bottom;

mRectF.bottom = - temp; //上下交换

matrix.mapRect(mRectF);

canvas.drawRect(mRectF, mPaint);//绘制矩形框

tempRectF.set(mRectF);

if((mCurrentTime == 0) ||((tempTime-mCurrentTime)/1000) >= 4)

{//超过4秒,发送一次识别face矩形框值

mHandler.sendMessage(mHandler.obtainMessage(

MessageConst.CLIENT_ACTION_UPDATA_FACEDECTION_DATA, tempRectF));

mCurrentTime = tempTime;

}

Log.i("ppp","mRectF.left = "+mRectF.left+"mRectF.right = "+mRectF.right);

}

canvas.restore();

}

}

(责任编辑:本港台直播)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
推荐内容