Ask Your Question

getting video to play fullscreen android

asked 2012-11-14 04:18:02 -0500

subash gravatar image

hi, i am using the native tutorials to show and edit video on an android tablet. the view i am getting is small and i want to get it to play on full screen. how can i do it?

edit retag flag offensive close merge delete

4 answers

Sort by » oldest newest most voted

answered 2012-11-16 01:39:46 -0500

It looks like some issue of CameraBridgeViewBase implementation. I have reproduced the problem on Samsung GT-I9100 with Android 4.0.4 (CM) and add a ticket.

As a workaround you can inherit your own view class from any concrete implementation of CameraBridgeViewBase (JavaCameraView or NativeCameraView) and override calculateCameraFrameSize method. JavaCameraView class implements view with standard android java camera api. NativeCameraView class implements view with native OpenCV camera (VideoCapture).

edit flag offensive delete link more

answered 2013-02-01 11:49:56 -0500

jameo gravatar image

updated 2013-02-04 08:53:53 -0500

For anyone still looking for this, I have solved the issue (sort-of). I cannot seem to get this to work for OpenCV v 2.4.3. I have tried everything on the internet. However, in OpenCV they have added a way to set the camera size

mMaxHeight = //your desired height
mMaxWidth = //your desired width
connectCamera(mMaxWidth, mMaxHeight);

Check out the OpenCV Tutorial 5(not included in 2.4.3 version), specifically the SampleJavaCameraView -> setResolution Method

Edit: Also, make sure in your manifests, you have


I think if you don't it can sometimes shrink the size slightly, depending on the screen size

edit flag offensive delete link more

answered 2012-11-14 05:39:08 -0500

icedecker gravatar image

You can get a list of the available resolutions or setup manually.

If you want to get the list of the available sizes and get the optimal camera size.

   if (mOpenCvCameraView != null) {
        List<Size> sizes = mOpenCvCameraView.getSupportedPreviewSizes();
        int mFrameWidth = width;
        int mFrameHeight = height;

        // selecting optimal camera size

            double minDiff = Double.MAX_VALUE;
            for (Size size : sizes) {
                if (Math.abs(size.height - height) < minDiff) {
                    mFrameWidth = (int) size.width;
                    mFrameHeight = (int) size.height;
                    minDiff = Math.abs(size.height - height);

        mOpenCvCameraView.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
        mOpenCvCameraView.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);

If the optimal camera size is not fullscreen, it is easy to get the great size that the camera support from the list.

Other option is to set manually the size:

        mOpenCvCameraView.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 1000);
        mOpenCvCameraView.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 800);

The source of the code is from Face Detection OpenCV version 2.4.2.

edit flag offensive delete link more


looks possible exept mOpenCvCameraView.set gives the warning "The method set(int, int) is undefined for the type CameraBridgeViewBase" , so there is no set fuction for the CameraBridgeViewBase object..

subash gravatar imagesubash ( 2012-11-14 06:12:00 -0500 )edit

Ok, it seems that the sample changed in OpenCV 2.4.3, that use the CameraBridgeViewBase. I don't not know how the object works, but in the documentation here maybe the connectCamera(width,height) do the work. But I'm not sure, try to see if it works.

icedecker gravatar imageicedecker ( 2012-11-14 06:49:25 -0500 )edit

Other option is to declare the mOpenCvCameraView as a VideoCapture object, instead of CameraBridgeViewBase.

icedecker gravatar imageicedecker ( 2012-11-14 06:53:03 -0500 )edit

the problem with connectCamera() is that it is not visible, it is protected "The method connectCamera(int, int) from the type CameraBridgeViewBase is not visible" do i need to define CameraBridgeViewBase in another way? –

subash gravatar imagesubash ( 2012-11-14 07:20:23 -0500 )edit

Try to use VideoCapture object instead of CameraBridgeViewBase. The VideoCapture have the set function.

icedecker gravatar imageicedecker ( 2012-11-14 09:36:01 -0500 )edit

i see that there is a bug:

subash gravatar imagesubash ( 2012-11-18 03:26:20 -0500 )edit

the bug was fixed 4 days ago, how can we get the fixed version of the code?

Szippy gravatar imageSzippy ( 2012-12-01 13:28:39 -0500 )edit

answered 2012-11-28 04:05:49 -0500

franute gravatar image

updated 2012-11-28 04:07:05 -0500

I'm experiencing the same problem with the camera, though I managed to solve it partially[*] by setting my activity to work in fullscreen mode.

Just add this before the setContentView in the onCreate method of your activity:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

[*] I said partially because still I can't select the resolution I want.

edit flag offensive delete link more


tried it, does not work for me... maybe i need to update the version

subash gravatar imagesubash ( 2012-12-04 03:01:58 -0500 )edit

Question Tools

1 follower


Asked: 2012-11-14 04:18:02 -0500

Seen: 5,132 times

Last updated: Feb 04 '13