Disclosed is an electronic device that includes: a camera; a display; a memory storing one or more instructions; and a processor configured to execute the one or more instructions to obtain, by the camera, an image including at least one object, identify an object type of the at least one object, obtain spatial information corresponding to the object type, based on the object type, and control the display, to display, a virtual object, based on the spatial information.