Aiming at the problems that the traditional ORB-SLAM2 algorithm has too little keyframe information in dynamic scenes, which leads to the loss of tracking and localization, the error generated by the camera trajectory, and the constructed sparse point cloud maps can't be directly applied to navigation and path planning, an ORB-SLAM2 algorithm based on the improvement of keyframe selection is proposed. Firstly, on the basis of the original ORB-SLAM2 framework, the key frames are screened by adding the corner factor and translation transition factor of the relative motion amount between frames in the neighboring image frames, and the new feature point tracking is added to improve the accuracy of the key frame selection. Then the dense map building and OctoMap threads are added to the three threads of the original system, and the ORB-SLAM2 algorithm with improved keyframe selection is used to build a dense point cloud map and converted and compressed into OctoMaps, and finally the effectiveness of the algorithm is verified on the TUM dataset. The experimental results show that the ORB-SLAM2 algorithm with improved keyframe selection can effectively select keyframe information, the tracking and localization accuracy is significantly improved under the premise of guaranteeing the real-time performance of the system, and the maximum absolute trajectory error is reduced by 49.1% on average in different datasets, and the constructed OctoMap can be stored in a much lower amount of memory and can be used directly for the navigation planning of the robot.