## 2 Proposed System
### Posture and Action Recognition
We adopted the CNN over SVM as the learning mechanism for its better recognition rate for this application [25; 26]. Finally, the posture sequence \(R=[A,B,C,D,E]\) was generated to serve as a standard MTA. To judge whether the patient had actually taken the medicine, the corresponding time sequence was first recorded and processed to become posture sequence \(O=[o_{1},\,\ldots,\,o_{m}]\) of \(m\) samples. They were then forwarded to the CNN to determine which sub-action among \(\{A,B,C,D,E\}\) a given \(o_{i}\) should belong to. Because \(R\) and \(O_{l}\) (\(O\) with postures labeled) might not be the same length due to different motion speeds, the method of dynamic time warps was utilized to evaluate their similarity [19]. An \(m\times 5\) matrix \(M\) was then generated, expressed as  
\[M_{m\times 5}= \begin{bmatrix}M(1,1)&\cdots&\cdots&M(1,5)\\ \vdots&M(i-1,j-1)&M(i-1,j)&\vdots\\ \vdots&M(i,j-1)&M(i,j)&\vdots\\ M(m,1)&\cdots&\cdots&M(m,5)\end{bmatrix}  \tag{4}\]  
where \(M(i,j)\) is the so-called dynamic time warping distance when the \(i\) posture of \(O_{l}\) is aligned with the \(j\) posture of \(R\), derived using an optimal alignment scheme in the algorithm of dynamic time warping [19] so that the similarity can be evaluated for \(R\) and \(O_{l}\), even when their timing is different. When the derived similarity measurement value from the process falls below an empirically selected threshold, they are deemed to be similar. Based on the discussions above, the algorithm developed for medicine-taking detection is organized as follows:  
Algorithm for medicine-taking detection to determine whether the patient has taken the medicine from the measured time sequence of his/her arm motion:  
1. Input the patient's time sequence of medicine taken, measured via the depth camera, and process it to become the posture sequence \(O\). Classify the postures into corresponding sub-actions A\(\sim\)E via the CNN and rename \(O\) to be \(O_{l}\). * Obtain the standard posture sequence \(R\) to serve as the reference for comparison from a number of demonstrations of successful medicine taking. * Generate Matrix \(M\) for similarity evaluation between \(R\) and \(O_{l}\). Derive the dynamic time warping distance for its elements \(M\)(_i,j_) for similarity measurement. * If the value of the similarity measurement in Step 3 is smaller (larger) than a preset threshold, the patient is judged to have (not) taken the medicine. In response to non-compliant patients, the robot follows a series of steps. Initially, the robot utilizes an integrated speaker system to repeatedly play voice prompts, encouraging patient cooperation. If the patient continues to be unresponsive, the robot will automatically send a notification to the nursing station, alerting healthcare professionals. To further manage the situation, nurses can engage in real-time communication with the patient using a microphone. Additionally, the system allows nurses to remotely control the robot through a WiFi connection. During manual operation, the robot's camera streams visual content in real-time to the nurse's interface. When the robot is unable to complete the assigned task, it sends an error message to the nursing station, requesting remote control intervention by personnel.