Aiming at the problem that the detection of the magnetic anomaly signal is usually interfered by the geomagnetic noise, a modified OBF magnetic target detection method based on the Karhuen-Loeve expansion is proposed, after the research of the magnetic interference compensation. Firstly, the ellipsoid fitting model of the magnetic interference is built, and the compensation of the interference is realized by solving the coefficients of the fitting model. The compensation ability is about 30 nT. Then, the OBF detection algorithm is modified by the Karhuen-Loeve expansion to improve the detectivity under the colored background noise. Finally, the experimental research on the detection of magnetic targets by an unmanned aerial vehicle is carried out. The experimental results show that the modified OBF detection algorithm presents better detectivity, especially for the detection of low SNR targets, and the SNR gain is improved by about 2 dB.