Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "native" pixelFormat #30

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading