Detection of optical field is a problem that has been studied during long time. Phase-shifting technique is well known as an intuitive and robust technique. I studied this phase-shifting technique in both temporal and spatial ways. I classified the errors into longitudinal one and transverse one that result from uncalibrated phase-shifter or optical misalignment, respectively. I demonstrated the feasibility to compensate these errors by use of a genetic algorithm.