Photodynamic therapy (PDT) is one of the best available treatment for dermatology, especially for port wine stains (PWS), in which the efficacy is associated with the light dose, the photosensitizer concentration, the oxygen concentration and so on. Accurate control of the light dose will help doctors develop more effective treatment protocols, and reduce the treatment cost. Considering the characters of PWS, a binocular vision system composed of a camera, a digital projector and a computing unit is designed. An accurate 3D modeling of patients was achieved using a gray coding structured light, and then the lesions were segmented based on HSV space. Subsequently, each 3D point is fit on the surface by a nearest neighbor algorithm and the surface normal can be obtained. Three dimensional localization of lesion provide digital objective basis for automatic control of light device. The irradiance on the surface at a given angle can be assessed, and the optimum angle for the treatment can be solved and optimized by the doctor to improve irradiation areas.