[android-developers] Re: Android camera orientation problem

2012-10-22 Thread spartygw
Camera.setDisplayOrientation works for me, I could never seem to get any 
rotation stuff to work that I tried to set using the Camera.Parameters.

-gw

On Monday, October 22, 2012 2:23:46 AM UTC-4, Haris wrote:
>
> Hi all For my application I am using android native camera and previewing 
> the image using surface view. But everything is working except the camera 
> orientation. When I open the camera by setting  
> screenOrientation="landscape on manifest file I am getting the preview 
> without any problem in landscape mode. But I need to take image in portrait 
> mode, for this I changed my manifest like  
> android:screenOrientation="portrait"  and change my code like 
> mCamera.setDisplayOrientation(90), params.set("orientation", 
> "landscape"),params.set("rotation", 90), but still I am getting 90 degree 
> rotated image. I searched a lot but nothing solved my problem...
>
> And my code is
>
>   public void setupCamera(int width, int height) {
> Log.i(TAG, "setupCamera");
> synchronized (this) {
> if (mCamera != null) {
> Camera.Parameters params = mCamera.getParameters();
> List sizes = 
> params.getSupportedPreviewSizes();
> List 
> imgsize=params.getSupportedPictureSizes();
> mFrameWidth = width;
> mFrameHeight = height;
>
>// mCamera.setDisplayOrientation(90);
> params.set("orientation", "landscape");
>  params.set("rotation", 90);
> // selecting optimal camera preview size
> {
> int  minDiff = Integer.MAX_VALUE;
> for (Camera.Size size : sizes) {
> if (Math.abs(size.height - height) < minDiff) {
> mFrameWidth = size.width;
> mFrameHeight = size.height;
> minDiff = Math.abs(size.height - height);
> }
> }
> }
>
> params.setPreviewSize(getFrameWidth(), getFrameHeight());
> 
>
> 
>
> List FocusModes = params.getSupportedFocusModes();
> if 
> (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
> {
> 
> params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
> }
> 
> mCamera.setParameters(params);
> 
>  
>
> mCamera.startPreview();
> }
> }
> }
>
>
> I am using micromax A52 mmodel with android 2.3
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Android camera orientation problem

2012-10-22 Thread Haris
I don't know why it's not worked with me. If I set orientation as portrait 
in manifest file I am getting 90 degree rotated image in my preview. But in 
the case of landscape orientation I am getting normal image in my preview 
while my phone orientation is portrait I know it is 90 degree rotated from 
landscape ,  and while saving or drawing  to a canvas I am getting 90 
degree rotated image. For this issue I just rotated my image 90 degree 
backward. I thought it is better to set the orientation correctly rather 
than rotating the image after capture.  

On Monday, 22 October 2012 20:58:26 UTC+5:30, spartygw wrote:
>
> Camera.setDisplayOrientation works for me, I could never seem to get any 
> rotation stuff to work that I tried to set using the Camera.Parameters.
>
> -gw
>
> On Monday, October 22, 2012 2:23:46 AM UTC-4, Haris wrote:
>>
>> Hi all For my application I am using android native camera and previewing 
>> the image using surface view. But everything is working except the camera 
>> orientation. When I open the camera by setting  
>> screenOrientation="landscape on manifest file I am getting the preview 
>> without any problem in landscape mode. But I need to take image in portrait 
>> mode, for this I changed my manifest like  
>> android:screenOrientation="portrait"  and change my code like 
>> mCamera.setDisplayOrientation(90), params.set("orientation", 
>> "landscape"),params.set("rotation", 90), but still I am getting 90 degree 
>> rotated image. I searched a lot but nothing solved my problem...
>>
>> And my code is
>>
>>   public void setupCamera(int width, int height) {
>> Log.i(TAG, "setupCamera");
>> synchronized (this) {
>> if (mCamera != null) {
>> Camera.Parameters params = mCamera.getParameters();
>> List sizes = 
>> params.getSupportedPreviewSizes();
>> List 
>> imgsize=params.getSupportedPictureSizes();
>> mFrameWidth = width;
>> mFrameHeight = height;
>>
>>// mCamera.setDisplayOrientation(90);
>> params.set("orientation", "landscape");
>>  params.set("rotation", 90);
>> // selecting optimal camera preview size
>> {
>> int  minDiff = Integer.MAX_VALUE;
>> for (Camera.Size size : sizes) {
>> if (Math.abs(size.height - height) < minDiff) {
>> mFrameWidth = size.width;
>> mFrameHeight = size.height;
>> minDiff = Math.abs(size.height - height);
>> }
>> }
>> }
>>
>> params.setPreviewSize(getFrameWidth(), getFrameHeight());
>> 
>>
>> 
>>
>> List FocusModes = params.getSupportedFocusModes();
>> if 
>> (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
>> {
>> 
>> params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
>> }
>> 
>> mCamera.setParameters(params);
>> 
>>  
>>
>> mCamera.startPreview();
>> }
>> }
>> }
>>
>>
>> I am using micromax A52 mmodel with android 2.3
>>
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Android camera orientation problem

2012-10-23 Thread Flame-Tree
Have you tried you application on any other phone. As you are accessing 
setparameter/getparameter; which is more specific with your hardware 
support. 
Have you tried any android application from Google play which 
behaves the way you would like. Confirm whether Phone provides the 
functionality or not 


 

On Monday, 22 October 2012 11:53:46 UTC+5:30, Haris wrote:
>
> Hi all For my application I am using android native camera and previewing 
> the image using surface view. But everything is working except the camera 
> orientation. When I open the camera by setting  
> screenOrientation="landscape on manifest file I am getting the preview 
> without any problem in landscape mode. But I need to take image in portrait 
> mode, for this I changed my manifest like  
> android:screenOrientation="portrait"  and change my code like 
> mCamera.setDisplayOrientation(90), params.set("orientation", 
> "landscape"),params.set("rotation", 90), but still I am getting 90 degree 
> rotated image. I searched a lot but nothing solved my problem...
>
> And my code is
>
>   public void setupCamera(int width, int height) {
> Log.i(TAG, "setupCamera");
> synchronized (this) {
> if (mCamera != null) {
> Camera.Parameters params = mCamera.getParameters();
> List sizes = 
> params.getSupportedPreviewSizes();
> List 
> imgsize=params.getSupportedPictureSizes();
> mFrameWidth = width;
> mFrameHeight = height;
>
>// mCamera.setDisplayOrientation(90);
> params.set("orientation", "landscape");
>  params.set("rotation", 90);
> // selecting optimal camera preview size
> {
> int  minDiff = Integer.MAX_VALUE;
> for (Camera.Size size : sizes) {
> if (Math.abs(size.height - height) < minDiff) {
> mFrameWidth = size.width;
> mFrameHeight = size.height;
> minDiff = Math.abs(size.height - height);
> }
> }
> }
>
> params.setPreviewSize(getFrameWidth(), getFrameHeight());
> 
>
> 
>
> List FocusModes = params.getSupportedFocusModes();
> if 
> (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
> {
> 
> params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
> }
> 
> mCamera.setParameters(params);
> 
>  
>
> mCamera.startPreview();
> }
> }
> }
>
>
> I am using micromax A52 mmodel with android 2.3
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Android camera orientation problem

2012-10-23 Thread Haris
Hi  thanks for your reply I didn't check that yet. I will try that.. 

On Tuesday, 23 October 2012 17:38:06 UTC+5:30, Flame-Tree wrote:
>
> Have you tried you application on any other phone. As you are accessing 
> setparameter/getparameter; which is more specific with your hardware 
> support. 
> Have you tried any android application from Google play which 
> behaves the way you would like. Confirm whether Phone provides the 
> functionality or not 
>
>
>  
>
> On Monday, 22 October 2012 11:53:46 UTC+5:30, Haris wrote:
>>
>> Hi all For my application I am using android native camera and previewing 
>> the image using surface view. But everything is working except the camera 
>> orientation. When I open the camera by setting  
>> screenOrientation="landscape on manifest file I am getting the preview 
>> without any problem in landscape mode. But I need to take image in portrait 
>> mode, for this I changed my manifest like  
>> android:screenOrientation="portrait"  and change my code like 
>> mCamera.setDisplayOrientation(90), params.set("orientation", 
>> "landscape"),params.set("rotation", 90), but still I am getting 90 degree 
>> rotated image. I searched a lot but nothing solved my problem...
>>
>> And my code is
>>
>>   public void setupCamera(int width, int height) {
>> Log.i(TAG, "setupCamera");
>> synchronized (this) {
>> if (mCamera != null) {
>> Camera.Parameters params = mCamera.getParameters();
>> List sizes = 
>> params.getSupportedPreviewSizes();
>> List 
>> imgsize=params.getSupportedPictureSizes();
>> mFrameWidth = width;
>> mFrameHeight = height;
>>
>>// mCamera.setDisplayOrientation(90);
>> params.set("orientation", "landscape");
>>  params.set("rotation", 90);
>> // selecting optimal camera preview size
>> {
>> int  minDiff = Integer.MAX_VALUE;
>> for (Camera.Size size : sizes) {
>> if (Math.abs(size.height - height) < minDiff) {
>> mFrameWidth = size.width;
>> mFrameHeight = size.height;
>> minDiff = Math.abs(size.height - height);
>> }
>> }
>> }
>>
>> params.setPreviewSize(getFrameWidth(), getFrameHeight());
>> 
>>
>> 
>>
>> List FocusModes = params.getSupportedFocusModes();
>> if 
>> (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
>> {
>> 
>> params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
>> }
>> 
>> mCamera.setParameters(params);
>> 
>>  
>>
>> mCamera.startPreview();
>> }
>> }
>> }
>>
>>
>> I am using micromax A52 mmodel with android 2.3
>>
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Android camera orientation problem

2012-10-23 Thread Jim Graham
On Mon, Oct 22, 2012 at 09:53:12PM -0700, Haris wrote:
> I don't know why it's not worked with me. If I set orientation as
> portrait in manifest file I am getting 90 degree rotated image in my
> preview. But in the case of landscape orientation I am getting normal
> image in my preview while my phone orientation is portrait I know it is
> 90 degree rotated from landscape ,  and while saving or drawing  to a
> canvas I am getting 90 degree rotated image. For this issue I just
> rotated my image 90 degree backward. I thought it is better to set the
> orientation correctly rather than rotating the image after
> capture.  

I'm assuming that you have some specific reason for wanting to use
portrait, where "normal" camera orientation is landscape?  In every
camera I've seen, used, or read about, the normal orientation is
landscape.  If you want portrait, you have to rotate the camera.
I recall reading somewhere in the developer's guide docs on the
camera that (as with 35mm and DSLR cameras) the Android camera's
normal orientation is landscape.  You CAN change that in java,
if you want to, though (but why would you?  if the user wants
to rotate the camera for a portrait-oriented shot, they'll
just rotate the device)

Later,
   --jim

-- 
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4) //  North American Hunting Club Member #70781171
ICBM/Hurr.: 30.44406N 86.59909W // Running Mac OS X Lion >

   "Now what *you* need is a proper pint of porter poured in a proper
   pewter porter pot.." --Peter Dalgaard in alt.sysadmin.recovery


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Android camera orientation problem

2012-10-23 Thread Adam Ratana
Haris, take a look a this:

http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)

This is for API 8 (2.2+) devices.  I've found that there's no reliable way 
to guarantee this to work on 2.1 devices by setting the camera parameters 
the way you are now, some just won't do it.

I've just spent quite a bit of my spare time working on implementing a 
portrait mode activity option for the camera preview - to answer Spooky's 
question, the main reason one might do this is because it goes well with 
the UI/UX of the application (specifically the other activities which share 
a common UI), and the application for the camera activity is augmented 
reality, and for most devices that I've had experience with, the sensors 
seem to be most accurate when the phone is held in portrait - though this 
can clearly vary.  It also was desired to have a working portrait mode 
version of the camera activity, instead of forcing the user to then change 
the way they were holding the device.  Instagram is one massively popular 
application which does this as well (or at least, appears to do so), and I 
think it works well with their UI.

You can of course, take advantage of the above method to simply rotate the 
preview depending on the current orientation of the device - either 
portrait or landscape, and indeed have different UIs for either scenario if 
you wish.  Of course then choosing the optimal preview size for your 
orientation, taking into account status bars or full screen, etc, can then 
be tricky and yield different results for each.  The default camera app 
seems to rotate it's UI elements which is a pretty neat solution.  Rotating 
any preview frames or shots is the least of the worries here, that's 
relatively simple to do.

I plan on cleaning up and open sourcing a proof of concept project I built 
which does a bunch of things, including dealing with having a camera 
orientation the same as the device orientation, and rotating it when the 
device rotates, etc, since this seems a really painful thing.  I'll post 
back here when it's up, probably within a month.


On Tuesday, October 23, 2012 12:28:46 PM UTC-4, Spooky wrote:
>
> I'm assuming that you have some specific reason for wanting to use 
> portrait, where "normal" camera orientation is landscape?  In every 
> camera I've seen, used, or read about, the normal orientation is 
> landscape.  If you want portrait, you have to rotate the camera. 
> I recall reading somewhere in the developer's guide docs on the 
> camera that (as with 35mm and DSLR cameras) the Android camera's 
> normal orientation is landscape.  You CAN change that in java, 
> if you want to, though (but why would you?  if the user wants 
> to rotate the camera for a portrait-oriented shot, they'll 
> just rotate the device) 
>
> Later, 
>--jim 
>
> -- 
> THE SCORE:  ME:  2  CANCER:  0 
> 73 DE N5IAL (/4) //  North American Hunting Club Member #70781171 
> ICBM/Hurr.: 30.44406N 86.59909W // Running Mac OS X Lion > 
>
>"Now what *you* need is a proper pint of porter poured in a proper 
>pewter porter pot.." --Peter Dalgaard in alt.sysadmin.recovery 
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Android camera orientation problem

2012-10-23 Thread Haris
Hi thanks all for your replays.. 

Yesterday I have checked some application from google play like 
pudding camera etc. and it's working perfectly. Even if I access the 
default camera from my application I am getting normal preview but while 
saving it is rotated. The reason why I need to use in portrait mode is that 
after capture I have to do some image processing algorithms on the image 
using opencv, and  on the JNI part it seems that  height of the image 
became width and width became height and all these because of the rotation. 
To avoid that confusion, -I know that not a big issue I just need to rotate 
the image 90 degree  backward-  I thought it is better to modify the camera 
orientation . Can any one give me a working source code for changing the 
camera orientation, may be it's my coding problem

Thanks
Haris

On Wednesday, 24 October 2012 10:20:31 UTC+5:30, Adam Ratana wrote:
>
> Haris, take a look a this:
>
>
> http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
>
> This is for API 8 (2.2+) devices.  I've found that there's no reliable way 
> to guarantee this to work on 2.1 devices by setting the camera parameters 
> the way you are now, some just won't do it.
>
> I've just spent quite a bit of my spare time working on implementing a 
> portrait mode activity option for the camera preview - to answer Spooky's 
> question, the main reason one might do this is because it goes well with 
> the UI/UX of the application (specifically the other activities which share 
> a common UI), and the application for the camera activity is augmented 
> reality, and for most devices that I've had experience with, the sensors 
> seem to be most accurate when the phone is held in portrait - though this 
> can clearly vary.  It also was desired to have a working portrait mode 
> version of the camera activity, instead of forcing the user to then change 
> the way they were holding the device.  Instagram is one massively popular 
> application which does this as well (or at least, appears to do so), and I 
> think it works well with their UI.
>
> You can of course, take advantage of the above method to simply rotate the 
> preview depending on the current orientation of the device - either 
> portrait or landscape, and indeed have different UIs for either scenario if 
> you wish.  Of course then choosing the optimal preview size for your 
> orientation, taking into account status bars or full screen, etc, can then 
> be tricky and yield different results for each.  The default camera app 
> seems to rotate it's UI elements which is a pretty neat solution.  Rotating 
> any preview frames or shots is the least of the worries here, that's 
> relatively simple to do.
>
> I plan on cleaning up and open sourcing a proof of concept project I built 
> which does a bunch of things, including dealing with having a camera 
> orientation the same as the device orientation, and rotating it when the 
> device rotates, etc, since this seems a really painful thing.  I'll post 
> back here when it's up, probably within a month.
>
>
> On Tuesday, October 23, 2012 12:28:46 PM UTC-4, Spooky wrote:
>>
>> I'm assuming that you have some specific reason for wanting to use 
>> portrait, where "normal" camera orientation is landscape?  In every 
>> camera I've seen, used, or read about, the normal orientation is 
>> landscape.  If you want portrait, you have to rotate the camera. 
>> I recall reading somewhere in the developer's guide docs on the 
>> camera that (as with 35mm and DSLR cameras) the Android camera's 
>> normal orientation is landscape.  You CAN change that in java, 
>> if you want to, though (but why would you?  if the user wants 
>> to rotate the camera for a portrait-oriented shot, they'll 
>> just rotate the device) 
>>
>> Later, 
>>--jim 
>>
>> -- 
>> THE SCORE:  ME:  2  CANCER:  0 
>> 73 DE N5IAL (/4) //  North American Hunting Club Member #70781171 
>> ICBM/Hurr.: 30.44406N 86.59909W // Running Mac OS X Lion > 
>>
>>"Now what *you* need is a proper pint of porter poured in a proper 
>>pewter porter pot.." --Peter Dalgaard in alt.sysadmin.recovery 
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Android camera orientation problem

2012-10-23 Thread Haris
Hi thanks all for your replays.. 

Yesterday I have checked some application from google play like 
pudding camera etc. and it's working perfectly. Even if I access the 
default camera from my application I am getting normal preview but while 
saving it is rotated. The reason why I need to use in portrait mode is that 
after capture I have to do some image processing algorithms on the image 
using opencv, and  on the JNI part it seems that  height of the image 
became width and width became height and all these because of the rotation. 
To avoid that confusion, -I know that not a big issue I just need to rotate 
the image 90 degree  backward-  I thought it is better to modify the camera 
orientation . Can any one give me a working source code for changing the 
camera orientation, may be it's my coding problem

Thanks
Haris

On Wednesday, 24 October 2012 10:20:31 UTC+5:30, Adam Ratana wrote:
>
> Haris, take a look a this:
>
>
> http://developer.android.com/reference/android/hardware/Camera.html#setDisplayOrientation(int)
>
> This is for API 8 (2.2+) devices.  I've found that there's no reliable way 
> to guarantee this to work on 2.1 devices by setting the camera parameters 
> the way you are now, some just won't do it.
>
> I've just spent quite a bit of my spare time working on implementing a 
> portrait mode activity option for the camera preview - to answer Spooky's 
> question, the main reason one might do this is because it goes well with 
> the UI/UX of the application (specifically the other activities which share 
> a common UI), and the application for the camera activity is augmented 
> reality, and for most devices that I've had experience with, the sensors 
> seem to be most accurate when the phone is held in portrait - though this 
> can clearly vary.  It also was desired to have a working portrait mode 
> version of the camera activity, instead of forcing the user to then change 
> the way they were holding the device.  Instagram is one massively popular 
> application which does this as well (or at least, appears to do so), and I 
> think it works well with their UI.
>
> You can of course, take advantage of the above method to simply rotate the 
> preview depending on the current orientation of the device - either 
> portrait or landscape, and indeed have different UIs for either scenario if 
> you wish.  Of course then choosing the optimal preview size for your 
> orientation, taking into account status bars or full screen, etc, can then 
> be tricky and yield different results for each.  The default camera app 
> seems to rotate it's UI elements which is a pretty neat solution.  Rotating 
> any preview frames or shots is the least of the worries here, that's 
> relatively simple to do.
>
> I plan on cleaning up and open sourcing a proof of concept project I built 
> which does a bunch of things, including dealing with having a camera 
> orientation the same as the device orientation, and rotating it when the 
> device rotates, etc, since this seems a really painful thing.  I'll post 
> back here when it's up, probably within a month.
>
>
> On Tuesday, October 23, 2012 12:28:46 PM UTC-4, Spooky wrote:
>>
>> I'm assuming that you have some specific reason for wanting to use 
>> portrait, where "normal" camera orientation is landscape?  In every 
>> camera I've seen, used, or read about, the normal orientation is 
>> landscape.  If you want portrait, you have to rotate the camera. 
>> I recall reading somewhere in the developer's guide docs on the 
>> camera that (as with 35mm and DSLR cameras) the Android camera's 
>> normal orientation is landscape.  You CAN change that in java, 
>> if you want to, though (but why would you?  if the user wants 
>> to rotate the camera for a portrait-oriented shot, they'll 
>> just rotate the device) 
>>
>> Later, 
>>--jim 
>>
>> -- 
>> THE SCORE:  ME:  2  CANCER:  0 
>> 73 DE N5IAL (/4) //  North American Hunting Club Member #70781171 
>> ICBM/Hurr.: 30.44406N 86.59909W // Running Mac OS X Lion > 
>>
>>"Now what *you* need is a proper pint of porter poured in a proper 
>>pewter porter pot.." --Peter Dalgaard in alt.sysadmin.recovery 
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Android camera orientation problem

2012-10-23 Thread Adam Ratana
Haris, check the link I provided, this is code you can call which will make
the camera orientation the same as the activity orientation.  for instance
if you set the activity orientation to portrait, calling the method will
also rotate the camera preview --

http://developer.android.com/**reference/android/hardware/**Camera.html#**
setDisplayOrientation(int)

they provide some code here.  Note that any preview frames will not be
rotate, though.

"If you want to make the camera image show in the same orientation as the
display, you can use the following code."

public static void setCameraDisplayOrientation(Activity activity,
 int cameraId, android.hardware.Camera camera) {
 android.hardware.Camera.CameraInfo info =
 new android.hardware.Camera.CameraInfo();
 android.hardware.Camera.getCameraInfo(cameraId, info);
 int rotation = activity.getWindowManager().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;
 }

 int result;
 if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
 result = (info.orientation + degrees) % 360;
 result = (360 - result) % 360;  // compensate the mirror
 } else {  // back-facing
 result = (info.orientation - degrees + 360) % 360;
 }
 camera.setDisplayOrientation(result);
 }


On Wed, Oct 24, 2012 at 1:46 AM, Haris  wrote:

> Hi thanks all for your replays..
>
> Yesterday I have checked some application from google play like
> pudding camera etc. and it's working perfectly. Even if I access the
> default camera from my application I am getting normal preview but while
> saving it is rotated. The reason why I need to use in portrait mode is that
> after capture I have to do some image processing algorithms on the image
> using opencv, and  on the JNI part it seems that  height of the image
> became width and width became height and all these because of the rotation.
> To avoid that confusion, -I know that not a big issue I just need to rotate
> the image 90 degree  backward-  I thought it is better to modify the camera
> orientation . Can any one give me a working source code for changing the
> camera orientation, may be it's my coding problem
>
> Thanks
> Haris
>
>
> On Wednesday, 24 October 2012 10:20:31 UTC+5:30, Adam Ratana wrote:
>>
>> Haris, take a look a this:
>>
>> http://developer.android.com/**reference/android/hardware/**Camera.html#*
>> *setDisplayOrientation(int)
>>
>> This is for API 8 (2.2+) devices.  I've found that there's no reliable
>> way to guarantee this to work on 2.1 devices by setting the camera
>> parameters the way you are now, some just won't do it.
>>
>> I've just spent quite a bit of my spare time working on implementing a
>> portrait mode activity option for the camera preview - to answer Spooky's
>> question, the main reason one might do this is because it goes well with
>> the UI/UX of the application (specifically the other activities which share
>> a common UI), and the application for the camera activity is augmented
>> reality, and for most devices that I've had experience with, the sensors
>> seem to be most accurate when the phone is held in portrait - though this
>> can clearly vary.  It also was desired to have a working portrait mode
>> version of the camera activity, instead of forcing the user to then change
>> the way they were holding the device.  Instagram is one massively popular
>> application which does this as well (or at least, appears to do so), and I
>> think it works well with their UI.
>>
>> You can of course, take advantage of the above method to simply rotate
>> the preview depending on the current orientation of the device - either
>> portrait or landscape, and indeed have different UIs for either scenario if
>> you wish.  Of course then choosing the optimal preview size for your
>> orientation, taking into account status bars or full screen, etc, can then
>> be tricky and yield different results for each.  The default camera app
>> seems to rotate it's UI elements which is a pretty neat solution.  Rotating
>> any preview frames or shots is the least of the worries here, that's
>> relatively simple to do.
>>
>> I plan on cleaning up and open sourcing a proof of concept project I
>> built which does a bunch of things, including dealing with having a camera
>> orientation the same as the device orientation, and rotating it when the
>> device rotates, etc, since this seems a really painful thing.  I'll post
>> back here when it's up, probably within a month.
>>
>>
>> On 

Re: [android-developers] Re: Android camera orientation problem

2012-10-24 Thread Jim Graham
On Tue, Oct 23, 2012 at 09:50:31PM -0700, Adam Ratana wrote:

> I've just spent quite a bit of my spare time working on implementing a 
> portrait mode activity option for the camera preview - to answer Spooky's 
> question, the main reason one might do this is because it goes well with 
> the UI/UX of the application (specifically the other activities which share 
> a common UI), and the application for the camera activity is augmented 
> reality,

Ahhh, yes.  Good point.  I hadn't thought about that.

Later,
   --jim

-- 
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4) //  North American Hunting Club Member #70781171
ICBM/Hurr.: 30.44406N 86.59909 // Running Mac OS X Lion >W

Seen in alt.sysadmin.recovery:  "Priceless; that's better than telling
him to use the Read Manual command with the Real Fast option."

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en