An imaging device and a method for generating a motion-compensated image or video are provided. The imaging device has a data acquisition facility for acquiring image data of a target object. The imaging device is configured to acquire, using a registration facility, a posture of an inertial measurement unit and, on the basis thereof, to carry out a registration between coordinate systems of the inertial measurement unit and the image data. The imaging device is further configured to acquire motion data from the inertial measurement unit arranged on the target object and, by processing the motion data, to generate the motion-compensated image or video.