Same question as Determine angle of view of smartphone camera, applied for WP7. Can't seem to find an appropriate method, and I don't want to put my users through calibrating it themselves (if possible). Thanks
-
this is also a nice blog about the sensors in the phone. I believe that you might find what you are looking for there instead of looking in the camera area. http://developer.nokia.com/community/wiki/Qibla_Compass_for_Windows_Phone – JP Hellemons Jan 30 '14 at 14:20
2 Answers
I dont know how to get the angle of the camera, but I do have an app that will calculate the tilt of the phone based on the Yaw/Roll/Pitch.
namespace PhoneUtilities.Utilities
{
public class AccelerometerMath
{
public static double RadianToDegree(double radians)
{
return radians * (180 / Math.PI);
}
public static double Pitch(AccelerometerReading e)
{
return RadianToDegree((Math.Atan(e.Acceleration.X / Math.Sqrt(Math.Pow(e.Acceleration.Y, 2) + Math.Pow(e.Acceleration.Z, 2)))));
}
public static double Roll(AccelerometerReading e)
{
return RadianToDegree((Math.Atan(e.Acceleration.Y / Math.Sqrt(Math.Pow(e.Acceleration.X, 2) + Math.Pow(e.Acceleration.Z, 2)))));
}
public static double Yaw(AccelerometerReading e)
{
return RadianToDegree((Math.Atan(Math.Sqrt(Math.Pow(e.Acceleration.X, 2) + Math.Pow(e.Acceleration.Y, 2)) / e.Acceleration.Z)));
}
}
}
The calculations were able to get me the angle of the tilt, here is an example I use for some trig calculation Cos(angle) = adj/hyp:
private double CalcUpAdj(AccelerometerReading reading)
{
double angle = PhoneUtilities.Utilities.AccelerometerMath.Yaw(reading);
//Get the angleNeeded for calculation
double angleNeeded = Math.Abs(angle);
double adj = CalcAdj(angleNeeded);
tbAngle.Text = String.Format("{0:0.00}", angleNeeded) + (char)176;
textBlockAdj.Text = adj.ToString();
return adj;
}
private double CalcAdj(double angleNeeded)
{
double number;
if (double.TryParse(tbHyp.Text, out number))
{
double hyp = number;
double adj = Math.Cos(Math.PI * angleNeeded / 180) * hyp;
tbAngle.Text = String.Format("{0:0.00}", angleNeeded) + (char)176;
textBlockAdj.Text = adj.ToString();
return adj;
}
return 0;
}
I dont know if this will help you with your camera, but I imagine if you knew the dimensions of the screen you could calculate the angle based on the tilt of the phone. Hopefully you find this helpful.

- 3,044
- 25
- 31
Please see this post
How to find out the aperture angle of an android camera
in WP7, there is no API function to get that, and no other option than
- Ask user introduce it (they never know)
- Make a list of phones you support and obtain/measure it for each one. Store it in your app. (crazy!)
(I am doing the same kind of stuff and we invested a lot in finding automatic calibration methods, without success.)
EDIT
Cheers and love for bill and microsoft co.
-
Obtain from manufacturers by contacting them individually, or by measuring each phone – JonAlb Nov 03 '11 at 08:43