1:8 Y.Yin et al. 0 m m (a)Writing with left hand (b)Writing with right hand Fig.6.Viewing angles for writing with different hands Here,the hand (i.e.,left hand or right hand)and the writing directions,i.e.,in front, left side,right side or below,determine the viewing angles.To detect which hand writes in the air,we introduce an initial gesture before writing,i.e.,the user stands with the hands down and then opens up the arm wearing the device until the arm is parallel to the floor.In the human coordinate system,if the hand moves left,then the user writes with left hand. Otherwise,the user writes with right hand.In regard to the human coordinate system,it will be described in the later System Design section.To detect the writing direction and project the 3D contour into a 2D plane properly,we introduce the 3D contour-based gesture model,as described below. 4 3D CONTOUR-BASED GESTURE MODEL Based on the accelerometer,gyroscope and magnetometer of the wrist-worn device,we can get the 3D contour of the in-air gesture.However,according to Section 3.2,due to the uncertainty of the viewing angle,writing direction and contour distribution,it is essential to find a plane to get the proper projection of 3D contour for character recognition.To solve this issue,we first introduce Principal Component Analysis(PCA)to adaptively detect the principal/writing plane.Then,we detect the reference coordinate plane and determine the viewing angle.After that,we tune the 2D contour in the principal plane to get the character contour in right orientation and normalized size. 4.1 Principal Plane Detection with PCA As mentioned before,to get a proper projected 2D contour for character recognition,we need to detect the principal/writing plane,which contains or is close to most of points in the 3D contour,as the red plane in Fig.7(a),Fig.7(b)and Fig.7(c).It is worth noting that the principal plane may be not parallel to any coordinate plane,as shown in Fig.7.In this paper,we utilize Principal Component Analysis(PCA)[30]to reduce the dimensionality of 3D contour and detect the principal plane adaptively,as described below. For convenience,we usei=(,,)T,i[1,n]to represent the contour (i.e.,point sequence)in Th-aris,yh-axis and zh-aris of human coordinate system.At first,we introduce the centralization operation to update the coordinates i of the contour,i.e., 1=x1-是∑=1,2=2-是∑-12,3=x8-是∑=1a.Then,euse wi=(wi,wi2,wis),iE[1,2]to represent the orthonormal basis vectors of the principal plane.Here,lwill2 =1,wwj=0,ij. As shown in Fig.8,for the point ci in human-frame,its projection point in the principal plane is y;=(vi,)T=i,where =(w1,w2).Then,we can use y;to reconstruct the ACM Trans.Sensor Netw.,Vol.1,No.1,Article 1.Publication date:January 2019.1:8 Y. Yin et al. -yh zh xh zh xh yh zh xh yh zh xh yh (a) Writing with left hand -yh zh xh zh xh yh zh xh yh zh xh zh (b) Writing with right hand Fig. 6. Viewing angles for writing with different hands Here, the hand (i.e., left hand or right hand) and the writing directions, i.e., in front, left side, right side or below, determine the viewing angles. To detect which hand writes in the air, we introduce an initial gesture before writing, i.e., the user stands with the hands down and then opens up the arm wearing the device until the arm is parallel to the floor. In the human coordinate system, if the hand moves left, then the user writes with left hand. Otherwise, the user writes with right hand. In regard to the human coordinate system, it will be described in the later System Design section. To detect the writing direction and project the 3D contour into a 2D plane properly, we introduce the 3D contour-based gesture model, as described below. 4 3D CONTOUR-BASED GESTURE MODEL Based on the accelerometer, gyroscope and magnetometer of the wrist-worn device, we can get the 3D contour of the in-air gesture. However, according to Section 3.2, due to the uncertainty of the viewing angle, writing direction and contour distribution, it is essential to find a plane to get the proper projection of 3D contour for character recognition. To solve this issue, we first introduce Principal Component Analysis (PCA) to adaptively detect the principal/writing plane. Then, we detect the reference coordinate plane and determine the viewing angle. After that, we tune the 2D contour in the principal plane to get the character contour in right orientation and normalized size. 4.1 Principal Plane Detection with PCA As mentioned before, to get a proper projected 2D contour for character recognition, we need to detect the principal/writing plane, which contains or is close to most of points in the 3D contour, as the red plane in Fig. 7(a), Fig. 7(b) and Fig. 7(c). It is worth noting that the principal plane may be not parallel to any coordinate plane, as shown in Fig. 7. In this paper, we utilize Principal Component Analysis (PCA) [30] to reduce the dimensionality of 3D contour and detect the principal plane adaptively, as described below. For convenience, we use 𝑥𝑖 = (𝑥𝑖1, 𝑥𝑖2, 𝑥𝑖3) 𝑇 , 𝑖 ∈ [1, 𝑛] to represent the contour (i.e., point sequence) in 𝑥ℎ − 𝑎𝑥𝑖𝑠, 𝑦ℎ − 𝑎𝑥𝑖𝑠 and 𝑧ℎ − 𝑎𝑥𝑖𝑠 of human coordinate system. At first, we introduce the centralization operation to update the coordinates 𝑥𝑖 of the contour, i.e., 𝑥𝑖1 = 𝑥𝑖1 − 1 𝑛 ∑︀𝑛 𝑗=1 𝑥𝑗1, 𝑥𝑖2 = 𝑥𝑖2 − 1 𝑛 ∑︀𝑛 𝑗=1 𝑥𝑗2, 𝑥𝑖3 = 𝑥𝑖3 − 1 𝑛 ∑︀𝑛 𝑗=1 𝑥𝑗3. Then, we use 𝜔𝑖 = (𝜔𝑖1, 𝜔𝑖2, 𝜔𝑖3) 𝑇 , 𝑖 ∈ [1, 2] to represent the orthonormal basis vectors of the principal plane. Here, ‖𝜔𝑖‖2 = 1, 𝜔 𝑇 𝑖 𝜔𝑗 = 0, 𝑖 ̸= 𝑗. As shown in Fig. 8, for the point 𝑥𝑖 in human-frame, its projection point in the principal plane is 𝑦𝑖 = (𝑦𝑖1, 𝑦𝑖2) 𝑇 = Ω 𝑇 𝑥𝑖 , where Ω = (𝜔1, 𝜔2). Then, we can use 𝑦𝑖 to reconstruct the ACM Trans. Sensor Netw., Vol. 1, No. 1, Article 1. Publication date: January 2019