Ask Your Question
2

Android camera image rotation

asked 2013-02-05 07:43:55 -0600

arsalank2 gravatar image

Does OpenCV support different device orientations (i.e. portrait and lanscape etc.) on Android?

I am capturing camera frames on the native side. If the device orientation is not landscape, the images are rotated. Is there a way to fix the rotation without manually rotating the captured image?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-02-05 10:32:07 -0600

matt.hammer gravatar image

updated 2013-02-05 10:32:43 -0600

I had a rotation issue with my Samsung Galaxy S3 - I had to use

                    camera.setDisplayOrientation(90);

to correct the problem - I think when I googled the issue it was a hardware setting on the camera

edit flag offensive delete link more

Comments

You are right, but I need to set this from native code, not from Java side.

arsalank2 gravatar imagearsalank2 ( 2013-02-07 06:24:19 -0600 )edit

Could you invoke this method via the JNI?

matt.hammer gravatar imagematt.hammer ( 2013-02-07 17:06:39 -0600 )edit

How to get access to the camera object?

arsalank2 gravatar imagearsalank2 ( 2013-02-11 02:50:23 -0600 )edit

@matt.hammer Where did you place this line of code???

jameo gravatar imagejameo ( 2013-02-11 08:27:39 -0600 )edit

In Java with the SDK, right after: Camera camera = Camera.open(); My JNI is rusty, but I think you could make this call with it.

matt.hammer gravatar imagematt.hammer ( 2013-02-11 13:26:54 -0600 )edit

@matt.hammer I am using the JavaCameraView, there is no call to Camera.open(), any suggestions? I also have the S3 and have been frustrated with that line of code not actually changing the orientation

jameo gravatar imagejameo ( 2013-02-12 08:10:32 -0600 )edit

@arsalank2 Did you find a solution?

powder366 gravatar imagepowder366 ( 2013-08-22 15:22:11 -0600 )edit

@jameo have you got a solution? I had tried to cast the JavaCameraView and reached to Camera.open() lines, but I still failed to rotate the view by adding "camera.setDisplayOrientation(90);" @matt.hammer could you tell me more about this?

Zeo gravatar imageZeo ( 2013-11-10 07:10:55 -0600 )edit

Anyone ever figure this out? There seems to not be a solution anywhere on the internet for this. cam.setDisplayOrientation(90) simply doesn't work. Any other solutions out there rely on pixel manipulations that vastly degrade the framerate....

wpccolorblind gravatar imagewpccolorblind ( 2014-02-12 00:53:42 -0600 )edit

Question Tools

Stats

Asked: 2013-02-05 07:43:55 -0600

Seen: 4,280 times

Last updated: Feb 05 '13