react-native-ml-kit icon indicating copy to clipboard operation
react-native-ml-kit copied to clipboard

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

Open KaungHtetHein116 opened this issue 1 year ago • 5 comments

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"

KaungHtetHein116 avatar Jul 30 '23 09:07 KaungHtetHein116

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"

mastersandeep92 avatar Aug 25 '23 09:08 mastersandeep92

not found the solution yet @mastersandeep92

KaungHtetHein116 avatar Sep 12 '23 13:09 KaungHtetHein116

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

a7medev avatar Sep 15 '23 06:09 a7medev

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

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

OGreeni avatar Sep 25 '23 15:09 OGreeni

        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

KaungHtetHein116 avatar Sep 28 '23 03:09 KaungHtetHein116