Skip to content

Commit

Permalink
Merge pull request #30 from seanpcoyle/remove-yuv
Browse files Browse the repository at this point in the history
Remove "native" pixelFormat
  • Loading branch information
mgcrea authored May 2, 2024
2 parents 35bf7b6 + 6c8ff30 commit c6e0258
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.common.InputImage;
import com.mrousavy.camera.core.FrameInvalidError;
import com.mrousavy.camera.frameprocessor.Frame;
import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin;
import com.mrousavy.camera.frameprocessor.VisionCameraProxy;
import com.mrousavy.camera.types.Orientation;
import com.mrousavy.camera.frameprocessors.Frame;
import com.mrousavy.camera.frameprocessors.FrameProcessorPlugin;
import com.mrousavy.camera.frameprocessors.VisionCameraProxy;
import com.mrousavy.camera.core.types.Orientation;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand All @@ -40,11 +40,16 @@ public class CodeScannerProcessorPlugin extends FrameProcessorPlugin {
public Object callback(@NotNull Frame frame,
@Nullable Map<String, Object> params) {

Image mediaImage = frame.getImage();
try {
Image mediaImage = frame.getImage();

if (mediaImage.getFormat() != ImageFormat.YUV_420_888) {
Log.e(TAG, "Unsupported image format: " + mediaImage.getFormat() +
". Only YUV_420_888 is supported for now.");
if (mediaImage.getFormat() != ImageFormat.YUV_420_888) {
Log.e(TAG, "Unsupported image format: " + mediaImage.getFormat() +
". Only YUV_420_888 is supported for now.");
return null;
}
} catch (FrameInvalidError e) {
Log.e(TAG, "Received an invalid frame.");
return null;
}

Expand All @@ -70,13 +75,14 @@ public Object callback(@NotNull Frame frame,

@Nullable
private InputImage getInputImageFromFrame(@NotNull Frame frame) {
Image mediaImage = frame.getImage();
try {
Image mediaImage = frame.getImage();

Orientation orientation = frame.getOrientation();
return InputImage.fromMediaImage(
mediaImage,
Orientation.Companion.fromUnionValue(orientation.getUnionValue())
.toDegrees());
.toSurfaceRotation());
} catch (FrameInvalidError e) {
Log.e(TAG, "Received an invalid frame.");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import com.mrousavy.camera.frameprocessor.FrameProcessorPluginRegistry;
import com.mrousavy.camera.frameprocessors.FrameProcessorPluginRegistry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"prettier-plugin-organize-imports": "^3.2.4",
"react": "18.2.0",
"react-native": "0.73.7",
"react-native-vision-camera": "3.9.2",
"react-native-vision-camera": "4.0.1",
"react-native-worklets-core": "1.1.1",
"release-it": "^17.2.0",
"tsup": "^8.0.2",
Expand Down
Loading

0 comments on commit c6e0258

Please sign in to comment.