1. An inspection apparatus for acquiring an image and subjecting the acquired image to image processing, comprising: an image processor which executes image processing on an image to be provided to template-matching using a first image processing algorithm; an erroneous recognition detector which determines whether or not a score of a matching position of the template-matching and a difference between the score of the matching position and a score of another matching position satisfy a predetermined condition; a teacher data generator, wherein the teacher data generator obtains an image using an image acquisition condition for obtaining an image having higher image quality than the image determined not to satisfy the predetermined condition when the erroneous recognition detector determines that the predetermined condition is not satisfied; an image processing optimizer which optimizes an image processing algorithm for the image to be provided to template-matching by setting the image acquired by the teacher data generator as a target image; and a switching unit which switches the first image processing algorithm of the image processor to a second image processing algorithm, wherein the second image processing algorithm is optimized by the image processing optimizer.