Computer Vision and Projection Mapping in Python

Pages
Contributors: Member #914806
Favorited Favorite 2

Correct for Off Axis Viewing

Now that we have found the contours of our project-able region, we can work on de-skewing the image, or calculating and applying the perspective transform we need to take this trapezoidal region and making it square. This artifacting is introduced by the fact that we cannot have the camera and projector directly on axis with each other. We need to do this correction so that we can accurately place the image sprites in the real world.

The code to do this now that we have all our information is fairly straightforward.

frame = warpPerspective(frame, m, (maxWidth, maxHeight))

This accomplishes our de-skew, and crops our image to the region in question. Another way to think of what this does is that it gives us back only the part of our image that is our project-able region. Everything else is discarded. This is important because we will need to look for faces within this region, and now that the region is square (not trapezoidal) we can start to calculate where our sprites need to go.