google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
26.82k stars 5.09k forks source link

Mediapipe application crashes while integrating Arcore(Sceneform) #321

Closed suraj-0387 closed 4 years ago

suraj-0387 commented 4 years ago

I am working to integrate mediapipe handtracking application with Arcore(Sceneform).I added arcore dependencies in mediapipe code and made few changes to it.I added a arfragment in the mediapipe code added surface holder callback to Arsceneview of sceneform(Adding a code below).After doing the changes I was able to see plane detector hand of arcore as well as mediapipe hand tracking but the application crashes when I try to open the app for the second time.Also when I try to relaunch the app for second time (fresh installation) the app only shows me black or white screen.I am adding a source code (changes that I had done) as well as error which I am getting.Please help me to integrate.

Changed code private void setupPreviewDisplayView() { previewDisplayView.setVisibility(View.GONE); arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.ux_fragment); arFragment.getArSceneView().setVisibility(View.GONE); arFragment.getArSceneView().getHolder().addCallback( new SurfaceHolder.Callback() { @Override public void surfaceCreated(SurfaceHolder holder) { processor.getVideoSurfaceOutput().setSurface(holder.getSurface()); }

                            @Override
                            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) 
                                  {
                                       // (Re-)Compute the ideal size of the camera-preview display (the area 
                                           that the
                                // camera-preview frames get rendered onto, potentially with scaling and 
                                   rotation)
                              // based on the size of the SurfaceView that contains the display.
                                Size viewSize = new Size(width, height);
                                Size displaySize = 
                                cameraHelper.computeDisplaySizeFromViewSize(viewSize);

                            // Connect the converter to the camera-preview frames as its input (via
                            // previewFrameTexture), and configure the output width and height as the 
                              computed
                           // display size.
                           try{
                           //Application crashes here
                            converter.setSurfaceTextureAndAttachToGLContext(
                            previewFrameTexture, displaySize.getWidth(), displaySize.getHeight());

                    }
                    catch(Exception e)
                    {e.printStackTrace();}

                }

                @Override
                public void surfaceDestroyed(SurfaceHolder holder) {
                    processor.getVideoSurfaceOutput().setSurface(null);

                }
            });

Error Process: com.example.handtrackinggradle, PID: 23620 java.lang.RuntimeException: Error during attachToGLContext (see logcat for details) at android.graphics.SurfaceTexture.attachToGLContext(SurfaceTexture.java:289) at com.google.mediapipe.components.ExternalTextureConverter$RenderThread.setSurfaceTextureAndAttachToGLContext(ExternalTextureConverter.java:187) at com.google.mediapipe.components.ExternalTextureConverter.lambda$setSurfaceTextureAndAttachToGLContext$1$ExternalTextureConverter(ExternalTextureConverter.java:111) at com.google.mediapipe.components.-$$Lambda$ExternalTextureConverter$5RBq2uHoPl06wf2nG84kcgcgP_U.run(Unknown Source:8) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at com.google.mediapipe.glutil.GlThread.run(GlThread.java:134) 2019-12-13 04:44:59.014 23620-23718/com.example.handtrackinggradle E/native: loge.h:15 DataSourceMetrics: kFirstGlCallback: 567.448154ms 2019-12-13 04:44:59.016 23620-23719/com.example.handtrackinggradle E/native: loge.h:15 CameraMetrics: FirstCaptureComplete: 440.307692ms 2019-12-13 04:44:59.016 23620-23716/com.example.handtrackinggradle E/native: loge.h:15 DataSourc

mgyong commented 4 years ago

Closing this thread for now. If there are still issues, pls reopen

suraj-0387 commented 4 years ago

please reopen this issue as I didn't got any solution for it

brianm-sra commented 4 years ago

I am working to integrate mediapipe handtracking application with Arcore(Sceneform).I added arcore dependencies in mediapipe code and made few changes to it.

Did you make any progress on this? How did you add ARCore to mediapipe hand tracking app? I am interested in trying this for Android.

mohdahk commented 4 years ago

please reopen this issue as I didn't got any solution for it

Facing the same. Did we have any solution for this ?

boehm-e commented 4 years ago

+1

mohdahk commented 4 years ago

+1

hi @boehm-e , i see this issue closed. How can we reopen this ?

boehm-e commented 4 years ago

@mohdahk we can't they just decided this issue was solved 🙄

mohdahk commented 4 years ago

@boehm-e i have opened a new issue with reference to this issue. You can post in here. #751