face-api.js icon indicating copy to clipboard operation
face-api.js copied to clipboard

unable to use in react native

Open toguvr opened this issue 3 years ago • 2 comments

Issue Description When i use the same i used in reactjs on react native it says this: "[Unhandled promise rejection: Error: getEnv - environment is not defined, check isNodejs() and isBrowser()]"

Steps to Reproduce

Do on react native project this lines: where user.avatar_url can be any other face image async function onSelectionChangedFirst() { // await faceapi.loadFaceRecognitionModel(MODEL_URL); await faceapi.nets.ssdMobilenetv1.loadFromUri(MODEL_URL); // if (!isFaceDetectionModelLoaded()) { // return; // } if (!user?.avatar_url) { return; }

const options = getFaceDetectorOptions();

const input1 = await faceapi.fetchImage(user.avatar_url);

const detections1 = await faceapi.detectAllFaces(input1, options);

const faceImages1 = await faceapi.extractFaces(input1, detections1);

if (faceImages1.length > 0) { setPreview1(faceImages1[0].toDataURL());

const fim1 = await faceapi.computeFaceDescriptor(faceImages1[0]);

setDescriptor1(fim1); } else { Alert.alert("sem nenhum rosto na foto"); } }

Expected Behavior

**Environment react native

Module version? Built-in demo or custom code? Type of module used (e.g. js, esm, esm-nobundle)? js Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)? react native OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)? Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)? Additional

For installation or startup issues include your package.json For usage issues, it is recommended to post your code as gist

toguvr avatar Dec 28 '21 16:12 toguvr

Getting the same error, have you resolved the issue?

algermakiputin avatar Mar 08 '22 00:03 algermakiputin

Also seeing this issue, any update?

davidalee avatar Feb 05 '23 20:02 davidalee