1 | initial version |
Well, a few ways to do it. I think the structured light module might actually be the easiest. That will help you determine any deformations with the surface, and maybe projector distortion.
The other way would be to calibrate a camera, use the projector to display a chessboard in different positions. Undistort the image using the camera calibration, then warp the corners of the projection into an appropriately sized frame. Then treat that as the image from a theoretical camera at the projector location. I'm not sure whether you would need to reverse the distortion into the projector or not, but it shouldn't be hard to try.
2 | No.2 Revision |
Well, a few ways to do it. I think the structured light module might actually be the easiest. That will help you determine any deformations with the surface, and maybe projector distortion.
The other way would be to calibrate a camera, use the projector to display a chessboard in different positions. Undistort the image using the camera calibration, then warp the corners of the projection into an appropriately sized frame. Then treat that as the image from a theoretical camera at the projector location. I'm not sure whether you would need to reverse the distortion into the projector or not, but it shouldn't be hard to try.
EDIT:
So, thinking about this, there are actually three separate problems.
You can probably safely ignore the first unless you're trying to project on a round building or something.
For the second the procedure is as follows:
For the third, it's pretty simple.
3 | No.3 Revision |
Well, a few ways to do it. I think the structured light module might actually be the easiest. That will help you determine any deformations with the surface, and maybe projector distortion.
The other way would be to calibrate a camera, use the projector to display a chessboard in different positions. Undistort the image using the camera calibration, then warp the corners of the projection into an appropriately sized frame. Then treat that as the image from a theoretical camera at the projector location. I'm not sure whether you would need to reverse the distortion into the projector or not, but it shouldn't be hard to try.
EDIT:
So, thinking about this, there are actually three separate problems.
You can probably safely ignore the first unless you're trying to project on a round building or something.
For the second the procedure is as follows:
For the third, it's pretty simple.
EDIT #2:
How to adjust the shape of the projection to make it square.
I'm assuming you have moved the projector into the best position you can manage, and already adjusted the keystone to get it as close as possible to correct. But now you need to project some pattern in a uniform manner but the image isn't uniform.
The first step is to get your calibrated camera (since every little bit helps) and take a picture. I'm going to fake the photos in GIMP, it's quicker and you'll get the idea.
Then you need to get your tape measure and measure the projection screen. You need to do this to be sure of the aspect ratio so you can warp it as if you were facing it directly on. Measure it in the X and Y directions. Take your undistorted image and pick the corners of your screen (or surface) and warp them to a Mat of the same aspect ratio of the screen, which I'll call ScreenMat. It should be a larger resolution than your projection.
(See that? That's why you calibrate your camera and undistort first. Your lines should be straight, not bent, I think. If they aren't, you will need do a Camera Calibration for your projector lens. After this though, this comes first.)
This warp is a simple homography that you can calculate by using this function. Your inputs should be the four corner points you picked out of the image, in pixel (x,y). The destination points should be the four corners of your ScreenMat.
For the last step pick the four corners of the actual projection. You want to use as much of your projector as possible, so create a rectangle within the projected area that is the same aspect ratio as your projector. Then do the findHomography again from the actual projection corners to the new corners you pick. Then warp your images with this homography before you project them, and they should show up within the rectangle you picked.
I hope this makes sense. If anything isn't clear, just ask.