Visual slam technology is one of the key technologies for robot to explore unknown environment independently. Accurate estimation of camera pose based on visual sensor is the basis of autonomous navigation and positioning. However, most visual slam algorithms are based on static environment assumption and cannot estimate accurate camera pose in dynamic environment. In order to solve this problem, a visual SLAM algorithm for indoor dynamic environment is proposed. Firstly, some moving objects are eliminated based on the depth information of RGB-D camera, and the initial camera pose is obtained by optimizing the luminosity and depth errors, then the moving objects are further eliminated. and, the initial static background is used for pose estimation again. After several iterations, the more accurate static background and more accurate camera pose is obtained. Experimental results show that, compared with previous research results, the proposed algorithm can achieve higher pose estimation accuracy in both low dynamic indoor scenes and high dynamic indoor scenes.