Using star tracker to perform space surveillance is a focal point of research in aerospace engineering. However, autonomous attitude determination with star trackers in missions is a challenging task, because of spacecraft attitude dynamics and false stars. We present a novel star pattern recognition algorithm to resolve these problems. The algorithm defines a star pattern, called a flower code, composed of angular distances and circular angles. Then, a three-step strategy is adopted to find the correspondence of the sensor pattern and the catalog pattern, including initial lookup table match, cyclic dynamic match, and validation. A number of experiments are carried out on simulated and real star images. The simulation results show that the proposed method provides improved performance, especially on robustness against false stars. Also, the results for real star images demonstrate the reliability of the method for ground-based measurements.