@Rongzhong Li There were a couple of reasons behind that.
1. "Defining" the exact elbow joint is really hard because the shape of the contour varies a lot. Please note that I am not using any ML frameworks. It is just a clever manipulation of the image. Using pose estimation was an option, but that algorithm is computationally intensive-my i7 laptop was having a hard time running it. I couldn't make pose estimation run on a raspberry pi at all.
The algorithm works by finding the centroid of the arm's contour and its highest point. Then it measures the angle with respect to the horizontal. The centroid is the rotation joint.
2. In the picture below (source:https://www.mathplanet.com/education/geometry/perpendicular-and-parallel/angles-parallel-lines-and-transversals), angles F,B are equal.
Similarly, the angle at the elbow should be "approximately" equal to the angle at the centroid.
A work around could be to forcibly displace the location of the centroid downwards in the image (i.e. increase its y-value. Please note that determining how to change the x-value is actually really complicated). However, the results are going to remain approximately similar-no significant difference in the angles read will be observed.