Search in sources :

Example 1 with RNFrame

use of org.reactnative.facedetector.RNFrame in project react-native-camera by react-native-community.

the class FileFaceDetectionAsyncTask method doInBackground.

@Override
protected SparseArray<Face> doInBackground(Void... voids) {
    if (isCancelled()) {
        return null;
    }
    mRNFaceDetector = detectorForOptions(mOptions, mContext);
    Bitmap bitmap = BitmapFactory.decodeFile(mPath);
    mWidth = bitmap.getWidth();
    mHeight = bitmap.getHeight();
    try {
        ExifInterface exif = new ExifInterface(mPath);
        mOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
    } catch (IOException e) {
        Log.e(ERROR_TAG, "Reading orientation from file `" + mPath + "` failed.", e);
    }
    RNFrame frame = RNFrameFactory.buildFrame(bitmap);
    return mRNFaceDetector.detect(frame);
}
Also used : Bitmap(android.graphics.Bitmap) ExifInterface(android.media.ExifInterface) RNFrame(org.reactnative.facedetector.RNFrame) IOException(java.io.IOException)

Aggregations

Bitmap (android.graphics.Bitmap)1 ExifInterface (android.media.ExifInterface)1 IOException (java.io.IOException)1 RNFrame (org.reactnative.facedetector.RNFrame)1