To solve the problems of complex planning method, too many man-made specified parameters and huge computation in the existing gait dynamic model, the gait generation approach of humanoid robot based on the data collected by Kinect to learn human gait was proposed. Firstly, the skeleton information was collected by Kinect device, human joint local coordinate system was built by the least square fitting method. Next, the dynamic model of human body mapping robot was built, and robot joint angle trajectory was generated according to mapping relation between main joints, the studies of walking posture from human was realized. Then, Robot's ankle joint was optimized and controlled by gradient descent on the basis of Zero-Moment Point (ZMP) stability principle. Finally, on the gait stability analysis, safety factor was proposed to evaluate the stability of robot walk. The experimental results show that the safety factor of walking keeps in 0 to 0.85, experctation is 0.4825 and ZMP closes to stable regional centres, the robot realizes walking imitating human posture and gait stability, which proves the validity of the method.