将Rajawali表面视图布局参数设置为等于JavaCameraView

时间:2016-10-18 09:54:56

标签: android android-camera surfaceview opencv4android rajawali

我正在尝试使用Rajawali库在我的JavaCameraView上放置一个3d对象。我已经为JavaCameraView设置了最大帧大小,如下所示:

javaCameraView.setMaxFrameSize(640,480);

我希望我的表面布局参数与javacameraview(宽度和高度)的布局参数匹配,但不知怎的,我无法实现。我该怎么做?

     @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    javaCameraView = (JavaCameraView) findViewById(R.id.java_camera_view);
    javaCameraView.setVisibility(View.VISIBLE);
    javaCameraView.setCvCameraViewListener(this);
    javaCameraView.setMaxFrameSize(640,480);


    final RajawaliSurfaceView surface = new RajawaliSurfaceView(this);
    surface.setFrameRate(60.0);
    surface.setRenderMode(IRajawaliSurface.RENDERMODE_WHEN_DIRTY);
    surface.setTransparent(true);
    surface.setBackgroundColor(Color.MAGENTA);

    javaCameraView.setLayoutParams(new RelativeLayout.LayoutParams(640, 480));
    // Add mSurface to your root view
    addContentView(surface, new RelativeLayout.LayoutParams(320, 240));


    renderer = new Renderer(this);
    surface.setSurfaceRenderer(renderer);

    Log.d("NATIVE LOG", "Initialisation complete");
}

0 个答案:

没有答案