Phase shifts extraction is an important research field of phase-shifting interferometry. In this paper, based on Gram-Schmidt orthonormalization of two vectors, a novel algorithm for phase shifts extraction is proposed. This algorithm can determine the phase shifts by using only two-frame phase-shifting interferograms, as well as the phase shifts among a sequence of interferograms by a loop program. To verify the performance of the proposed algorithm, we have employed this algorithm to the simulation fringe patterns and experimental interferograms to extract the phase shifts, both of the results prove that this algorithm can obtain the phase shifts with high precision rapidly. Comparing with other algorithms, it shows that the proposed algorithm is suitable for phase shifts extraction, especially in the situation of only two-frame interferograms.