To deal with the problem of complex computation and poor real-time performance of mobile robot simultaneous localization and 3D dense mapping, a real-time SLAM algorithm is proposed based on RGB-D data. Firstly, the FAST feature points in RGB image are extracted. The 3D position of the feature points is calculated. Then, the direct method is used to minimize the photometric error to estimate the pose transform of the camera. The key frames are extracted according to the size of the pose transform. Finally, to reduce the accumulated error occurred during the movement of mobile robot, a closed-loop detection method based on the bag-of-words model is proposed. The g2o framework is adopted to optimize the pose graph. Experimental results show that the proposed algorithm can effectively improve the real-time performance of SLAM system and build a dense three-dimensional environment map. © 2018, Science Press. All right reserved.