mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Question about inconsistency of faceLandmarker.detectAsync inputs and outputs

Open RavenGluttonous opened this issue 6 months ago • 2 comments

Hello, I am using the FaceLandmarker model and I noticed that when using the RunningMode.LIVE_STREAM mode, I got 322 video frames through the camera and called the faceLandmarker.detectAsync method the corresponding number of times, but the returnLivestreamResult is executed only 295 times. Can you please tell me if it has an inconsistency between the number of inputs and outputs. Below is the code when I am using it:

    @Override
    public void run() {
        while (isVideoFrame) {

            try {
                if (FaceLandmarkerHelper.getInstance() != null) {

                    Frame frame = videoFrameQueue.take();
                    //......
                    detectAsync(mpImage, frameTime);
                    //......

                    //position prints the final result as 332
                    position++;
                }
            } catch (InterruptedException e) {
                
            }
    }
    private void returnLivestreamResult(
            FaceLandmarkerResult result,
            MPImage input
    ) {

        if (!result.faceLandmarks().isEmpty() && !isClose()) {
            long finishTimeMs = SystemClock.uptimeMillis();
            long inferenceTime = finishTimeMs - result.timestampMs();

            //frameCount prints the final result as 295
            MyLog.d("chunk","\nmediapipe returns the "+frameCount+"recognized image");
            ++frameCount;
            try {
                resultBundles.put(new ResultBundle(
                        result,
                        inferenceTime,
                        input.getHeight(),
                        input.getWidth(),
                        nv21landmarkQueue.take()
                ));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        } 
        input.close();

    }

RavenGluttonous avatar Dec 19 '23 07:12 RavenGluttonous