Closed kulame closed 1 year ago
does mediapipe support vite build?
Hi @kulame, Please refer to closed issue #3796 and try out the importing the mediapipe as mentioned in #3796(comment) However, This can be more helpful see the vite support implementation from here.
Just to piggyback off this issue, I am also currently getting a similar error on @mediapipe/face_mesh
:
For context, I am using a NextJS + Electron with the help of the library Nextron
. Inside FaceMeshComponent.js
:
import React, {useRef, useEffect} from 'react';
import Webcam from "react-webcam"
import { FaceMesh } from "@mediapipe/face_mesh";
function FaceMeshComponent() {
const webcamRef = useRef(null);
const canvasRef = useRef(null);
useEffect(() => {
const faceMesh = new FaceMesh({locateFile: (file) => {
return `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${file}`;
}});
faceMesh.setOptions({
maxNumFaces: 1,
refineLandmarks: true,
minDetectionConfidence: 0.5,
minTrackingConfidence: 0.5
});
}, [])
return <div>...</div>
Appreciate any help!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
@Zxun2, Could you please raise a fresh issue with problems you are facing to adopt mediapipe solution in the JS platform? Marking this issue as reference. Thanks!!
Just to piggyback off this issue, I am also currently getting a similar error on
@mediapipe/face_mesh
:For context, I am using a NextJS + Electron with the help of the library
Nextron
. InsideFaceMeshComponent.js
:import React, {useRef, useEffect} from 'react'; import Webcam from "react-webcam" import { FaceMesh } from "@mediapipe/face_mesh"; function FaceMeshComponent() { const webcamRef = useRef(null); const canvasRef = useRef(null); useEffect(() => { const faceMesh = new FaceMesh({locateFile: (file) => { return `https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${file}`; }}); faceMesh.setOptions({ maxNumFaces: 1, refineLandmarks: true, minDetectionConfidence: 0.5, minTrackingConfidence: 0.5 }); }, []) return <div>...</div>
Appreciate any help!
Hello, I alse got the same error. Have you sloved the problem?
Thanks.
Hi @kulame, Please refer to closed issue #3796 and try out the importing the mediapipe as mentioned in #3796(comment) However, This can be more helpful see the vite support implementation from here.
If anyone still has issues, for me it was due to the vite build system, and the source code of mediapipe not public thus could not be obfuscated. From the issues @kulame sent I could find a package that handled it with ease: vite-plugin-mediapipe
The code of my script still remained the same as in:
import { FACEMESH_TESSELATION, HAND_CONNECTIONS, Holistic, POSE_CONNECTIONS } from '@mediapipe/holistic';
const holistic = new Holistic({
locateFile: file => {
console.log(file)
return `https://cdn.jsdelivr.net/npm/@mediapipe/holistic@0.5.1675471629/${file}`;
},
});
And I also add a vite.config.js in the root of my project that looks like this:
import { mediapipe } from 'vite-plugin-mediapipe';
import { defineConfig } from 'vite'
export default defineConfig(config => {
return {
plugins: [
mediapipe({
'holistic.js': [
'VERSION',
'POSE_CONNECTIONS',
'HAND_CONNECTIONS',
'FACEMESH_TESSELATION',
'Holistic'
]
})
]
}
});
After including the vite.config.js the build was successful and I was able to deploy the app to production.
Please make sure that this is a bug and also refer to the troubleshooting, FAQ documentation before raising any issues.
System information (Please provide as much relevant information as possible)
Describe the current behavior:
I want to integrate mediapipe into tauri
my code is
it's ok on "cargo tauri dev" but it failed on "cargo tauri build"
Describe the expected behavior: Pass the test case