-1

I have an app that detects the eye using Firebase ML kit Detector in Java but I want the Camera Preview run on background and detect the eyes' position without showing in my screen.

The xml file is mentioned bellow. I' ve changed the visibility to invisible or gone but with no success.

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:visibility="visible">



        <com.example.eyetrackerdemo.CameraSourcePreview
            android:id="@+id/preview"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.example.eyetrackerdemo.GraphicOverlay
                android:id="@+id/barcodeOverlay"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </com.example.eyetrackerdemo.CameraSourcePreview>
    </LinearLayout>

Do you have any idea what implementation should I follow. Further I want to record the video that running on background and save it in the device.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
joe
  • 93
  • 2
  • 12

1 Answers1

0

One possible way is to use your camera view in your layout but not in the visible screen. Like,

<LinearLayout
      1...
      
      2...
         android:layout_height="match_parent"
 
      3.<org.opencv.android.JavaCameraView
          android:id="@+id/myCameraView"
          android:layout_width="match_parent"
          android:layout_height="200dp"
          app:show_fps="false" />

 </LinearLayout>

Pay attention to android:layout_height="match_parent" in the second widget. This enables the second widget to cover remain screen and doesn't give any space to the cameraview.

necip
  • 333
  • 4
  • 11