# Design, Implementation, and Field Testing
## 4 System Implementation
### Gesture Recognition and Activity Detection  
The Activity Recognizer component in the KinectSever is used to recognize the registration gesture and to detect predefined activities, which are defined in the Configuration file encoded in the eXtensible Markup Language (XML). Both the gesture/activity description and the recognition engine follow the framework that we developed previously [10; 11; 12]. In this framework, an activity can be defined in terms of Joint Angle, Joint Distance, and Bone Orientation. The Joint Angle element defines the relative angle between two adjacent body segments represented by three joints (one joint common to both segments, and one each for the other end of the two segments). The Joint Distance element defines the distance between two joints. The Bone Orientation element defines the orientation of a body segment relative to a particular anatomical planes, such as the frontal, sagittal, or transverse plane. The class hierarchy is shown in Figure 5. The three types of elements are represented by three classes JointAngle, JointDistance, and BoneOrientation. They all implement the abstract class Configuration, which defines a single method called \"RecognizeGesture(0)\". To accommodate activities that require the use of complex configurations that use two or more configuration elements, the Gesture class is introduced, which contains the GestureComponents member variable. This member variable is used to fetch and store the list of configurations for the complex gesture/activity. The GestureRecognizer class is the front-end class for gesture/activity detection. It has two key member variables: (1) RegisterRules, which contains one or more configurations for the registration gesture; and (2) ActivityRules, which contains the list of configurations for the activities to be detected. The RegisterRules may define multiple alternative gestures such that if any of the gesture is made by the user, the user is considered registered. The GestureRecognizer is created when the system is initiated where the definitions of the gestures and activities are loaded into GestureRecognizer from the configuration file. For the registration gesture, it is detected at the single-frame level. For the back-bending activity, it is detected both on the single-frame level, and the activity level, which we will elaborate further. Figure 5: Class diagram for the Activity Recognizer. In this study, both the registration gesture and the back-bending activity are defined as BoneOrientation elements and they all use the transverse plane as the reference plane, as shown in Listing 1. For the transverse plane, we use the Kinect floor clip plane parameters. This is not only convenient, but also more reliable because it is independent from the user postures. The registration gesture is described in terms of the orientation between the left arm segment from left elbow to the left wrist and the transverse plane, which should be 0 degree relative to the axis that is perpendicular to the transverse plane, with a tolerance of 20 degrees. The back-bending activity is defined in terms of the angle between the vector that is perpendicular to the transverse plane, and the trunk vector from the hip center to the shoulder center. When a standing straight up, the angle should be close to 0. We define the minimum deviation angle of 30 degrees to declare that the user is bending her/his back too much.