Search in sources :

Example 1 with ImageDimensions

use of org.reactnative.camera.utils.ImageDimensions in project react-native-camera by react-native-community.

the class RNCameraView method onFacesDetected.

public void onFacesDetected(SparseArray<Face> facesReported, int sourceWidth, int sourceHeight, int sourceRotation) {
    if (!mShouldDetectFaces) {
        return;
    }
    SparseArray<Face> facesDetected = facesReported == null ? new SparseArray<Face>() : facesReported;
    ImageDimensions dimensions = new ImageDimensions(sourceWidth, sourceHeight, sourceRotation, getFacing());
    RNCameraViewHelper.emitFacesDetectedEvent(this, facesDetected, dimensions);
}
Also used : ImageDimensions(org.reactnative.camera.utils.ImageDimensions) Face(com.google.android.gms.vision.face.Face)

Example 2 with ImageDimensions

use of org.reactnative.camera.utils.ImageDimensions in project react-native-camera by react-native-community.

the class RNFrameFactory method buildFrame.

public static RNFrame buildFrame(byte[] bitmapData, int width, int height, int rotation) {
    Frame.Builder builder = new Frame.Builder();
    ByteBuffer byteBuffer = ByteBuffer.wrap(bitmapData);
    builder.setImageData(byteBuffer, width, height, ImageFormat.NV21);
    switch(rotation) {
        case 90:
            builder.setRotation(Frame.ROTATION_90);
            break;
        case 180:
            builder.setRotation(Frame.ROTATION_180);
            break;
        case 270:
            builder.setRotation(Frame.ROTATION_270);
            break;
        default:
            builder.setRotation(Frame.ROTATION_0);
    }
    ImageDimensions dimensions = new ImageDimensions(width, height, rotation);
    return new RNFrame(builder.build(), dimensions);
}
Also used : Frame(com.google.android.gms.vision.Frame) ImageDimensions(org.reactnative.camera.utils.ImageDimensions) ByteBuffer(java.nio.ByteBuffer)

Example 3 with ImageDimensions

use of org.reactnative.camera.utils.ImageDimensions in project react-native-camera by lwansbrough.

the class RNFrameFactory method buildFrame.

public static RNFrame buildFrame(byte[] bitmapData, int width, int height, int rotation) {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bitmapData);
    ImageDimensions dimensions = new ImageDimensions(width, height, rotation);
    InputImage image = InputImage.fromByteBuffer(byteBuffer, width, height, rotation, InputImage.IMAGE_FORMAT_NV21);
    return new RNFrame(image, dimensions);
}
Also used : ImageDimensions(org.reactnative.camera.utils.ImageDimensions) ByteBuffer(java.nio.ByteBuffer) InputImage(com.google.mlkit.vision.common.InputImage)

Example 4 with ImageDimensions

use of org.reactnative.camera.utils.ImageDimensions in project react-native-camera by react-native-community.

the class RNCameraView method onTextRecognized.

@Override
public void onTextRecognized(SparseArray<TextBlock> textBlocks, int sourceWidth, int sourceHeight, int sourceRotation) {
    if (!mShouldRecognizeText) {
        return;
    }
    SparseArray<TextBlock> textBlocksDetected = textBlocks == null ? new SparseArray<TextBlock>() : textBlocks;
    ImageDimensions dimensions = new ImageDimensions(sourceWidth, sourceHeight, sourceRotation, getFacing());
    RNCameraViewHelper.emitTextRecognizedEvent(this, textBlocksDetected, dimensions);
}
Also used : ImageDimensions(org.reactnative.camera.utils.ImageDimensions) TextBlock(com.google.android.gms.vision.text.TextBlock)

Example 5 with ImageDimensions

use of org.reactnative.camera.utils.ImageDimensions in project react-native-camera by react-native-community.

the class RNFrameFactory method buildFrame.

public static RNFrame buildFrame(Bitmap bitmap) {
    Frame.Builder builder = new Frame.Builder();
    builder.setBitmap(bitmap);
    ImageDimensions dimensions = new ImageDimensions(bitmap.getWidth(), bitmap.getHeight());
    return new RNFrame(builder.build(), dimensions);
}
Also used : Frame(com.google.android.gms.vision.Frame) ImageDimensions(org.reactnative.camera.utils.ImageDimensions)

Aggregations

ImageDimensions (org.reactnative.camera.utils.ImageDimensions)6 Frame (com.google.android.gms.vision.Frame)2 InputImage (com.google.mlkit.vision.common.InputImage)2 ByteBuffer (java.nio.ByteBuffer)2 Face (com.google.android.gms.vision.face.Face)1 TextBlock (com.google.android.gms.vision.text.TextBlock)1