baidu
This commit is contained in:
@@ -27,6 +27,8 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -155,6 +157,7 @@ public class NutritionMaster extends Application {
|
||||
for (int i = 0; i < occupations.length; i++) {
|
||||
ConstantUtils.occupationList.add(occupations[i].getOccupation_name());
|
||||
}
|
||||
Collections.shuffle(ConstantUtils.occupationList);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -209,11 +209,20 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
String result = null;
|
||||
try {
|
||||
if (code == MATERAIL_CODE) {
|
||||
MaterialClassifier materialClassifier = new MaterialClassifier();
|
||||
JSONObject jsonObject = materialClassifier.plantDetect(data);
|
||||
result = jsonObject.getJSONArray("objects")
|
||||
.getJSONObject(0).getString("value");
|
||||
translate(result);
|
||||
// MaterialClassifier materialClassifier = new MaterialClassifier();
|
||||
// JSONObject jsonObject = materialClassifier.plantDetect(data);
|
||||
// result = jsonObject.getJSONArray("objects")
|
||||
// .getJSONObject(0).getString("value");
|
||||
// translate(result);
|
||||
result = WebUtil.HttpPost(ConstantUtils.BD_MATERIAL_URL,
|
||||
ConstantUtils.BD_ACCESS_TOKEN, param);
|
||||
Logger.d(result);
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
JSONArray resultObject = jsonObject.getJSONArray("result");
|
||||
jsonObject = resultObject.getJSONObject(0);
|
||||
ClassifyResult classifyResult = new ClassifyResult(ClassifyResult.MATERIAL);
|
||||
classifyResult.setName(jsonObject.getString("name"));
|
||||
resultList.add(classifyResult);
|
||||
refreshUI();
|
||||
} else if (code == DISH_CODE) {
|
||||
result = WebUtil.HttpPost(ConstantUtils.BD_DISH_URL,
|
||||
@@ -255,11 +264,8 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
@OnClick({R.id.more_take_photo_button_capture, R.id.more_takephoto_ok,R.id.results_text_view})
|
||||
=======
|
||||
|
||||
@OnClick({R.id.more_take_photo_button_capture, R.id.more_takephoto_ok, R.id.results_text_view})
|
||||
>>>>>>> develop
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.more_take_photo_button_capture:
|
||||
@@ -308,12 +314,8 @@ public class ClassifierCamera extends AppCompatActivity {
|
||||
finish();
|
||||
break;
|
||||
case R.id.results_text_view:
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
resultList.remove(resultList.size() - 1);
|
||||
refreshUI();
|
||||
>>>>>>> develop
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,6 +278,7 @@ public class ConstantUtils {
|
||||
public static String BD_ACCESS_TOKEN = "";
|
||||
|
||||
public static String BD_DISH_URL = "https://aip.baidubce.com/rest/2.0/image-classify/v2/dish";
|
||||
public static String BD_MATERIAL_URL = "https://aip.baidubce.com/rest/2.0/image-classify/v1/classify/ingredient";
|
||||
|
||||
// public static ArrayList<ClassifyResult> testData = new ArrayList<>();
|
||||
//
|
||||
|
||||
@@ -480,7 +480,7 @@ public class WebUtil {
|
||||
}
|
||||
});
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
/*
|
||||
MyUser testUser = new MyUser();
|
||||
@@ -657,8 +657,7 @@ public class WebUtil {
|
||||
}
|
||||
});*/
|
||||
|
||||
=======
|
||||
>>>>>>> develop
|
||||
|
||||
/*
|
||||
* MyUser testUser = new MyUser(); testUser.setUsername("test6");
|
||||
* testUser.setPassword("66666"); testUser.setAge(8); testUser.setHeight(175);
|
||||
@@ -739,10 +738,7 @@ public class WebUtil {
|
||||
* } });
|
||||
*/
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> develop
|
||||
/*
|
||||
* WebUtil.getFoodMaterial("西红柿", new Callback() {
|
||||
*
|
||||
@@ -817,9 +813,6 @@ public class WebUtil {
|
||||
* @Override public void onResponse(Call call, Response response) throws
|
||||
* IOException { System.out.println(response.body().string()); } });
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> develop
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user