Orientation based on vanishing points
In one implementation, a method of determining a downward direction is performed by a device including one or more processors, non-transitory memory, and an image sensor. The method includes capturing, using the image sensor, an image of a physical environment. The method includes detecting a plurality of lines within the image of the physical environment. The method includes determining one or more vanishing directions based on the plurality of lines. The method includes defining a downward direction based on the one or more vanishing directions.
1 . A method comprising:
at a device including one or more processors, non-transitory memory, and an image sensor:
capturing, using the image sensor, a first image of a physical environment;
detecting a first plurality of lines within the first image of the physical environment;
determining one or more vanishing directions based on the first plurality of lines;
defining a downward direction based on the one or more vanishing directions;
capturing, using the image sensor, a second image of the physical environment;
detecting a second plurality of lines within the second image;
determining an updated one or more vanishing directions based on the second plurality of lines; and
updating the downward direction based on the updated one or more vanishing directions.
2 . The method of claim 1 , wherein determining the one or more vanishing directions includes determining a first vanishing point and determining a first vanishing direction based on the first vanishing point.
3 . The method of claim 2 , wherein determining the first vanishing point is based on a random sample consensus (RANSAC) algorithm defining a first subset of the first plurality of lines.
4 . The method of claim 3 , wherein determining the one or more vanishing directions includes determining a second vanishing direction based on a second vanishing point determined based on a RANSAC algorithm excluding the first subset of the first plurality of lines.
5 . The method of claim 4 , wherein determining the one or more vanishing directions includes determining a second vanishing direction based on a voting algorithm.
6 . The method of claim 4 , wherein determining the one or more vanishing directions includes determining a third direction based on a cross-product of the first vanishing direction and the second vanishing direction.
7 . The method of claim 1 , wherein determining the one or more vanishing directions includes determining a first vanishing direction, a second vanishing direction, and a third direction based on a three-line RANSAC algorithm.
8 . The method of claim 7 , further comprising selecting the third direction as the downward direction.
9 . The method of claim 7 , further comprising selecting the first vanishing direction, the second vanishing direction, or the third direction as the downward direction based on a vector from an inertial measurement unit.
10 . The method of claim 1 , further comprising displaying virtual content based on the downward direction.
11 . The method of claim 10 , wherein displaying the virtual content based on the downward direction includes displaying a virtual object aligned with the downward direction.
12 . The method of claim 10 , wherein displaying the virtual content based on the downward direction includes displaying a virtual object moving along the downward direction.
13 . The method of claim 1 , further comprising updating display of virtual content based on the updated downward direction.
14 . A device comprising:
an image sensor;
non-transitory memory; and
one or more processors to:
capture, using the image sensor, a first image of a physical environment;
detect a first plurality of lines within the first image of the physical environment;
determine one or more vanishing directions based on the first plurality of lines;
define a downward direction based on the one or more vanishing directions;
capture, using the image sensor, a second image of the physical environment;
detect a second plurality of lines within the second image;
determine an updated one or more vanishing directions based on the second plurality of lines; and
update the downward direction based on the updated one or more vanishing directions.
15 . The device of claim 14 , wherein the one or more processors are to determine the one or more vanishing directions by:
determining a first vanishing direction based on a first vanishing point;
determining a second vanishing direction based on a second vanishing point; and
determining a third direction based on a cross-product of the first vanishing direction and the second vanishing direction.
16 . The device of claim 14 , wherein the one or more processors are further to display virtual content based on the downward direction.
17 . The device of claim 16 , wherein the one or more processors are to display the virtual content based on the downward direction by displaying a virtual object aligned with the downward direction.
18 . The device of claim 16 , wherein the one or more processors are to display the virtual content based on the downward direction by displaying a virtual object moving along the downward direction.
19 . A non-transitory memory storing one or more programs, which, when executed by one or more processors of a device including an image sensor, cause the device to:
capture, using the image sensor, a first image of a physical environment;
detect a first plurality of lines within the first image of the physical environment;
determine one or more vanishing directions based on the first plurality of lines;
define a downward direction based on the one or more vanishing directions;
capture, using the image sensor, a second image of the physical environment;
detect a second plurality of lines within the second image;
determine an updated one or more vanishing directions based on the second plurality of lines; and
update the downward direction based on the updated one or more vanishing directions.