Machine vision image quality is significantly affected by illumination. Uniform illumination of a rectangular target surface requires a function for evaluating the illumination system. In this study, based on an LED array light source illuminance model, such an evaluation function was established. Further, the influence of the light source’s structure on illumination was analyzed using a single-factor analysis method to determine the boundary conditions, and it was then solved using a genetic algorithm to finalize the structural design. An experimental platform was built to measure the illuminance uniformity. The experimental results were consistent with the numerical results, verifying the effectiveness and feasibility of the proposed illumination method. Thus, this research provides a theoretical reference for the illumination of a rectangular target surface for vision-based detection.