Heart rate variability (HRV) is a specific quantitative indicator of autonomic nerve regulation of the heart. The research of HRV can quantify the changes of human mental state. In this paper, an improved differential threshold method was proposed for R wave detection and recognition of ECG signals. The recognition rate was improved by improving the starting position of R wave and the time window function of the traditional differential threshold method. The experimental platform in this paper is a wearable sign monitoring system constructed based on body area networks (BAN) technology. Experimental results showed that the recognition rate of R wave of real-time 5min ECG data collected by this algorithm was more than 99%. Then, analytic hierarchy Process (AHP) was used to construct the mental stress assessment model, and the weight judgment matrix was constructed according to the influence degree of HRV analysis parameters on mental stress, and the consistency check was carried out to obtain the weight value of the corresponding HRV analysis parameters. Finally, comparative experiment proved that the model can describe the mental stress of the body quantitatively.