An electronic device is provided. The electronic device includes a plurality of
distance sensors, an inertial sensor, a camera, a display, memory storing one or more computer programs, and a processor operatively connected to the plurality of
distance sensors, the inertial sensor, the
camera module, the display module, and the memory, wherein the one or more computer programs include computer-
executable instructions that, when executed by processor, cause the electronic device to: identify, using the inertial sensor, whether a user wearing the electronic device on their head is walking, detect, in response to the user walking, a
head rotation amount of the user using the inertial sensor, obtain a plurality of images through the camera on the basis of satisfying a
head rotation condition based on the
head rotation amount, measure an angle between a movement direction of the user and a
gaze direction of the user on the basis of the plurality of images that are obtained, and activate among the plurality of
distance sensors, at least one first distance sensor corresponding to the movement direction, when the measured angle exceeds a threshold.