How to Overlay drawing on CameraX display.

3,376 views
Skip to first unread message

Rob

unread,
Jun 19, 2020, 8:28:56 AM6/19/20
to Android CameraX Discussion Group
Hi All,

We are trying to figure out how to overlay drawing ON the PreviewView on which the Camerax is displayed. We already know where the face is located so we don't
need to use Firebase to get that information. We tried placing an ImageView over the PreviewView and creating a transparent bitmap displayed in the ImageView.

We did this with Camera1 and Camera2 using a TextureView, for the camera display and ImageView for drawing but are having difficulty with CameraX.
Does anyone have a sample, preferable in Java, but anything is fine or idea if this is the correct approach.  We have seen a few, but they are done with the pre alpha07 update.


<ImageView
    android:id="@+id/overlayView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible" />

<androidx.camera.view.PreviewView
    android:id="@+id/view_finder"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />


Thanks,

Rob

Scott Nien

unread,
Jun 19, 2020, 10:16:07 PM6/19/20
to Rob, Android CameraX Discussion Group
Hi Rob, 
Can you try to swap the order of <ImageView> and <PreviewView> ?   Does it fix the problem ? 

Scott

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/4f4bc112-3efa-4c6f-965b-d594efa3ddc6o%40android.com.

adnan ganie

unread,
Jun 19, 2020, 11:39:47 PM6/19/20
to Android CameraX Discussion Group
yes, we can but using constraintLayout
<ImageView
app:layout_constraintEnd_toEndOf="view_finder"
app:layout_constraintStart_toStartOf="view_finder"
app:layout_constraintTop_toTopOf="view_finder"
app:layout_constraintBottom_BottomOf="view_finder"
   android:id="@+id/overlayView"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:visibility="visible" />

<androidx.camera.view.PreviewView
   android:id="@+id/view_finder"
   android:layout_width="match_parent"
   android:layout_height="match_parent" />

Rob

unread,
Jun 20, 2020, 7:11:27 AM6/20/20
to Android CameraX Discussion Group, r9o...@gmail.com
Yes that did help.  We tried so many things, I'm sure we tried that, but we must have had other issues and never flipped it back.
Thanks,
Rob


On Friday, June 19, 2020 at 10:16:07 PM UTC-4, Scott Nien wrote:
Hi Rob, 
Can you try to swap the order of <ImageView> and <PreviewView> ?   Does it fix the problem ? 

Scott

On Fri, Jun 19, 2020 at 8:28 PM Rob <r9o...@gmail.com> wrote:
Hi All,

We are trying to figure out how to overlay drawing ON the PreviewView on which the Camerax is displayed. We already know where the face is located so we don't
need to use Firebase to get that information. We tried placing an ImageView over the PreviewView and creating a transparent bitmap displayed in the ImageView.

We did this with Camera1 and Camera2 using a TextureView, for the camera display and ImageView for drawing but are having difficulty with CameraX.
Does anyone have a sample, preferable in Java, but anything is fine or idea if this is the correct approach.  We have seen a few, but they are done with the pre alpha07 update.


<ImageView
    android:id="@+id/overlayView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:visibility="visible" />

<androidx.camera.view.PreviewView
    android:id="@+id/view_finder"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />


Thanks,

Rob

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-developers+unsub...@android.com.

Scott Nien

unread,
Jun 20, 2020, 9:35:58 PM6/20/20
to Rob, Android CameraX Discussion Group
Hi Rob, 
What are the specific issues when you try to place an ImageView on top of a PreviewView ?  

To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/0bc7aa27-0efb-4a60-bcf0-0a7e4993ba1do%40android.com.
Reply all
Reply to author
Forward
0 new messages