react-native-mlkit icon indicating copy to clipboard operation
react-native-mlkit copied to clipboard

[Object Detection] Documentation is off

Open jolo-dev opened this issue 1 year ago • 3 comments

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

jolo-dev avatar Aug 15 '24 12:08 jolo-dev

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.

frankcalise avatar Aug 15 '24 14:08 frankcalise

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 avatar Aug 16 '24 13:08 jolo-dev

Ah and I am using Android.

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

jolo-dev avatar Aug 16 '24 15:08 jolo-dev