infinitered / react-native-mlkit

The definitive MLKit wrapper for React Native and Expo
https://docs.infinite.red/react-native-mlkit/
160 stars 13 forks source link

[Object Detection] Documentation is off #165

Open jolo-dev opened 4 weeks ago

jolo-dev commented 4 weeks ago

I took the example from the docs here and noticed many errors which I cannot make work :/

https://github.com/user-attachments/assets/d09daf3e-c09b-4be0-b487-21201ca99902

frankcalise commented 4 weeks ago

hey @jolo-dev can you try switching that item that isn't found to RNMLKitObjectDetectionObject and the hook should just return the model directly, not an object.

You can use the Example App for reference.

jolo-dev commented 4 weeks ago

Hi @frankcalise,

Thanks for commenting. I adjusted the code accordingly.

Now, I get following error when I want to use the ObjectDetectionModelContextProvider.

 ERROR  Error: Cannot find native module 'RNMLKitObjectDetection', js engine: hermes
    at ContextNavigator

I am on expo SDK 51. My client has version 2.31.2

Here my very simplified code

import React from 'react';
import { View, Button, Text } from 'react-native';
import {
  useObjectDetectionModels,
} from "@infinitered/react-native-mlkit-object-detection";

export function CameraScreen() {
  const { ObjectDetectionModelContextProvider } = useObjectDetectionModels({
    loadDefaultModel: true,
    defaultModelOptions: {
      shouldEnableMultipleObjects: true,
      shouldEnableClassification: true,
      detectorMode: "stream",
    },
  });
  return (
    <View style={styles.container}>
        <ObjectDetectionModelContextProvider>
            <MyComponent />
        </ObjectDetectionModelContextProvider>
    </View>
  );
}
jolo-dev commented 4 weeks ago

Ah and I am using Android.

Could it be it happens because it was not defined here correctly. It says RNMLKitObjDet instead of RNMLKitObjectDetection.