A workpiece W serving as an object for detection is fixed in place. A
camera 20 is mounted to the end of a robot RB. The camera is turned about
an axis, which passes through the center position of the workpiece W and
is perpendicular to the optical axis of the camera, to take an image of
the workpiece W at a plurality of positions in different directions. A
teaching model is generated on the basis of each produced image data. The
relative position and posture of the workpiece to the camera 20 is also
stored in association with the teaching model. Thus, it is possible to
easily generate the teaching model of the workpiece regardless of
three-dimensional variations in posture.