user1768360
user1768360

Reputation: 193

Opencv fullscreen using CameraBridgeViewBase android

i am trying to set up Opencv on android using the given tutorials as the base. i havenot been able to control the video size on the screen, i want to enlarge it to full screen. i am using the CameraBridgeViewBase object as the VideoCapture object does not work. does anyone know how to set up the picture to be full screen?

relevant code:

public class Sample3Native extends Activity implements CvCameraViewListener {
private static final String TAG = "OCVSample::Activity";

private Mat                    mRgba;
private Mat                    mGrayMat;
private Mat                    mFinalMat;


public CameraBridgeViewBase   mOpenCvCameraView;



private BaseLoaderCallback     mLoaderCallback = new BaseLoaderCallback(this) {
    @Override
    public void onManagerConnected(int status) {



        switch (status) {
            case LoaderCallbackInterface.SUCCESS:
            {
                Log.i(TAG, "OpenCV loaded successfully");


                mOpenCvCameraView.enableView();

            } break;
            default:
            {
                super.onManagerConnected(status);
            } break;
        }
    }
};

public Sample3Native() {
    Log.i(TAG, "Instantiated new " + this.getClass());
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "called onCreate");
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);


    setContentView(R.layout.tutorial3_surface_view);


    mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.tutorial4_activity_surface_view);
    mOpenCvCameraView.setCvCameraViewListener(this);


}

any help would be much appreciated

Upvotes: 2

Views: 4649

Answers (3)

Rishabh Lashkari
Rishabh Lashkari

Reputation: 638

I got it working by following these steps.

  1. Remove ActionBar - Go to values/styles and change

    style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"

    to

    style name="AppTheme" parent="Theme.AppCompat.NoActionBar"

  2. Set max frame size - use this code to set the frame size.

    mOpenCvCameraView.setMaxFrameSize(720, 480);

Upvotes: 1

Shah
Shah

Reputation: 701

You need to set your activity Theme as Full Screen in Android Manifest file. In your activity add android:theme="@android:style/Theme.NoTitleBar.Fullscreen".

Upvotes: 0

Jameo
Jameo

Reputation: 4617

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, specifically the SampleJavaCameraView -> setResolution Method

Upvotes: 0

Related Questions