A device for automatically registering the penetration depth of an invasive instrument into an opening and the rotational orientation of an invasive instrument in an opening of a body with the aid of a length-selective and rotation-selective pattern applied to the surface of the instrument, wherein the device has a sensor embodied to surround the instrument in a ring-shaped manner. According to the invention, the sensor is embodied for registering the length-selective and rotation-selective pattern and embodied and provided for the temporary arrangement in the region of the opening for the insertion of the invasive instrument. The device according to the invention has an evaluation unit for evaluating the penetration depth and the rotational orientation of an invasive instrument on the basis of the registered selective pattern.