Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Rotate camera JavaCameraView

$
0
0
I'm using JavaCameraView. This is Android application and it supports both Portrait and Landscape modes. I am able to set correct preview and picture size for camera BUT for some reason rotation parameter is ignored and preview is only OK in landscape mode. This is the code I use to set orientation: private void setCameraDisplayOrientation(Camera camera) { int cameraId = getCameraId(); android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo(); android.hardware.Camera.getCameraInfo(cameraId, info); WindowManager windowManager = (WindowManager) getContext() .getSystemService(Context.WINDOW_SERVICE); int rotation = windowManager.getDefaultDisplay().getRotation(); int degrees = 0; switch (rotation) { case Surface.ROTATION_0: degrees = 0; break; case Surface.ROTATION_90: degrees = 90; break; case Surface.ROTATION_180: degrees = 180; break; case Surface.ROTATION_270: degrees = 270; break; } camera.setDisplayOrientation((info.orientation - degrees + 360) % 360); } Obviously I can rotate picture in onCameraFrame but it looks like waste of resources to me. Does OpenCV camera even support orientation other than Landscape?

Viewing all articles
Browse latest Browse all 41027

Trending Articles