Tour Into a PictureOverviewDemos: Room, Alley, Library, Railroad, Trees, Road, Canal, ColumnsBells & WhistlesOverview
1.) Marking 3D data points3D data extraction is not yet completely automatic, so I must choose 8 control points in my image. 4 of these points are shown in the image above as the corners of the rectangle in the center outlying the "backwall" of the image. The other 4 are the points along the edge of the image where the "edges" of the room leave the scene. You can see that if chosen correctly, that the lines created between the edge points and the corresponding corners of the backwall should all converge to a single point on the horizon line. If you look carefully (disregarding the white lines in the center of the backwall), you can make out 5 quadralaterals: The backwall, the ceiling, the rightwall, the leftwall and the floor. Extracting these quadralaterals is the goal of step 2. 2.) Producing the 5 different scene imagesOk so now I have points approximating quadralaterals in the image. One of the problems here though is that if I connect the quadralaterals the way they are, I could end up cutting off a corner of the image. For example, in the image above, while examining the left wall quadralateral formed between the left points of the back wall and the blue point on the upper edge (called Pt.A) and the cyan point on the left edge (called Pt.B), connecting points A and B to complete the quadraleteral will cut off the upper left corner completely. So in order to ensure the whole image is taken, I extend the edge points along their respective lines far enough such that when the quadralaterals are formed, the entire image is accounted for.Now that I have these 5 quads, I can solve homographies for each of them to rectangles of appropriate dimensions. Then using the homographies actually warp the 5 quads to rectangles and save them as 5 seperate images. For example, the 5 images extracted for the image above are as follows:
Notice that some of the images have large black spots on them. This is because the camera did not perfectly capture a rectangle for each wall, floor or ceiling in a scene. So my algorithm extends the rectangles to all be the same "depth" and fills in the un captured parts with black. Anyway, now that we have our 5 scene images, we can construct the 3D scene! 3.) Constructing the 3D sceneUp to this point, I had used Matlab exclusively to perform all my calculations and image manipulations. This was primarily because Matlab is extremely well suited for image processing. However, now we dive into the realm of 3 Dimensions! So at this point in my implementation I switch gears and start using the 3D friendly DirectX Graphics library in C++ (and using Perl to glue the 2 together). This decision enabled me to relatively easily construct the 3D scene and move the camera in real time through the scene. It also allowed me to perform some fun tricks with scaling that you can see in the Bells & Whistles section.So the process here is theoretically simple.
ResultsI did some fun little matrix math to allow myself to control the camera very much like a character in a first-person videogame and was then able to navigate through the scene in real time to get various "Novel Views" of the image from different perspectives and angles.Example:
Make sure to check out the demos and the bells & whistles pages for some really cool images and videos! fin |