First I get into JavaCameraView.java class in the OpenCV Library and then in the initializeCamera add the following lines just before mCamera.startPreview(); private SurfaceTexture mSurfaceTexture1; protected Camera mCamera; mCamera = Camera.open(); Camera.Parameters p = mCamera.getParameters(); p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); mCam.setParameters(p); mSurfaceTexture1 = new SurfaceTexture(0); try { mCamera.setPreviewTexture(mSurfaceTexture1); } catch (IOException ex) { // Ignore } mCamera.startPreview();
First I get into JavaCameraView.java class in the OpenCV Library and then in the initializeCamera add the following lines just before mCamera.startPreview(); setDisplayOrientation(mCamera, 90); mCamera.setPreviewDisplay(getHolder()); The first function implemented like this protected void setDisplayOrientation(Camera camera, int angle){ Method downPolymorphic; try { downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class }); if (downPolymorphic != null) downPolymorphic.invoke(camera, new Object[] { angle }); } catch (Exception e1) { e1.printStackTrace(); } } Reference : https://stackov...