C# WP7摄像机看到的角度是多少?
同一问题,适用于WP7。 似乎找不到合适的方法,我也不想让我的用户自己进行校准(如果可能的话)。C# WP7摄像机看到的角度是多少?,c#,windows-phone-7,camera,C#,Windows Phone 7,Camera,同一问题,适用于WP7。 似乎找不到合适的方法,我也不想让我的用户自己进行校准(如果可能的话)。 谢谢我不知道如何获取相机的角度,但我有一个应用程序,可以根据偏航/滚动/俯仰计算手机的倾斜 namespace PhoneUtilities.Utilities { public class AccelerometerMath { public static double RadianToDegree(double radians) {
谢谢我不知道如何获取相机的角度,但我有一个应用程序,可以根据偏航/滚动/俯仰计算手机的倾斜
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)));
}
}
}
这些计算能够得到倾斜的角度,下面是我用于一些trig计算的示例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;
}
我不知道这是否对你的相机有帮助,但我想如果你知道屏幕的尺寸,你可以根据手机的倾斜来计算角度。希望这对你有所帮助。请看这篇文章
在WP7中,没有API函数可以实现这一点,除此之外没有其他选项
- 请用户介绍(他们永远不知道)
- 列出您支持的手机列表,并为每部手机获取/测量。将其存储在应用程序中。(疯了!)
为比尔和微软公司干杯和爱。通过单独联系制造商,或通过测量每一个手机来获得。虽然与我所寻找的内容无关,但这是一个关于手机传感器的不错的博客。我相信你可能会在那里找到你想要的东西,而不是在摄像机区域。