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
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
(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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With