本文整理汇总了Java中com.facepp.error.FaceppParseException类的典型用法代码示例。如果您正苦于以下问题:Java FaceppParseException类的具体用法?Java FaceppParseException怎么用?Java FaceppParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FaceppParseException类属于com.facepp.error包,在下文中一共展示了FaceppParseException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detect
import com.facepp.error.FaceppParseException; //导入依赖的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();
}
示例2: TrainGroup
import com.facepp.error.FaceppParseException; //导入依赖的package包/类
private void TrainGroup() {
new Thread(new Runnable() {
@Override
public void run() {
JSONObject syncRet = null;
try {
syncRet = httpRequests.trainIdentify(new PostParameters()
.setGroupName("my_group"));
System.out.println("train group session:"
+ syncRet.toString());
} catch (FaceppParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
}
示例3: detect
import com.facepp.error.FaceppParseException; //导入依赖的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();
}
示例4: detect
import com.facepp.error.FaceppParseException; //导入依赖的package包/类
public void detect(final Bitmap image) {
new Thread(new Runnable() {
@Override
public void run() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
img.compress(Bitmap.CompressFormat.JPEG, 100, stream);
imageArray = stream.toByteArray();
try {
// detect
JSONObject result = httpRequests
.detectionDetect(new PostParameters()
.setImg(imageArray));
// finished , then call the callback function
if (callback != null) {
callback.detectResult(result);
}
} catch (FaceppParseException e) {
e.printStackTrace();
getActivity().runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(inflater.getContext(), "�������",
Toast.LENGTH_SHORT).show();
}
});
}
}
}).start();
}
示例5: detect
import com.facepp.error.FaceppParseException; //导入依赖的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();
}
示例6: recogenition
import com.facepp.error.FaceppParseException; //导入依赖的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();
}
示例7: run
import com.facepp.error.FaceppParseException; //导入依赖的package包/类
/**
* 无锁并发:对需要处理的文件id取模分段,不同线程处理不同的文件
* 如m个文件n个线程则 1号线程处理 1,1+n,1+2n...1+kn 号文件(1+kn<m)
*/
@Override
public void run() {
int threadId = Integer.parseInt(Thread.currentThread().getName());
int fileId = threadId;
while(fileId < list.size()){
File file = list.get(fileId);
fileId += Config.threadNum;
//过滤
JSONObject result = null;
try {
result = httpRequests.detectionDetect(new PostParameters()
.setImg(file).setAttribute("gender"));
} catch (FaceppParseException e) {
System.out.println("Error:\tThread-" + threadId + "\tFile-"+fileId + "\t" + file.getName() + " => " + e.getErrorMessage());
continue;
}
//检查是不是很多白色像素来去表情包
if(file.length() < Config.whiteRGBFileSizeMax){
if(FileUtils.isImageWhite(file,Config.whiteRGBMin,Config.whiteRGBRate)){
continue;
}
}
String gender = getGenderOrNull(result);
if (null == gender) {
}else{
int index = -9999;
if("Female".equals(gender)){
index = femaleIndex.getAndIncrement();
}else{
index = maleIndex.getAndIncrement();
}
//有些图片是.null后缀如 : ZJ0P65PZN$CW6IU)2PJVMDQ.null
String destSuffix = FileUtils.getFileSuffix(file);
if(destSuffix.equals("null")){
destSuffix = "jpg";
}
FileUtils.fileChannelCopy(file, new File(Config.destPath
+ "\\" + gender + "\\" + index + "." + destSuffix));
if(Config.delSrcFile){ //删源文件
file.delete();
}
}
}
}
示例8: detect
import com.facepp.error.FaceppParseException; //导入依赖的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();
}
示例9: error
import com.facepp.error.FaceppParseException; //导入依赖的package包/类
void error(FaceppParseException exception);
示例10: error
import com.facepp.error.FaceppParseException; //导入依赖的package包/类
void error(FaceppParseException e);