When everything is loaded, we can iterate through the main loop delimited by the while loop. In this loop, we first query the next grabbed frame, and we then run an active appearance model fit so that we can find landmarks on the next frame. Since the current position is very important at this step, we pass it as a parameter to the pseudocode function performAAMSearch(pose,aam). If we find the current pose, which is signaled through error image convergence, we will get the next landmark
positions so we can provide them to POSIT. This happens in the following line, applyPOSIT(new2DPose, headModel, mapping), where the new 2D pose is passed as a parameter, as also our previously loaded headModel and the mapping. After that, we can render any 3D model in the obtained pose like a coordinate axis or an augmented reality model. As we have landmarks, more interesting effects can be
obtained through model parameterization, such as opening a mouth or changing eyebrow position.