Ask Your Question
0

OpenCV android camera preview with custom layout?

asked 2013-05-08 19:41:01 -0600

Marde gravatar image

updated 2013-05-15 01:51:40 -0600

I want to add a button to the opencvcamera preview, but the button isnt visible and the Preview still fills the whole screen. Is there a way to make a custom layout where the OpenCV camera preview does not fill the whole scrren to display an additional button?

 <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:opencv="http://schemas.android.com/apk/res-auto"

        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:orientation="horizontal">

        <org.opencv.android.NativeCameraView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:id="@+id/HelloOpenCvView"
            opencv:show_fps="true"
            opencv:camera_id="any" />

       <Button
        android:id="@+id/takepicture"  
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text=" * Take Picture " 
        android:layout_gravity="bottom|right"
        android:layout_margin="10px"
        />

     </LinearLayout >
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-05-15 03:14:26 -0600

Rafael Sierra gravatar image

I believe that's normal LinearLayout behavior, where an object grows (because of wrap_content) and pushes other objects off the screen.

Instead, what I use when I want to overlay buttons, is a RelativeLayout.

edit flag offensive delete link more

Comments

Ok thanks. I keep it in mind if I need it again. Its just I thought about how to get an ad banner to an opencv view. But it seems those Ad banner could just be overlayed.

Marde gravatar imageMarde ( 2013-05-15 06:30:10 -0600 )edit

Thank you. This method worked for me =)

AuroraBlaze gravatar imageAuroraBlaze ( 2014-12-26 01:25:57 -0600 )edit

Question Tools

Stats

Asked: 2013-05-08 19:41:01 -0600

Seen: 2,015 times

Last updated: May 15 '13