Knowledge of optimal quantum measurements is important for a wide range of situations, including quantum communication and quantum metrology. Quantum measurements are usually optimized with an ideal experimental realization in mind. Real devices and detectors are, however, imperfect. This has to be taken into account when optimizing quantum measurements. In this paper, we derive the optimal minimum-cost and minimum-error measurements for a general model of imperfect detection.