I am busy writing an app that lets me use my phone (Galaxy S2 2.2.3) as a steering wheel. Just a nerdy weekend project really.
I have gotten everything working regarding calculating the orientation of the device using SensorManager.GetOrientation() with a slight snag. The rotation around the axis which comes out of the screen and back of the phone rises from 0 to 90 degrees and then falls back down in the same manner to 0 degrees instead of proceeding to 180.
This had me really confused until I read something somewhere that suggested the API might be flipping (internally as the screen doesn't flip) orientation so the phones coordinates system is flipping from left to right landscape (Its worth noting that I have it locked in landscape mode in the Manifest). This explains the weird behaviour in terms of orientation.
Does anyone know how to stop this happening, or have I gone wrong completely in my understanding?
Related
I'm just starting a cardboard project as it's really joyful to experiment VR without any huge hardware, but I have a little problem which sounds really basic : the screen orientation. I just would have my game playable in Landscape Right instead of Left as I'm developing on my Xperia Z.
Usually screen orientation's problems are solved by forcing the orientation through the Player's Settings in the Build Menu. But here, the fact is that when I tick the "Landscape Right" box instead of the left one (which is the default setting of the Cardboard API) it correctly inverts my display but my camera stays at the same orientation as before.
From this results that my gyroscope works in reverse and that the ground is seen on the top, with all the texts reversed as well.
I've already done what Eldir tried here (Google cardboard device orientation) but as it wasn't the same problem I'm having, it wasn't efficient.
Do you have any ideas that if the API allows a quick change for this, or if I have to modify the whole parameters of the gyroscope ?
Thanks !
I have a server component that processes video uploads for a web/iOS/Android application.
However I am running into a problem handling the video orientation. Is there a good way to solve this? I have a tool MediaInfo that rips the meta data out of the device but this is what i am encountering
iOS
the portrait is correct 90 or 270
the landscape is crazy. if you hold the device with the button to the left, it reports 0 for the front camera and 180 for the back
Android
here the situation is reversed the landscape is correct both front and back camera
the portrait is 90 or 270 depending on if you are using the front or back camera
furthermore some devices like Motorola Droids and Evo4G dont record the meta data at all
has anyone seen a clean solution for this?
There is no clean solution for android devices that do not report the orientation.
For all the other orientations, I had overly complicated it in my mind. The flip between front and back means the angles are correct if rotated clockwise
So I'm pretty new to Android programming and my current project involves moving a picture left and right by tilting. It works fine but I can't figure out how to make the accelerometer useful in landscape mode (forced landscape). I get good results if i hold the phone upright (it remains in landscape) but obviously that doesn't really fulfill my needs. Is there a quick fix for this I can use?
I made a particle system that was designed for a tablet.. particles follow finger movement etc. anyways.. I implemented the gyroscope so when you tilt the tablet whatever direction.. all the particles fall to that direction. In the manifest I locked it down to landscape view.
So then I loaded it up on a Samsung Intercept. When I moved that screen around nothing was going in the correct direction at all.. So what I did to fix the situation is
if (width<800) // My tablet width is obviously 800 phone is much less
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
else
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
this fixes my problem.. but I'm unsure if this is for all phones? My samsung intercept is only for development and it's a POS IMO. Is it the phone or is this just how it works..
Some devices have a natural orientation of portrait and some have a natural orientation of landscape. This will affect the default sensor coordinate system for the device. Take a look at this post from the Android Developers blog for more details and solutions: http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html
First of all, I would like to refer to this Issue on the google groups.
My problem is i want the landscape-native app to work in portrait mode. The way of getting the app into portrait mode is no problem at all, but when you display the app in portrait mode, my problem occurs.
When the Barcode Scanner is starting op, its camera view is (pr. default) at a +90 degree angle. When viewing the app in portrait mode the Barcode Scanner is (naturally) still at a +90 degree angle.
In the referred Issue-page there is displayed a hack to get around the problem, but this does not seem to work on most devices. This does also not work on my targeted devices.
I would like to hear if some of you have got a work around, or found the place in the source where you can 'undo' the 90 degree flipping?
A usable answer will be utmost appriciated :D Unfortunately i can't make progress in the project before this is solved. It is demanded to run in portrait mode ;)
In advance ... Thanks :)
I have implemented this in a private build. It is complicated and I can't share the details. The key steps are:
Call Camera.setDisplayOrientation() to counteract the rotation; see the Android javadoc for some discussion on that
Make sure that Camera.Parameters.setPreviewSize() is called correctly; preview sizes are reported in landscape but need to be set in portrait
(And guess what -- the default orientation of phones is considered portrait but tablets is considered landscape! Make sure you've accounted for that too.)
Finally, the preview data is always in landscape mode. You need to rotate it yourself to read it right-side-up, or otherwise account for that.