The person following robot needs to detect and track the following target, then move by maintaining a safe distance from the following target, and finally complete the following task. This paper proposes a person following robot framework based on YOLOv7 and DeepSORT methods, which can realize the functions of multi-target detection and re-identification after target loss, and solve the problem of low accuracy of target following. Meanwhile, for the problem of autonomous localization and navigation of following robots in unknown environment, a strategy of real-time map building during the following process is proposed to realize autonomous localization and return after complete loss of the target. For the case that the following target is lost at the corner, this paper introduces a nonlinear regression model to achieve automatic target retrieval. In addition, by using a distributed architecture, the computational consumption on the robot side is reduced. Finally, the effectiveness of the proposed method is verified by conducting experiments in an indoor environment.