A machine control device that controls a machine performing a predetermined operation on an object, the machine control device being configured to control a relative position of the machine and the object based on an image including the object imaged by an imaging device, the machine control device comprising:
- an imaging control unit that controls a position and orientation of the imaging device, and controls the imaging device to capture two or more images including the object at two or more different imaging positions based on a control command;
- an imaging position information acquiring unit that acquires positional information of the two or more imaging positions;
- a measurement distance restoring unit that restores a measurement distance of the object as positional information of the object based on at least two images among the two or more images, distance information between at least two imaging positions corresponding to the at least two images among the two or more imaging positions, and a parameter of the imaging device by using a stereo camera method;
- an area specifying unit that specifies a partial area of the object as a specified area;
- and
- a predetermined precision position calculating unit that calculates distance information between the at least two imaging positions at which a measurement precision of the object satisfies a predetermined precision, or calculates a measurement distance of the object at which the measurement precision of the object satisfies a predetermined precision,
- wherein the machine control device controls the position and orientation of the imaging device based on the distance information between the at least two imaging positions or the measurement distance of the object calculated by the predetermined precision position calculating unit, and changes at least one of the at least two imaging positions,
- wherein the measurement precision is determined based on the at least two images, the distance information between the at least two imaging positions, and the parameter of the imaging device in the specified area, and the measurement precision defines the magnitude of a difference that occurs when the workpiece is erroneously displayed on an adjacent pixel,
- wherein the measurement distance restoring unit obtains parallax information Z for each pixel by performing area matching on the at least two images, and calculates a measurement distance H of the object by equation (1) below based on the parallax information Z for the each pixel, distance information between the at least two imaging positions D, and a focal distance f which is a parameter of the imaging device, and
- wherein the predetermined precision position calculating unit calculates a distance D′ between the at least two imaging positions at which the measurement precision of the object satisfies a predetermined precision P′ by equation (3) below based on a measurement distance H of the object and a focal distance f which is a parameter of the imaging device, or calculates a measurement distance H′ of the object at which the measurement precision of the object satisfies the predetermined precision P′ by equation (4) below based on the distance between the at least two imaging positions D and the focal distance f which is the parameter of the imaging device,
- H=D×f/Z (1),
- P′=H2/(D′×f) (3),
- P′=H′2/(D×f) (4).