// Path: app/src/main/java/cn/ac/iscas/xlab/droidfacedog/entity/FaceResult.java
// public class FaceResult extends Object {
// 
//     private PointF midEye;
//     private float eyeDist;
//     private float confidence;
//     private float pose;
//     private int id;
//     private long time;
// 
//     public FaceResult() {
//         id = 0;
//         midEye = new PointF(0.0f, 0.0f);
//         eyeDist = 0.0f;
//         confidence = 0.4f;
//         pose = 0.0f;
//         time = System.currentTimeMillis();
//     }
// 
// 
//     public void setFace(int id, PointF midEye, float eyeDist, float confidence, float pose, long time) {
//         set(id, midEye, eyeDist, confidence, pose, time);
//     }
// 
//     public void clear() {
//         set(0, new PointF(0.0f, 0.0f), 0.0f, 0.4f, 0.0f, System.currentTimeMillis());
//     }
// 
//     public synchronized void set(int id, PointF midEye, float eyeDist, float confidence, float pose, long time) {
//         this.id = id;
//         this.midEye.set(midEye);
//         this.eyeDist = eyeDist;
//         this.confidence = confidence;
//         this.pose = pose;
//         this.time = time;
//     }
// 
//     public float eyesDistance() {
//         return eyeDist;
//     }
// 
//     public void setEyeDist(float eyeDist) {
//         this.eyeDist = eyeDist;
//     }
// 
//     public void getMidPoint(PointF pt) {
//         pt.set(midEye);
//     }
// 
//     public PointF getMidEye() {
//         return midEye;
//     }
// 
//     public void setMidEye(PointF midEye) {
//         this.midEye = midEye;
//     }
// 
//     public float getConfidence() {
//         return confidence;
//     }
// 
//     public void setConfidence(float confidence) {
//         this.confidence = confidence;
//     }
// 
//     public float getPose() {
//         return pose;
//     }
// 
//     public void setPose(float pose) {
//         this.pose = pose;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     @Override
//     public String toString() {
//         return "FaceResult{" +
//                 "midEye=" + midEye +
//                 ", eyeDist=" + eyeDist +
//                 ", confidence=" + confidence +
//                 ", pose=" + pose +
//                 ", id=" + id +
//                 ", time=" + time +
//                 '}';
//     }
// }


import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import cn.ac.iscas.xlab.droidfacedog.entity.FaceResult;
            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }


    //Rotate Bitmap
    public final static Bitmap rotate(Bitmap b, float degrees) {
        if (degrees != 0 && b != null) {
            Matrix m = new Matrix();
            m.setRotate(degrees, (float) b.getWidth() / 2,
                    (float) b.getHeight() / 2);

            Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
                    b.getHeight(), m, true);
            if (b != b2) {
                b.recycle();
                b = b2;
            }

        }
        return b;
    }


// Path: app/src/main/java/cn/ac/iscas/xlab/droidfacedog/entity/FaceResult.java
// public class FaceResult extends Object {
// 
//     private PointF midEye;
//     private float eyeDist;
//     private float confidence;
//     private float pose;
//     private int id;
//     private long time;
// 
//     public FaceResult() {
//         id = 0;
//         midEye = new PointF(0.0f, 0.0f);
//         eyeDist = 0.0f;
//         confidence = 0.4f;
//         pose = 0.0f;
//         time = System.currentTimeMillis();
//     }
// 
// 
//     public void setFace(int id, PointF midEye, float eyeDist, float confidence, float pose, long time) {
//         set(id, midEye, eyeDist, confidence, pose, time);
//     }
// 
//     public void clear() {
//         set(0, new PointF(0.0f, 0.0f), 0.0f, 0.4f, 0.0f, System.currentTimeMillis());
//     }
// 
//     public synchronized void set(int id, PointF midEye, float eyeDist, float confidence, float pose, long time) {
//         this.id = id;
//         this.midEye.set(midEye);
//         this.eyeDist = eyeDist;
//         this.confidence = confidence;
//         this.pose = pose;
//         this.time = time;
//     }
// 
//     public float eyesDistance() {
//         return eyeDist;
//     }
// 
//     public void setEyeDist(float eyeDist) {
//         this.eyeDist = eyeDist;
//     }
// 
//     public void getMidPoint(PointF pt) {
//         pt.set(midEye);
//     }
// 
//     public PointF getMidEye() {
//         return midEye;
//     }
// 
//     public void setMidEye(PointF midEye) {
//         this.midEye = midEye;
//     }
// 
//     public float getConfidence() {
//         return confidence;
//     }
// 
//     public void setConfidence(float confidence) {
//         this.confidence = confidence;
//     }
// 
//     public float getPose() {
//         return pose;
//     }
// 
//     public void setPose(float pose) {
//         this.pose = pose;
//     }
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     @Override
//     public String toString() {
//         return "FaceResult{" +
//                 "midEye=" + midEye +
//                 ", eyeDist=" + eyeDist +
//                 ", confidence=" + confidence +
//                 ", pose=" + pose +
//                 ", id=" + id +
//                 ", time=" + time +
//                 '}';
//     }
// }


// Path: app/src/main/java/cn/ac/iscas/xlab/droidfacedog/util/ImageUtils.java
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Base64;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import cn.ac.iscas.xlab.droidfacedog.entity.FaceResult;

            int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }


    //Rotate Bitmap
    public final static Bitmap rotate(Bitmap b, float degrees) {
        if (degrees != 0 && b != null) {
            Matrix m = new Matrix();
            m.setRotate(degrees, (float) b.getWidth() / 2,
                    (float) b.getHeight() / 2);

            Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
                    b.getHeight(), m, true);
            if (b != b2) {
                b.recycle();
                b = b2;
            }

        }
        return b;
    }


    public static Bitmap getBitmap(String filePath, int width, int height) {