Accurate patient setup is essential in high-precision radiotherapy because deviations in delivered beam geometry may result in decreasing tumor control and increasing complications of adjacent normal tissue. At a majority of clinical facilities, radiation oncologists verify the patient setup by visual comparison in spite of it lacks reproducibility and quantitativity during the radiation treatment. Therefore, the purpose of this study was to develop an automated method for verification of patient setup based on an edge-based template matching between the digitally reconstructed radiography (DRR) and portal images for prostate cancer treatment. First, the actual center of the irradiation field in the portal image was estimated based on the template matching technique with the cross-correlation coefficient. Second, the measuring scales on the DRR and the portal image of an electronic portal imaging device were reduced, and edge portions in two images were enhanced by using a Sobel filter for an accurate template matching. Third, a pelvic template image of the DRR was produced after the registration between the DRR and portal image using an affine transform. Forth, the center of the planned irradiation field in the portal image was estimated based on the template matching technique with the cross-correlation coefficient. Finally, the patient setup error was calculated based on the displacement between the center of the actual irradiation field and planned irradiation field. We applied the proposed method to 14 cases with prostate cancer. The residual error between the patient setup errors obtained by our method and the oncologist was calculated for evaluation of the proposed method. The average residual error of the Euclidian distance was 3.15 mm. The results suggest that the proposed method may be useful for detection of the patient setup error using the DRR and portal image.