The algorithm works like this. A video capture is initialized through VideoCapture cap(0), so that the default webcam is used. Now that we have video capture working, we also need to load our trained active appearance model, which will occurs in the pseudocode loadPreviouslyTrainedAAM mapping. We also load the 3D head model for POSIT and the mapping of landmark points to 3D head points in our mapping variable.