android - Take picture when phone is straight -
i want ask question because i've searched through google , can't seem find useful, , read this , this.
the question is, can take picture camera when phone straight using sensors in android device?
just looking advice on how it?
you should able use orientation sensor , sensorevents.
the orientation sensor lets monitor position of device relative >to earth's frame of reference (specifically, magnetic north).
the orientation sensor derives data using device's geomagnetic >field sensor in combination device's accelerometer. using these 2 >hardware sensors, orientation sensor provides data following >three dimensions:
azimuth (degrees of rotation around z axis). angle between magnetic north , device's y axis. example, if device's y axis aligned magnetic north value 0, , if device's y axis pointing south value 180. likewise, when y axis pointing east value 90 , when pointing west value 270.
pitch (degrees of rotation around x axis). value positive when positive z axis rotates toward positive y axis, , negative when positive z axis rotates toward negative y axis. range of values 180 degrees -180 degrees.
roll (degrees of rotation around y axis). value positive when positive z axis rotates toward positive x axis, , negative when positive z axis rotates toward negative x axis. range of values 90 degrees -90 degrees.
using these values should able tell when phone "straight" in position. there examples on page under "using orientation sensor" header : http://developer.android.com/guide/topics/sensors/sensors_position.html#sensors-pos-orient
also @ http://developer.android.com/reference/android/hardware/sensorevent.html shows how use sensor events
Comments
Post a Comment