In this paper, we propose a trajectory reconstruction method based on a low-cost IMU (Inertial Measurement Unit), which is usually equipped in smartphones. The IMU used in our work consists of a 3-axis accelerometer and a 3-axis gyroscope, which can record information of acceleration and rotation, respectively. However, intrinsic bias and random noise cause unreliable IMU signals. Thus, to improve the accuracy of the reconstructed trajectory, we apply filtering methods to reduce high or low frequency noises of the signal. Moreover, the machine learning technique is utilized to detect the movement state of the smartphone. Also, instead of a simple threshold to detect the smartphone movement as implemented in previous related works, we extract multiple features from IMU signals and train a movement detection model based on the linear discriminant analysis (LDA) to increase the robustness of the system. Finally, a 'reset switch' mechanism is used to more effectively restrain the accumulated error of the accelerometer.