问题
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 got it working by following these steps.
Remove ActionBar - Go to values/styles and change
style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"
to
style name="AppTheme" parent="Theme.AppCompat.NoActionBar"
Set max frame size - use this code to set the frame size.
mOpenCvCameraView.setMaxFrameSize(720, 480);
回答2:
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
回答3:
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".
来源:https://stackoverflow.com/questions/13438897/opencv-fullscreen-using-camerabridgeviewbase-android