A medical device, comprising: image pickup means that is able to pick up an image of a tube cavity in a subject; an insertion section that is insertable through the tube cavity, includes a channel formed therein through which a medical instrument is insertable, and includes an opening of the channel and the image pickup means at a distal end portion thereof; the medical instrument that can be protruded from the opening for examination or treatment in the tube cavity; virtual endoscopic image generation means configured to generate a virtual endoscopic image of the tube cavity from a plurality of different line-of-sight positions using three-dimensional image data of the tube cavity that is obtained in advance; image retrieval means configured to retrieve the virtual endoscopic image highly similar to the endoscopic image of the tube cavity in a body picked up by the image pickup means; and characterized in further comprising: reference-point setting means configured to set a reference point at the opening based on a line-of-sight position of the highly similar virtual endoscopic image; relative-position calculation means configured to calculate a relative position of the medical instrument to the reference point; movement detection means configured to detect a movement of the reference point; and position correction means configured to correct the relative position in response to the movement of the reference point detected by the movement detection means. image pickup means that is able to pick up an image of a tube cavity in a subject; an insertion section that is insertable through the tube cavity, includes a channel formed therein through which a medical instrument is insertable, and includes an opening of the channel and the image pickup means at a distal end portion thereof; the medical instrument that can be protruded from the opening for examination or treatment in the tube cavity; virtual endoscopic image generation means configured to generate a virtual endoscopic image of the tube cavity from a plurality of different line-of-sight positions using three-dimensional image data of the tube cavity that is obtained in advance; image retrieval means configured to retrieve the virtual endoscopic image highly similar to the endoscopic image of the tube cavity in a body picked up by the image pickup means; and characterized in further comprising: reference-point setting means configured to set a reference point at the opening based on a line-of-sight position of the highly similar virtual endoscopic image; relative-position calculation means configured to calculate a relative position of the medical instrument to the reference point; movement detection means configured to detect a movement of the reference point; and position correction means configured to correct the relative position in response to the movement of the reference point detected by the movement detection means. reference-point setting means configured to set a reference point at the opening based on a line-of-sight position of the highly similar virtual endoscopic image; relative-position calculation means configured to calculate a relative position of the medical instrument to the reference point; movement detection means configured to detect a movement of the reference point; and position correction means configured to correct the relative position in response to the movement of the reference point detected by the movement detection means.