face-api.js
face-api.js copied to clipboard
unable to use in react native
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
Getting the same error, have you resolved the issue?
Also seeing this issue, any update?