本文整理汇总了Java中com.facepp.http.HttpRequests类的典型用法代码示例。如果您正苦于以下问题:Java HttpRequests类的具体用法?Java HttpRequests怎么用?Java HttpRequests使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequests类属于com.facepp.http包,在下文中一共展示了HttpRequests类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: detect
import com.facepp.http.HttpRequests; //导入依赖的package包/类
public void detect(final Bitmap bmp, final Callback callback)
{
new Thread(new Runnable()
{
@Override
public void run()
{
try {
HttpRequests requests = new HttpRequests(Constant.API_KEY, Constant.API_SECRET, true, true);
Bitmap bmpSamll = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmpSamll.compress(Bitmap.CompressFormat.JPEG, 70, stream); // 压缩
byte[] arrays = stream.toByteArray();
PostParameters params = new PostParameters();
params.setImg(arrays);
// 人脸检测
JSONObject jsonObject = requests.detectionDetect(params);
Log.d("TAG", jsonObject.toString());
if (callback != null) {
callback.success(jsonObject);
}
} catch (FaceppParseException e) {
e.printStackTrace();
if (callback != null) {
callback.error(e);
}
}
}
}).start();
}
开发者ID:VernonVan,项目名称:Face,代码行数:33,代码来源:FaceppDetect.java
示例2: detect
import com.facepp.http.HttpRequests; //导入依赖的package包/类
public static void detect(final Bitmap bm, final CallBack callBack) {
new Thread(new Runnable() {
@Override
public void run() {
// request
try {
HttpRequests requests = new HttpRequests(KEY, SECRET, true,
true);
Bitmap bmSmall = Bitmap.createBitmap(bm, 0, 0,
bm.getWidth(), bm.getHeight());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmSmall.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] arrays = stream.toByteArray();
PostParameters params = new PostParameters();
params.setImg(arrays);
JSONObject jsonObject = requests.detectionDetect(params);
// Log
Log.i("TAG", jsonObject.toString());
if (callBack != null) {
callBack.success(jsonObject);
}
} catch (FaceppParseException e) {
e.printStackTrace();
if (callBack != null) {
callBack.error(e);
}
}
}
}).start();
}
开发者ID:HuaDanJson,项目名称:FaceAI_Android,代码行数:39,代码来源:FaceppDetect.java
示例3: detect
import com.facepp.http.HttpRequests; //导入依赖的package包/类
public void detect(final Bitmap image) {
new Thread(new Runnable() {
public void run() {
HttpRequests httpRequests = new HttpRequests(
"8a6935b89012418fad0e9b3328bbeba9",
"WQN_MfSnt5Frtmy0XYeKJ8fh1xIVAmo_", true, false);
// Log.v(TAG, "image size : " + img.getWidth() + " " +
// img.getHeight());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
float scale = Math.min(
1,
Math.min(600f / img.getWidth(),
600f / img.getHeight()));
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
Bitmap imgSmall = Bitmap.createBitmap(img, 0, 0,
img.getWidth(), img.getHeight(), matrix, false);
// Log.v(TAG, "imgSmall size : " + imgSmall.getWidth() + " "
// + imgSmall.getHeight());
imgSmall.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] array = stream.toByteArray();
try {
// detect
JSONObject result = httpRequests
.detectionDetect(new PostParameters()
.setImg(array));
// finished , then call the callback function
if (callback != null) {
callback.detectResult(result);
}
} catch (FaceppParseException e) {
e.printStackTrace();
FindHowOldAct.this.runOnUiThread(new Runnable() {
public void run() {
SystemUtils.checkNetWork(FindHowOldAct.this);
textView.setText("error.");
}
});
}
}
}).start();
}
开发者ID:absentm,项目名称:myapplication,代码行数:50,代码来源:FindHowOldAct.java
示例4: recogenition
import com.facepp.http.HttpRequests; //导入依赖的package包/类
public static void recogenition(final File file){
new Thread(new Runnable() {
@Override
public void run() {
HttpRequests httpRequests = new HttpRequests(Global.FACEPP_KEY, Global.FACEPP_SECRET);
PostParameters postParameters = new PostParameters().setImg(file).setAttribute("all");
try {
// postParameters.getMultiPart().writeTo(System.out);
JSONObject result = httpRequests.detectionDetect(postParameters);
System.out.println(result.toString());
} catch (FaceppParseException e) {
e.printStackTrace();
}
}
}).start();
}
开发者ID:hss01248,项目名称:FaceDetect,代码行数:25,代码来源:FaceNet.java
示例5: detect
import com.facepp.http.HttpRequests; //导入依赖的package包/类
public void detect(final Bitmap image) {
new Thread(new Runnable() {
public void run() {
HttpRequests httpRequests = new HttpRequests("48e076d2628e91534e6f2175cd7f8003", "pV22Bbbs-xn-XW4-f2ZpiNaUolEt3sAD", true, false);
//Log.v(TAG, "image size : " + img.getWidth() + " " + img.getHeight());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
float scale = Math.min(1, Math.min(600f / img.getWidth(), 600f / img.getHeight()));
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
Bitmap imgSmall = Bitmap.createBitmap(img, 0, 0, img.getWidth(), img.getHeight(), matrix, false);
//Log.v(TAG, "imgSmall size : " + imgSmall.getWidth() + " " + imgSmall.getHeight());
imgSmall.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] array = stream.toByteArray();
try {
//detect
JSONObject result = httpRequests.detectionDetect(new PostParameters().setImg(array));
//��ɣ������ص�����
if (callback != null) {
callback.detectResult(result);
System.out.println(result);
}
} catch (FaceppParseException e) {
e.printStackTrace();
MainActivity.this.runOnUiThread(new Runnable() {
public void run() {
// textView.setText("�����쳣.");
Toast.makeText(MainActivity.this, "�����쳣����������Ƿ�������", Toast.LENGTH_LONG).show();
}
});
}
}
}).start();
}
开发者ID:zhongbaitu,项目名称:MAKEYOURFACE,代码行数:46,代码来源:MainActivity.java
注:本文中的com.facepp.http.HttpRequests类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论