第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

點擊detect出現(xiàn)一直出現(xiàn)"error!"

為什么點擊detect后一直都是"error!“呢,是哪一部分的原因呢?

package?com.example.imooc_how_old;

import?android.content.Intent;
import?android.database.Cursor;
import?android.graphics.Bitmap;
import?android.graphics.BitmapFactory;
import?android.graphics.Canvas;
import?android.graphics.Paint;
import?android.net.Uri;
import?android.os.Handler;
import?android.os.Message;
import?android.provider.MediaStore;
import?android.support.v7.app.AppCompatActivity;
import?android.os.Bundle;
import?android.text.TextUtils;
import?android.view.View;
import?android.widget.Button;
import?android.widget.ImageView;
import?android.widget.TextView;

import?com.facepp.error.FaceppParseException;

import?org.json.JSONArray;
import?org.json.JSONException;
import?org.json.JSONObject;

public?class?MainActivity?extends?AppCompatActivity?implements?View.OnClickListener?{

????private?static?final?int?PICK_CODE?=?0X110;
????private?ImageView?mPhoto;
????private?Button?mGetImage;
????private?Button?mDetect;
????private?TextView?mTip;
????private?View?mWaitting;

????private?String?mCurrentPhotoStr;
????private?Bitmap?mPhotoImage;
????private?Paint?mPaint;

????@Override
????protected?void?onCreate(Bundle?savedInstanceState)?{
????????super.onCreate(savedInstanceState);
????????setContentView(R.layout.activity_main);

????????initViews();

????????initEvents();
????????mPaint?=?new?Paint();
????}

????private?void?initEvents()?{
????????mGetImage.setOnClickListener(this);
????????mDetect.setOnClickListener(this);
????}

????private?void?initViews()?{
????????mPhoto?=?(ImageView)?findViewById(R.id.id_photo);
????????mGetImage?=?(Button)?findViewById(R.id.id_getImage);
????????mDetect?=?(Button)?findViewById(R.id.id_detect);
????????mTip?=?(TextView)?findViewById(R.id.id_tip);
????????mWaitting?=?findViewById(R.id.id_waitting);
????}

????@Override
????protected?void?onActivityResult(int?requestCode,?int?resultCode,?Intent?intent)?{
????????if(requestCode?==?PICK_CODE)
????????{
????????????if?(intent?!=?null)
????????????{
????????????????Uri?uri?=?intent.getData();
????????????????Cursor?cursor?=?getContentResolver().query(uri,null,null,null,null);
????????????????cursor.moveToFirst();

????????????????int?idx?=?cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
????????????????mCurrentPhotoStr?=?cursor.getString(idx);
????????????????cursor.close();

????????????????//壓縮照片
????????????????resizePhoto();

????????????????mPhoto.setImageBitmap(mPhotoImage);
????????????????mTip.setText("Click?Detect?==>");
????????????}
????????}
????????super.onActivityResult(requestCode,?resultCode,?intent);
????}

????//壓縮照片
????private?void?resizePhoto()?{
????????BitmapFactory.Options?options?=?new?BitmapFactory.Options();
????????options.inJustDecodeBounds?=?true;

????????BitmapFactory.decodeFile(mCurrentPhotoStr,options);
????//每張圖片不能超過3M
????????double?ratio?=?Math.max(options.outWidth?*1.0/1024f,options.outHeight?*?1.0d/1024f);

????????options.inSampleSize?=?(int)?Math.ceil(ratio);

????????options.inJustDecodeBounds?=?false;

????????mPhotoImage?=?BitmapFactory.decodeFile(mCurrentPhotoStr,options);
????}

????private?static?final?int?MSG_SUCESS?=?0x111;
????private?static?final?int?MSG_ERROR?=?0x112;

????private?Handler?mHandler?=?new?Handler(){
????????@Override
????????public?void?handleMessage(Message?msg)?{

????????????switch?(msg.what)
????????????{
????????????????case?MSG_SUCESS:
????????????????????mWaitting.setVisibility(View.GONE);
????????????????????JSONObject?rs?=?(JSONObject)?msg.obj;

????????????????????prepareRsBitmap(rs);

????????????????????mPhoto.setImageBitmap(mPhotoImage);

????????????????????break;
????????????????case?MSG_ERROR:
????????????????????mWaitting.setVisibility(View.GONE);
????????????????????String?errorMsg?=?(String)?msg.obj;

????????????????????if(TextUtils.isEmpty(errorMsg)){
????????????????????????mTip.setText("Error.");
????????????????????}
????????????????????else{
????????????????????????mTip.setText(errorMsg);
????????????????????}
????????????????????break;
????????????}
????????????super.handleMessage(msg);
????????}
????};

????private?void?prepareRsBitmap(JSONObject?rs)?{

????????Bitmap?bitmap?=?Bitmap.createBitmap(mPhotoImage.getWidth(),mPhotoImage.getHeight(),mPhotoImage.getConfig());
????????Canvas?canvas?=?new?Canvas(bitmap);
????????canvas.drawBitmap(mPhotoImage,0,0,null);

????????try?{
????????????JSONArray?faces?=?rs.getJSONArray("face");

????????????int?faceCount?=?faces.length();

????????????mTip.setText("find"?+?faceCount);

????????????for(int?i?=?0;?i?<?faceCount;?i++){
????????????????//拿到單獨的face對象
????????????????JSONObject?face?=?faces.getJSONObject(i);
????????????????JSONObject?posObj?=?face.getJSONObject("position");

????????????????float?x?=?(float)?posObj.getJSONObject("CENTER").getDouble("x");
????????????????float?y?=?(float)?posObj.getJSONObject("CENTER").getDouble("y");

????????????????float?w?=?(float)?posObj.getDouble("width");
????????????????float?h?=?(float)?posObj.getDouble("height");

????????????????x?=?x/100?*?bitmap.getWidth();
????????????????y?=?y/100?*?bitmap.getHeight();

????????????????w?=?w/100?*?bitmap.getWidth();
????????????????h?=?h/100?*?bitmap.getHeight();

????????????????mPaint.setColor(0xffffffff);
????????????????mPaint.setStrokeWidth(3);
????????????????//畫box
????????????????canvas.drawLine(x?-?w/2?,?y?-?h/2?,?x?-?w/2?,?y?+?h/2?,?mPaint);
????????????????canvas.drawLine(x?-?w/2?,?y?-?h/2?,?x?+?w/2?,?y?-?h/2?,?mPaint);
????????????????canvas.drawLine(x?+?w/2?,?y?-?h/2?,?x?+?w/2?,?y?+?h/2?,?mPaint);
????????????????canvas.drawLine(x?-?w/2?,?y?+?h/2?,?x?+?w/2?,?y?+?h/2?,?mPaint);

????????????????mPhotoImage?=?bitmap;
????????????}
????????}?catch?(JSONException?e)?{
????????????e.printStackTrace();
????????}

????}

????@Override
????public?void?onClick(View?v)?{
????????switch(v.getId())
????????{
????????????case?R.id.id_getImage:
????????????????Intent?intent?=?new?Intent?(Intent.ACTION_PICK);
????????????????intent.setType("image/*");
????????????????startActivityForResult(intent,PICK_CODE);
????????????????break;
????????????case?R.id.id_detect:

????????????????mWaitting.setVisibility(View.VISIBLE);

????????????????FaceppDetect.detect(mPhotoImage,?new?FaceppDetect.CallBack()?{
????????????????????@Override
????????????????????public?void?success(JSONObject?result)?{
????????????????????????Message?msg?=?Message.obtain();
????????????????????????msg.what?=?MSG_SUCESS;
????????????????????????msg.obj?=?result;
????????????????????????mHandler.sendMessage(msg);
????????????????????}

????????????????????@Override
????????????????????public?void?error(FaceppParseException?exception)?{
????????????????????????Message?msg?=?Message.obtain();
????????????????????????msg.what?=?MSG_ERROR;
????????????????????????msg.obj?=?exception.getErrorMessage();
????????????????????????mHandler.sendMessage(msg);
????????????????????}
????????????????});

????????????????break;
????????}
????}
}


正在回答

2 回答

看下你的錯誤碼,去曠視找下問題所在
58ae3dad0001d66b11520864.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕粉0849514580

老哥知道怎么解決嗎
2018-12-12 回復(fù) 有任何疑惑可以回復(fù)我~

哥們你解決了嗎?我也是這種問題

1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕粉0849514580

有知道怎么解決嗎
2018-12-12 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
How-old 刷臉神器
  • 參與學(xué)習(xí)       31536    人
  • 解答問題       160    個

通過第三方本課程教大家實現(xiàn)人臉識別,通過案例講解原理

進(jìn)入課程

點擊detect出現(xiàn)一直出現(xiàn)"error!"

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號