In SMT production line, different types of components may have the same shape but providing different functions. The only difference between these components is the text on surface of a component indicating its type. Therefore, not only geometry defect inspection but also text detection is needed in component inspection to avoid wrong use of components. Traditional algorithms based on pixel comparison of text image are time consuming and sensitive to tiny change of the text as well. A concise text detection algorithm based on color projection is proposed. The algorithm transfers two-dimensional color image to one-dimensional curve for comparison by projection of the text image, which greatly reduces the computing amount, increases speed and makes the algorithm less sensitive to displacement or rotation of the text. Experiments show that the algorithm can ensure effective real-time text detection.