Get And Compare The Vertical Position of The Phone to The Ground

I'm making an app (a collaboration), and for this, we're using a camera with an overlay on top of it. We're hoping to use this so that the user(s) can only take a photo when it's at a specific angle. Unfortunately, I'm not sure how to get the angle.

The idea goes like this:

  1. The user calibrates the device on a flat surface using a Button.
  2. The overlay will point in the direction of where the phone should be tilted, and a capture Button will be enabled when the phone is titled at an angle between -1.5° and +1.5° of the target values (these will be read from a list).

I've tried reading the documentation for the GyroscopeSensor and the Accelerometer, but I couldn't exactly understand how I could use this in the app. For this reason, I'm reaching out to the amazing folks present on this Community.

Have a good day.

TBI

@Matthew_Bjerregaard

See here

Basic Spirit Level (read all)

If you used @Kumaraswamy's Procam extension with the above, you could have a preview, and automatically take the picture when the camera is level ....

2 Likes

Yes, I'm using exactly that one. (Great extension, by the way. Thank you @Kumaraswamy)

Thank you, but it would be better for the shot to be manually initiated.

1 Like

Ouch, I forgot the OrientationSensor even existed.
I've read the documentation, but couldn't find anything about calibrating it. Is there a method to do this? Or is it calibrated automatically on initialization?

As I believe @SteveJG suggests, you find a flat surface and calibrate it from there....

Taifun's tutorial to to trigger something if device is facing down https://puravidaapps.com/snippets.php#2accelerometer

Unfortunately the Orientation Sensor hardware is not available in higher Android devices. You need to use the Accelerometer. :cry:

1 Like

Does it work on very old phones that run Android 2/3/4? The app is meant to target rural areas that don't particularly have sophisticated technology.

It being the Orientation sensor. Yes, it should work as these devices probably have Orientation sensor hardware. :slight_smile: Why not try?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.