First time here? Check out the FAQ!

Ask Your Question
1

getting video to play fullscreen android

asked Nov 14 '12

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?

Preview: (hide)

4 answers

Sort by » oldest newest most voted
3

answered Nov 16 '12

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).

Preview: (hide)
1

answered Feb 1 '13

jameo gravatar image

updated Feb 4 '13

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 2.4.3.2 they have added a way to set the camera size

disconnectCamera();
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

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

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

Preview: (hide)
1

answered Nov 14 '12

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.

Preview: (hide)

Comments

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 (Nov 14 '12)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 (Nov 14 '12)edit

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

icedecker gravatar imageicedecker (Nov 14 '12)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 (Nov 14 '12)edit

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

icedecker gravatar imageicedecker (Nov 14 '12)edit

i see that there is a bug: http://code.opencv.org/issues/2549

subash gravatar imagesubash (Nov 18 '12)edit

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

Szippy gravatar imageSzippy (Dec 1 '12)edit
0

answered Nov 28 '12

franute gravatar image

updated Nov 28 '12

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.

Preview: (hide)

Comments

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

subash gravatar imagesubash (Dec 4 '12)edit

Question Tools

1 follower

Stats

Asked: Nov 14 '12

Seen: 5,503 times

Last updated: Feb 04 '13