## 2 Related Works  
Conventional research of in-bed behavior analysis includes body movement during sleep, sleep apnea, and sleeping postures. For sleeping posture recognition or behavior analysis, wearable devices [8, 9] were attached to the human body or a mattress. However, they often make the patients uncomfortable and affect sleeping quality. Another way is to install pressure sensors on the mattress for sleep monitoring [10] (such as detecting events of normal breathing, apnea, and body motion). To ensure less inconvenience or interference, image-based approaches were often developed. The RGB, depth [11], and near- or far-infrared (NIR or FIR) images [12] can be used for different purposes. Among them, thermo imaging [13] is free of privacy issues but often expensive. Depth cameras based on ToF (time of flight) principle also suffer from higher cost and cluttered noise from environmental lighting. In a compromise between the performance, cost, and privacy for elderly patients, we choose to use a RGB-D camera which is capable of capturing color and depth information (e.g., the Microsoft Kinect, Intel RealSense, etc.). Recently, machine learning (ML) approaches for disease diagnosis (e.g., [PERSON]'s [14] and ovarian cancers [15]) have gained increasing attention. They often used hand-crafted features sophisticatedly defined by a system designer or deep-learning (DL) features automatically trained from the dataset. For health care purposes, electronic health records (EHR) are also used to predict the risk of fall for the elderly using a ML approach [16]. In sleep monitoring, [PERSON] et al. [17] used a Kinect depth sensor to detect and recognize patient movements, motion patterns, and pose positions by gross body motion estimation [18] and in-bed pose analysis. Spatial and temporal features from depth image sequence were aggregated for analysis on a condition of no blanket covering on the body, which seems unreasonable for immobile and elderly patients. [PERSON] et al. [19] also used Kinect V2 depth image to form a bed-aligned map (BAM) [20] (each cell covering 10 cm \(\times\) 10 cm) and realized sleeping position classification through convolutional neural networks (CNNs). [PERSON] et al. [21] proposed to build a vertical distance map from the Kinect depth image to classify among ten sleeping postures, where a multi-stream CNN architecture considering different resolutions was used. In [21, 22], though the subjects covered with blankets were also considered, their goal was sleep quality assessment. In contrast to image-based methods, some other studies used skeleton-based algorithms for posture/action recognition. [PERSON] et al. [23] proposed to use 3D skeleton from Kinect V2 for sleep pattern monitoring. However, the subjects for the test were not covered with blankets, so that 3D skeletons could be constructed from the depth images. Recently, deep-learning algorithms were developed to estimate human skeleton (a set of articulated 3D joints) from a single RGB image [24, 25, 26, 27] to avoid the influence of inaccurate depths and for outdoor use. This kind of 2D skeleton and 3D skeleton was used in [28, 29] for fall detection and gesture recognition, respectively. In view of the prior works, Table 1 compares research on different goals for posture classification to better reflect the goal and condition considered in the proposed work. A collaboration between National Chung Cheng University (CCU) and Ditmanson Medical Foundation Chiayi Christian Hospital was conducted to use a RGB-D camera for capturing the color plus depth images and carry out recognition into three sleep postures for immobile patients. A warning message will be sent to the caregivers to remind them about repositioning the patients if they stay in unchanged postures for a long time (e.g., two hours) or lose a specified posture due to body motions. By referring to [30; 31], three lying postures are defined: supine, left, and right. Left or right side lying is performed by inserting pillows under the right or left side back.