a7medev / react-native-ml-kit

React Native On-Device Machine Learning w/ Google ML Kit
MIT License
342 stars 55 forks source link

Face detection not working when image path is given from react native camera kit #33

Open KaungHtetHein116 opened 11 months ago

KaungHtetHein116 commented 11 months ago

When I use Image taken from React native camera kit package, even when the face is clear and have proper pixel, the face result is incorrect and it happens on ios device only.

Face detection is working properly when image is picked from device.

Here is my code for face detection.

const { uri } = await cameraRef.current.capture() const result = await FaceDetection.detect(imagePath, { classificationMode: 'all', })

here is example image path generated by react native camera kit Image size is 1179 × 1179 pixels

file:///private/var/mobile/Containers/Data/Application/8A87BC60-F8AC-4344-A9A2-D1ECB695BDA8/tmp/6DF288F4-D386-42FE-A51E-DF8C3C7DC6C7-7734-0000018B730F71E2.jpg

here is detail of my project

"react-native": "0.72.1" "@react-native-ml-kit/face-detection": "^1.1.2" "react-native-camera-kit": "^13.0.0"

mastersandeep92 commented 10 months ago

I use Image taken from React native camera kit package, I have the Same issue on iOS Device only @KaungHtetHein116 have find any Solution ?

my Image File URI is below : - file:///private/var/mobile/Containers/Data/Application/88D2BA48-CA30-49EE-86F6-C3014AE0C89D/tmp/B48F5191-B4BE-497B-ACEA-F2CC8F493792-3951-000001EA7FA7E978.jpg

and Face Detection Result is [ ]

here is detail of my project

"react-native": "0.72.3" "@react-native-ml-kit/face-detection": "^1.1.2" "react-native-camera-kit": "^13.0.0"

KaungHtetHein116 commented 10 months ago

not found the solution yet @mastersandeep92

a7medev commented 9 months ago

Hi everyone, thanks for reporting this issue! I'll check it and get back to you 🙏🏼

OGreeni commented 9 months ago

Face detection is working properly when image is picked from device.

Could you give an example of a file path that worked?

KaungHtetHein116 commented 9 months ago
        import Picker, { ImageOrVideo } from 'react-native-image-crop-picker'
        import FaceDetection from '@react-native-ml-kit/face-detection'

    Picker.openPicker({})
            .then(handleSelectedImage)
            .catch(handlePermissionError)

    const handleSelectedImage = (image: ImageOrVideo) => {
        if (!hasFace(image?.path)) {
            return
        }
    }

    const hasFace = async (imagePath: string): Promise<boolean> => {
        setChecking(true)

        const result = await FaceDetection.detect(imagePath, {
            classificationMode: 'all',
        })

        return result?.length > 0
    }

here is the code that worked using image from device @OGreeni