Synopsis
Getting Things to Run
Taking the Pictures
ToDo
Creating the Panorama
Debugging
Turn in
Extra Credit
Panorama Links
In this project, you will implement a system to combine a series of photographs into a 360° panorama. Your software will automatically align the photographs (determine their overlap and relative positions) and then blend the resulting photos into a single seamless panorama. You will then be able to view the resulting panorama inside an interactive Web viewer. To start your project, you will be supplied with some test images and skeleton code you can use as the basis of your project and instructions on how to use the viewer.
Project2.exe is a command line program that requires arguments to work properly. Thus you need to run it from the command line, or from a shortcut to the executable that has the arguments specified in the "Target" field of the shortcut properties.
To run from the command line, click the Windows Start button and select "Run". Then enter "cmd" in the "Run" dialog and click "OK". A command window will pop up where you can type DOS commands. Use the DOS "cd" (change directory) command to navigate to the directory where Project2.exe is located. Then type "project2" followed by your arguments. If you do not supply any arguments, the program will print out information on what arguments it expects.
Another way to pass arguments to a program is to create a shortcut to it. To create a shortcut, right-click on the executable and drag to the location where you wish to place the shortcut. A menu will pop up when you let go of the mouse button. From the menu, select "Create Shortcut Here". Now right-click on the short-cut you've created and select "Properties". In the properties dialog select the "Shortcut" tab and add your arguments after the text in the "Target" field. Your arguments must be outside of the quotation marks and separated with spaces.
You can run the skeleton program from inside Visual Studio, just like you could with the last project. However, you will need to tell Visual Studio what arguments to pass. Here's how:
You will be checking out equipment (camera, tripod, and Kaidan head) in groups of three or four. Everyone is responsible for writing all code on their own, but only one artifact need be turned in per group. Remember to bring extra batteries with you, these cameras drain batteries.
Skip this step for the test data. Its camera parameters can be found in the sample commands in stitch2.txt, which is provided along with the skeleton code.
Camera |
resolution |
focal length |
k1 |
k2 |
Canon Powershot A10, tag CS30012716 |
480x640 |
678.21239 pixels |
-0.21001 |
0.26169 |
Canon Powershot A10, tag CS30012717 |
480x640 |
677.50487 pixels |
-0.20406 |
0.23276 |
Canon Powershot A10, tag CS30012718 |
480x640 |
676.48417 pixels |
-0.20845 |
0.25624 |
Canon Powershot A10, tag CS30012927 |
480x640 |
671.16649 pixels |
-0.19270 |
0.14168 |
Canon Powershot A10, tag CS30012928 |
480x640 |
674.82258 pixels |
-0.21528 |
0.30098 |
Canon Powershot A10, tag CS30012929 |
480x640 |
674.79106 pixels |
-0.21483 |
0.32286 |
test images |
384x512 |
595 pixels |
-0.15 |
0.0 |
(Note: If you are using the skeleton software, save your images in (TrueVision) Targa format (.tga), since this is the only format the skeleton software can currently read. Also make sure the aspect ratio of the image (width vs. height) is either 4:3 or 3:4 (480x640 will do) which is the only aspect ratio supported by the skeleton software.)
Note: The skeleton code includes an image library, ImageLib, that is fairly general and complex. It is NOT necessary for you to peek extensively into this library! We have created some notes for you here.
[TODO] Compute the inverse map to warp the image by filling in the skeleton code in the warpSphericalField routine to:
(Note: You will have to use the focal length f estimates for the half-resolution images provided above (you can either take pictures and save them in small files or save them in large files and reduce them afterwards) . If you use a different image size, do remember to scale f according to the image size.)
To do this, you will have to implement a feature-based translational motion estimation. The skeleton for this code is provided in FeatureAlign.cpp. The main routines that you will be implementing are:
int
alignPair(const FeatureSet
&f1, const FeatureSet
&f2, const vector<FeatureMatch>
&matches, MotionModel m, float
f, int nRANSAC, double RANSACthresh,
CTransform3x3& M);
int
countInliers(const FeatureSet
&f1, const FeatureSet
&f2, const vector<FeatureMatch>
&matches, MotionModel m, float
f, CTransform3x3 M, double RANSACthresh, vector<int> &inliers);
int
leastSquaresFit(const
FeatureSet &f1, const
FeatureSet &f2, const
vector<FeatureMatch> &matches, MotionModel m, float f, const vector<int>
&inliers, CTransform3x3& M);
AlignPair takes two feature sets, f1 and f2, the list of feature matches, and a motion model (described below), and estimates and inter-image transform matrix M. It is therefore similar to the evaluateMatch function in Project 1, except that now the transformation is being computed rather than evaluated. For this project, the enum MotionModel only takes on the value eTranslate, but for the next project, it will take on the value eRotate3D, and your code will have to be extended to handle this case.
AlignPair uses RANSAC (RAndom SAmpling Consensus) to pull out a minimal set of feature matches (one match for this project), estimates the corresponding motion (alignment) and then invokes countInliers to count how many of the feature matches agree with the current motion estimate. After repeated trials, the motion estimate with the largest number of inliers is used to compute a least squares estimate for the motion, which is then returned in the motion estimate M.
CountInliers is similar to evaluateMatch except that rather than computing
the average Euclidean distance, the number of matches that have a distance
below RANSACthresh is computed.
It also returns an list of inlier match ids.
LeastSquaresFit computes a least squares estimate for the translation using all of the matches previously estimated as inliers. It returns the resulting translation estimate in the last column of M.
[Note: this description should be updated once Ian
has written the skeleton code.]
[TODO] You will have to fill in the missing code in alignPair to:
[TODO] Then, resample each image to its final location and blend it with its neighbors (AccumulateBlend, NormalizeBlend). Try a simple feathering function as your weighting function (see mosaics lecture slide on "feathering") (this is a simple 1-D version of the distance map described in [Szeliski & Shum]). For extra credit, you can try other blending functions or figure out some way to compensate for exposure differences. In NormalizeBlend, remember to set the alpha channel of the resultant panorama to opaque!
[TODO] Crop the resulting image to make the left and right edges seam perfectly (BlendImages). The horizontal extent can be computed in the previous blending routine since the first image occurs at both the left and right end of the stitched sequence (draw the “cut” line halfway through this image). Use a linear warp to the mosaic to remove any vertical “drift” between the first and last image. This warp, of the form y' = y + ax, should transform the y coordinates of the mosaic such that the first image has the same y-coordinate on both the left and right end. Calculate the value of 'a' needed to perform this transformation.
You may also refer to the file
stitch2.txt provided along with the skeleton code for the appropriate command line syntax. This command-line interface allows you to debug each stage of the program independently.
You can use the test results included in the images/ folder to check whether your program is running correctly. Comparing your output to that of the sample solution is also a good way of debugging your program.
Here is a list of suggestions for extending the program for extra credit. You are encouraged to come up with your own extensions. We're always interested in seeing new, unanticipated ways to use this program!
Get started early on Project 3. There’s a lot of work to do there in one week, so it will pay off to move onto that project as soon as this one is working