2

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

1
  • I have a similar problem. I want the preview to be in fullscreen but the resolution of the camera to be only 640x480 (to improve the speed)
    – Simon
    Commented Jan 8, 2013 at 16:18

3 Answers 3

1

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

0

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

0

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.