Hi,
After a bit of testing withRecognitionImpl.estimateAngleToObject() in land-scape mode, I realized that it only outputs the angle relative to the X axis, this works perfectly in portrait mode but when the phone is flipped the X axis gets flipped with the Y axis, this of-course will always return the same angle along the X axis.
It could be a problem with my phones Gyro-scope but in-case:
I think the most efficient would be to offset the X axis by 90 degrees when it's flipped.
I did a bit of digging and tried to fix it myself,
-the code below works when the phone is in land-scape mode
-the code below is hard-coded, it doesn't flip the axis it just works according to the Y axis.
public double calcAngle(Recognition recognition,AngleUnit angleUnit) {
//get vertical focal length
double adjacentSideLength = vuforia.getCameraCalibration().getFocalLength().getData()[1;
//calculate the distance from the vertical center line
//NOTE: getTop() and getBottom() are used here since top and bottom
// in portrait mode are actually left and right in landScape mode
double oppositeSideLength = (recognition.getTop()+recognition.getBottom())*0.5f
- 0.5f * recognition.getImageHeight();
//calculate the angle
double tangent = oppositeSideLength / adjacentSideLength;
double angle = angleUnit.fromRadians(Math.atan(tangent));
return angle;
}
Hi, After a bit of testing with
RecognitionImpl.estimateAngleToObject()
in land-scape mode, I realized that it only outputs the angle relative to the X axis, this works perfectly in portrait mode but when the phone is flipped the X axis gets flipped with the Y axis, this of-course will always return the same angle along the X axis.It could be a problem with my phones Gyro-scope but in-case:
I think the most efficient would be to offset the X axis by 90 degrees when it's flipped. I did a bit of digging and tried to fix it myself, -the code below works when the phone is in land-scape mode -the code below is hard-coded, it doesn't flip the axis it just works according to the Y axis.