Difference between revisions of "Example Overhead View"

From BoofCV
Jump to navigationJump to search
(Created page with "<center> <gallery widths=350 heights=300px> file:Example_overhead_input.jpg | Input image file:Example_overhead_output.jpg‎ | Synthetic overhead view created from input imag...")
 
m
Line 9: Line 9:


Example Code:
Example Code:
* [https://github.com/lessthanoptimal/BoofCV/blob/v0.16/examples/src/boofcv/examples/geometry/ExampleOverheadView.java ExampleOverheadView.java]
* [https://github.com/lessthanoptimal/BoofCV/blob/v0.17/examples/src/boofcv/examples/geometry/ExampleOverheadView.java ExampleOverheadView.java]


Concepts:
Concepts:
Line 35: Line 35:
MultiSpectral<ImageUInt8> imageRGB = ConvertBufferedImage.convertFromMulti(input, null,true, ImageUInt8.class);
MultiSpectral<ImageUInt8> imageRGB = ConvertBufferedImage.convertFromMulti(input, null,true, ImageUInt8.class);


StereoParameters stereoParam = BoofMiscOps.loadXML("../data/applet/road/stereo01.xml");
StereoParameters stereoParam = UtilIO.loadXML("../data/applet/road/stereo01.xml");
Se3_F64 groundToLeft = BoofMiscOps.loadXML("../data/applet/road/ground_to_left_01.xml");
Se3_F64 groundToLeft = UtilIO.loadXML("../data/applet/road/ground_to_left_01.xml");


CreateSyntheticOverheadView<MultiSpectral<ImageUInt8>> generateOverhead =
CreateSyntheticOverheadView<MultiSpectral<ImageUInt8>> generateOverhead =

Revision as of 10:24, 19 June 2014

For some tasks (e.g. autonomous driving) detecting features and understanding the scene is difficult due to perspective distortion. An overhead orthogonal view of the scene can be created if the geometry between the camera and the ground plane is known. Each pixel in the overhead image will have a known size and its location relative to the camera is also known.

Example Code:

Concepts:

  • Perspective Distortion
  • Ground plane

Relevant Applets:

Related Examples:

Example Code

/**
 * Creates a synthetic overhead view from an image using the known ground plane.  This is commonly used for navigation
 * in man-made environments, such on roads or through hallways.  Objects which are not actually on the ground plane
 * will be heavily distorted in the overhead view.
 *
 * @author Peter Abeles
 */
public class ExampleOverheadView {
	public static void main( String args[] ) {
		BufferedImage input = UtilImageIO.loadImage("../data/applet/road/left01.png");

		MultiSpectral<ImageUInt8> imageRGB = ConvertBufferedImage.convertFromMulti(input, null,true, ImageUInt8.class);

		StereoParameters stereoParam = UtilIO.loadXML("../data/applet/road/stereo01.xml");
		Se3_F64 groundToLeft = UtilIO.loadXML("../data/applet/road/ground_to_left_01.xml");

		CreateSyntheticOverheadView<MultiSpectral<ImageUInt8>> generateOverhead =
				new CreateSyntheticOverheadViewMS<ImageUInt8>(TypeInterpolate.BILINEAR,3,ImageUInt8.class);

		// size of cells in the overhead image in world units
		double cellSize = 0.05;

		// You can use this to automatically select reasonable values for the overhead image
		SelectOverheadParameters selectMapSize = new SelectOverheadParameters(cellSize,20,0.5);
		selectMapSize.process(stereoParam.left,groundToLeft);

		int overheadWidth = selectMapSize.getOverheadWidth();
		int overheadHeight = selectMapSize.getOverheadHeight();

		MultiSpectral<ImageUInt8> overheadRGB =
				new MultiSpectral<ImageUInt8>(ImageUInt8.class,overheadWidth,overheadHeight,3);
		generateOverhead.configure(stereoParam.left,groundToLeft,
				selectMapSize.getCenterX(), selectMapSize.getCenterY(), cellSize,overheadRGB.width,overheadRGB.height);

		generateOverhead.process(imageRGB, overheadRGB);

		// note that the left/right values are swapped in the overhead image.  This is an artifact of the plane's
		// 2D coordinate system having +y pointing up, while images have +y pointing down.
		BufferedImage output = ConvertBufferedImage.convertTo(overheadRGB,null,true);

		ShowImages.showWindow(input,"Input Image");
		ShowImages.showWindow(output,"Overhead Image");
	}
}