本文整理汇总了Java中boofcv.gui.ListDisplayPanel类的典型用法代码示例。如果您正苦于以下问题:Java ListDisplayPanel类的具体用法?Java ListDisplayPanel怎么用?Java ListDisplayPanel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListDisplayPanel类属于boofcv.gui包,在下文中一共展示了ListDisplayPanel类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: view
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static void view(File directory) {
ListDisplayPanel panel = new ListDisplayPanel();
int numCols = 20;
int numImagesPerLabel = -1;
char prevNumLabel = ' ';
for (File d : directory.listFiles((dir, name) -> !name.matches("\\..*"))) {
String label = d.getName();
BufferedImage[] bufferedImages = Arrays.stream(d.listFiles((dir, name) -> name.matches(".*\\.jpg")))
.map(f -> UtilImageIO.loadImage(f.getAbsolutePath()))
.map(bi -> resize(bi, bi.getWidth() / 3, bi.getHeight() / 3))
.collect(Collectors.toList())
.toArray(new BufferedImage[0]);
panel.addItem(new ImageGridPanel((bufferedImages.length / numCols) + 1, numCols, bufferedImages), label);
System.out.println(label + "\t" + bufferedImages.length);
if (prevNumLabel != label.charAt(0)) {
numImagesPerLabel = bufferedImages.length;
prevNumLabel = label.charAt(0);
} else if (numImagesPerLabel != bufferedImages.length) {
throw new IllegalStateException("Expected " + numImagesPerLabel + " images, but only found " + bufferedImages.length + " for " + label);
}
}
ShowImages.showWindow(panel, ViewLabelledImagesV2.class.getSimpleName(), true);
}
开发者ID:tomwhite,项目名称:set-game,代码行数:26,代码来源:ViewLabelledImagesV2.java
示例2: sharpen
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
/**
* When an image is sharpened the intensity of edges are made more extreme while flat regions remain unchanged.
*/
public static void sharpen() {
// BufferedImage buffered = UtilImageIO.loadImage("../data/applet/enhance/dull.jpg");
BufferedImage buffered = UtilImageIO.loadImage("../data/applet/enhance/dark.jpg");
ImageUInt8 gray = ConvertBufferedImage.convertFrom(buffered,(ImageUInt8)null);
ImageUInt8 adjusted = new ImageUInt8(gray.width, gray.height);
ListDisplayPanel panel = new ListDisplayPanel();
EnhanceImageOps.sharpen4(gray, adjusted);
panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-4");
EnhanceImageOps.sharpen8(gray, adjusted);
panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-8");
panel.addImage(ConvertBufferedImage.convertTo(gray,null),"Original");
panel.setPreferredSize(new Dimension(gray.width,gray.height));
ShowImages.showWindow(panel,"Sharpen");
}
开发者ID:intrack,项目名称:BoofCV-master,代码行数:24,代码来源:ExampleImageEnhancement.java
示例3: find
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
@Override
public double[] find(BufferedImage image, boolean debug) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Shape> shapes = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(3) // this is fairly critical
.edges()
.dilate()
.contours()
.polygons(0.05, 0.05)
.getExternalShapes();
int expectedWidth = 40 * 3; // 40mm
int expectedHeight = 20 * 3; // 20mm
int tolerancePct = 40;
List<Shape> filtered = GeometryUtils.filterByArea(shapes, expectedWidth, expectedHeight, tolerancePct);
List<Shape> nonOverlapping = GeometryUtils.filterNonOverlappingBoundingBoxes(filtered);
if (debug) {
System.out.println(shapes);
System.out.println(filtered);
System.out.println(nonOverlapping);
ShowImages.showWindow(panel, "Binary Operations", true);
}
return new double[] { nonOverlapping.size() % 3 }; // just return as an int mod 3
}
开发者ID:tomwhite,项目名称:set-game,代码行数:30,代码来源:FindCardNumberFeatures.java
示例4: find
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
@Override
public double[] find(BufferedImage image, boolean debug) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Shape> shapes = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(3) // this is fairly critical
.edges()
.dilate()
.contours()
.polygons(0.05, 0.05)
.getExternalShapes();
int expectedWidth = 40 * 3; // 40mm
int expectedHeight = 20 * 3; // 20mm
int tolerancePct = 40;
List<Shape> filtered = GeometryUtils.filterByArea(shapes, expectedWidth, expectedHeight, tolerancePct);
List<Shape> nonOverlapping = GeometryUtils.filterNonOverlappingBoundingBoxes(filtered);
Optional<double[]> cardShapeFeatures = nonOverlapping.stream()
.map(Shape::getPolygon)
.map(p -> new double[] { p.size(), p.isConvex() ? 1 : 0 })
.findFirst();
if (debug) {
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return cardShapeFeatures.orElse(null); // improve
}
开发者ID:tomwhite,项目名称:set-game,代码行数:33,代码来源:FindCardShapeFeatures.java
示例5: find
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
@Override
public double[] find(BufferedImage image, boolean debug) throws IOException {
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
double[] features = ImageProcessingPipeline.fromBufferedImage(image, panel)
.filterBackgroundOut()
.coupledHueSat();
if (debug) {
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return features;
}
开发者ID:tomwhite,项目名称:set-game,代码行数:12,代码来源:FindCardColourFeatures.java
示例6: run
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
private void run() throws IOException {
BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("C:\\development\\readySET\\deck\\1221.png"));
GrayU8 gray = ConvertBufferedImage.convertFrom(image,(GrayU8)null);
GrayU8 edgeImage = gray.createSameShape();
// Create a canny edge detector which will dynamically compute the threshold based on maximum edge intensity
// It has also been configured to save the trace as a graph. This is the graph created while performing
// hysteresis thresholding.
CannyEdge<GrayU8,GrayS16> canny = FactoryEdgeDetectors.canny(2,true, true, GrayU8.class, GrayS16.class);
// The edge image is actually an optional parameter. If you don't need it just pass in null
canny.process(gray,0.1f,0.3f,edgeImage);
// First get the contour created by canny
List<EdgeContour> edgeContours = canny.getContours();
// The 'edgeContours' is a tree graph that can be difficult to process. An alternative is to extract
// the contours from the binary image, which will produce a single loop for each connected cluster of pixels.
// Note that you are only interested in verticesnal contours.
List<Contour> contours = BinaryImageOps.contour(edgeImage, ConnectRule.EIGHT, null);
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(edgeImage, false, null);
BufferedImage visualCannyContour = VisualizeBinaryData.renderContours(edgeContours,null,
gray.width,gray.height,null);
BufferedImage visualEdgeContour = new BufferedImage(gray.width, gray.height,BufferedImage.TYPE_INT_RGB);
VisualizeBinaryData.render(contours, (int[]) null, visualEdgeContour);
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(visualBinary,"Binary Edges from Canny");
panel.addImage(visualCannyContour, "Canny Trace Graph");
panel.addImage(visualEdgeContour,"Contour from Canny Binary");
ShowImages.showWindow(panel,"Canny Edge", true);
}
开发者ID:tuomilabs,项目名称:readySET,代码行数:35,代码来源:Converter.java
示例7: main
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static void main( String args[] ) {
// load the input image, declare data structures, create a noisy image
Random rand = new Random(234);
String dir = new File(".").getAbsolutePath();
File file = new File("/Users/mehdibenchoufi/Downloads/Example_lena_denoise_noisy.jpg");
ImageFloat32 input = UtilImageIO.loadImage(file.getAbsolutePath(), ImageFloat32.class);
ImageFloat32 noisy = input.clone();
GImageMiscOps.addGaussian(noisy, rand, 20, 0, 255);
ImageFloat32 denoised = new ImageFloat32(input.width, input.height);
// How many levels in wavelet transform
int numLevels = 4;
// Create the noise removal algorithm
WaveletDenoiseFilter<ImageFloat32> denoiser =
FactoryImageDenoise.waveletBayes(ImageFloat32.class, numLevels, 0, 255);
// remove noise from the image
denoiser.process(noisy,denoised);
// display the results
ListDisplayPanel gui = new ListDisplayPanel();
gui.addImage(ConvertBufferedImage.convertTo(input, null),"Input");
gui.addImage(ConvertBufferedImage.convertTo(noisy,null),"Noisy");
gui.addImage(ConvertBufferedImage.convertTo(denoised,null),"Denoised");
ShowImages.showWindow(input, "With noise", true);
ShowImages.showWindow(denoised, "Without noise", true);
}
开发者ID:echopen,项目名称:PRJ-medtec_androidapp,代码行数:31,代码来源:PostProcessing.java
示例8: main
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static void main( String args[] ) {
// load the input image, declare data structures, create a noisy image
Random rand = new Random(234);
ImageFloat32 input = UtilImageIO.loadImage("../data/evaluation/standard/lena512.bmp",ImageFloat32.class);
ImageFloat32 noisy = input.clone();
GImageMiscOps.addGaussian(noisy, rand, 20, 0, 255);
ImageFloat32 denoised = new ImageFloat32(input.width,input.height);
// How many levels in wavelet transform
int numLevels = 4;
// Create the noise removal algorithm
WaveletDenoiseFilter<ImageFloat32> denoiser =
FactoryImageDenoise.waveletBayes(ImageFloat32.class,numLevels,0,255);
// remove noise from the image
denoiser.process(noisy,denoised);
// display the results
ListDisplayPanel gui = new ListDisplayPanel();
gui.addImage(ConvertBufferedImage.convertTo(input,null),"Input");
gui.addImage(ConvertBufferedImage.convertTo(noisy,null),"Noisy");
gui.addImage(ConvertBufferedImage.convertTo(denoised,null),"Denoised");
ShowImages.showWindow(gui,"Wavelet Noise Removal Example");
}
开发者ID:intrack,项目名称:BoofCV-master,代码行数:28,代码来源:ExampleWaveletDenoise.java
示例9: displayResults
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
/**
* Displays results in a window for easy comparison..
*/
private static void displayResults(BufferedImage orig,
MultiSpectral<ImageFloat32> distortedImg,
PointTransform_F32 tran,
PointTransform_F32 fullView,
PointTransform_F32 allInside,
ImageDistort<ImageFloat32> distort) {
// render the results
MultiSpectral<ImageFloat32> undistortedImg = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
distortedImg.getWidth(),distortedImg.getHeight(),distortedImg.getNumBands());
distort.setModel(new PointToPixelTransform_F32(tran));
GImageMiscOps.fill(undistortedImg, 0);
DistortImageOps.distortMS(distortedImg, undistortedImg, distort);
BufferedImage out1 = ConvertBufferedImage.convertTo(undistortedImg, null);
distort.setModel(new PointToPixelTransform_F32(fullView));
GImageMiscOps.fill(undistortedImg,0);
DistortImageOps.distortMS(distortedImg,undistortedImg,distort);
BufferedImage out2 = ConvertBufferedImage.convertTo(undistortedImg,null);
distort.setModel(new PointToPixelTransform_F32(allInside));
GImageMiscOps.fill(undistortedImg,0);
DistortImageOps.distortMS(distortedImg,undistortedImg,distort);
BufferedImage out3 = ConvertBufferedImage.convertTo(undistortedImg,null);
// display in a single window where the user can easily switch between images
ListDisplayPanel panel = new ListDisplayPanel();
panel.addItem(new ImagePanel(orig), "Original");
panel.addItem(new ImagePanel(out1), "Undistorted");
panel.addItem(new ImagePanel(out3), "Undistorted All Inside");
panel.addItem(new ImagePanel(out2), "Undistorted Full View");
ShowImages.showWindow(panel, "Removing Lens Distortion");
}
开发者ID:intrack,项目名称:BoofCV-master,代码行数:38,代码来源:ExampleRemoveLensDistortion.java
示例10: main
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static void main( String args[] ) {
BufferedImage input = UtilImageIO.loadImage(fileName);
ImageFloat32 inputF32 = ConvertBufferedImage.convertFrom(input,(ImageFloat32)null);
ImageFloat32 integral = IntegralImageOps.transform(inputF32,null);
ImageFloat32 intensity = new ImageFloat32(integral.width,integral.height);
ListDisplayPanel guiIntensity = new ListDisplayPanel();
guiIntensity.addImage(input,"Original");
guiIntensity.addImage(VisualizeImageData.grayMagnitude(inputF32,null,255),"Gray");
int skip = 0;
for( int octave = 0; octave < 4; octave++ ) {
if( skip == 0 )
skip = 1;
else
skip = skip+skip;
for( int sizeIndex = 0; sizeIndex< 4; sizeIndex++ ) {
int block = 1+skip*2*(sizeIndex+1);
int size = 3*block;
IntegralImageFeatureIntensity.hessian(integral,1,size,intensity);
float maxAbs = ImageStatistics.maxAbs(intensity);
BufferedImage b = VisualizeImageData.colorizeSign(intensity,null,maxAbs);
guiIntensity.addImage(b,String.format("Oct = %2d size %3d",octave+1,size));
}
}
ShowImages.showWindow(guiIntensity,"Feature Intensity");
}
开发者ID:intrack,项目名称:BoofCV-master,代码行数:32,代码来源:IntensityFastHessianApp.java
示例11: find
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
@Override
public double[] find(BufferedImage image, boolean debug) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Shape> shapes = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(3) // this is fairly critical
.edges()
.dilate()
.contours()
.polygons(0.05, 0.05)
.getExternalShapes();
int expectedWidth = 40 * 3; // 40mm
int expectedHeight = 20 * 3; // 20mm
int tolerancePct = 40;
List<Shape> filtered = GeometryUtils.filterByArea(shapes, expectedWidth, expectedHeight, tolerancePct);
List<Shape> nonOverlapping = GeometryUtils.filterNonOverlappingBoundingBoxes(filtered);
Optional<RectangleLength2D_F32> box = nonOverlapping.stream()
.map(Shape::getBoundingBox)
.findFirst();
double[] features = null;
if (box.isPresent()) {
Quadrilateral_F64 quad = new Quadrilateral_F64();
RectangleLength2D_F32 rect = box.get();
convert(rect, quad);
Planar<GrayF32> output = GeometryUtils.removePerspectiveDistortion(image, quad, 200, 100);
BufferedImage shape = ConvertBufferedImage.convertTo_F32(output, null, true);
if (debug) {
panel.addImage(shape, "Shape");
}
ImageProcessingPipeline.ContourPolygonsProcessor edgeProcessor = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.edges()
.contours()
.polygons(0.01, 0.01);
ImageProcessingPipeline.ContourPolygonsProcessor binaryProcessor = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.binarize(0, 255, true)
.contours()
.polygons(0.01, 0.01);
GrayU8 finalImage = ImageProcessingPipeline.fromBufferedImage(shape, panel)
.gray()
.sharpen()
.binarize(0, 255, true)
.extract(100 - 25, 50 - 12, 50, 25)
.getImage();
double meanPixelValue = ImageStatistics.mean(finalImage);
features = new double[] { meanPixelValue };
}
if (debug) {
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return features;
}
开发者ID:tomwhite,项目名称:set-game,代码行数:64,代码来源:FindCardShadingFeatures.java
示例12: detect
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public List<CardImage> detect(BufferedImage image, String filename, boolean debug, boolean allowRotated, int expectedRows, int expectedColumns) throws IOException {
// Based on code from http://boofcv.org/index.php?title=Example_Binary_Image
String imageInfo = filename == null ? image.toString() : filename;
if (!allowRotated && image.getWidth() > image.getHeight()) {
throw new IllegalArgumentException("Image height must be greater than width: " + imageInfo);
}
int medianBlur = this.medianBlur != -1 ? this.medianBlur : Math.max(image.getHeight(), image.getWidth()) / 200; // heuristic
ListDisplayPanel panel = debug ? new ListDisplayPanel() : null;
List<Quadrilateral_F64> quads = ImageProcessingPipeline.fromBufferedImage(image, panel)
.gray()
.medianBlur(medianBlur)
.binarize(0, 255)
.erode()
.dilate()
.contours()
.polygons(0.05, 0.1)
.getExternalQuadrilaterals();
// Only include shapes that are within given percentage of the mean area. This filters out image artifacts that
// happen to be quadrilaterals that are not cards (since they are usually a different size).
List<Quadrilateral_F64> cards = GeometryUtils.filterByArea(quads, areaTolerancePct);
List<List<Quadrilateral_F64>> rows = GeometryUtils.sortRowWise(cards);// sort into a stable order
if (expectedRows != -1 && rows.size() != expectedRows) {
throw new IllegalArgumentException(String.format("Expected %s rows, but detected %s: %s", expectedRows, rows.size(), imageInfo));
}
if (expectedColumns != -1) {
rows.forEach(row -> {
if (row.size() != expectedColumns) {
throw new IllegalArgumentException(String.format("Expected %s columns, but detected %s: %s", expectedColumns, row.size(), imageInfo));
}
});
}
List<CardImage> cardImages = rows.stream()
.flatMap(List::stream)
.map(q -> {
// Remove perspective distortion
Planar<GrayF32> output = GeometryUtils.removePerspectiveDistortion(image, q, 57 * 3, 89 * 3); // actual cards measure 57 mm x 89 mm
BufferedImage im = ConvertBufferedImage.convertTo_F32(output, null, true);
return new CardImage(im, q);
}
).collect(Collectors.toList());
if (debug) {
int i = 1;
for (CardImage card : cardImages) {
panel.addImage(card.getImage(), "Card " + i++);
}
ShowImages.showWindow(panel, getClass().getSimpleName(), true);
}
return cardImages;
}
开发者ID:tomwhite,项目名称:set-game,代码行数:58,代码来源:CardDetector.java
示例13: ImageProcessingPipeline
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
private ImageProcessingPipeline(BufferedImage original, ListDisplayPanel panel) {
this.panel = panel;
addImageToPanel(original, "Original");
}
开发者ID:tomwhite,项目名称:set-game,代码行数:5,代码来源:ImageProcessingPipeline.java
示例14: fromBufferedImage
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static BufferedImageProcessor fromBufferedImage(BufferedImage original, ListDisplayPanel panel) {
return new ImageProcessingPipeline(original, panel).new BufferedImageProcessor(original);
}
开发者ID:tomwhite,项目名称:set-game,代码行数:4,代码来源:ImageProcessingPipeline.java
示例15: ModelBuilderGUI
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public ModelBuilderGUI() {
listPanel = new ListDisplayPanel();
}
开发者ID:ftomassetti,项目名称:SketchModel,代码行数:4,代码来源:ModelBuilderGUI.java
示例16: ModelBuilderConsole
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public ModelBuilderConsole() {
listPanel = new ListDisplayPanel();
}
开发者ID:ftomassetti,项目名称:SketchModel,代码行数:4,代码来源:ModelBuilderConsole.java
示例17: main
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
/**
* The main method.
*
* @param args the arguments
*/
public static void main( String args[] ) {
// load and convert the image into a usable format
BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("/home/pete/development/gitrepo/iote2e/iote2e-tests/images/iote2e-test.png"));
// convert into a usable format
GrayF32 input = ConvertBufferedImage.convertFromSingle(image, null, GrayF32.class);
GrayU8 binary = new GrayU8(input.width,input.height);
GrayS32 label = new GrayS32(input.width,input.height);
// Select a global threshold using Otsu's method.
double threshold = GThresholdImageOps.computeOtsu(input, 0, 255);
// Apply the threshold to create a binary image
ThresholdImageOps.threshold(input,binary,(float)threshold,true);
// remove small blobs through erosion and dilation
// The null in the input indicates that it should internally declare the work image it needs
// this is less efficient, but easier to code.
GrayU8 filtered = BinaryImageOps.erode8(binary, 1, null);
filtered = BinaryImageOps.dilate8(filtered, 1, null);
// Detect blobs inside the image using an 8-connect rule
List<Contour> contours = BinaryImageOps.contour(filtered, ConnectRule.EIGHT, label);
// colors of contours
int colorExternal = 0xFFFFFF;
int colorInternal = 0xFF2020;
// display the results
BufferedImage visualBinary = VisualizeBinaryData.renderBinary(binary, false, null);
BufferedImage visualFiltered = VisualizeBinaryData.renderBinary(filtered, false, null);
BufferedImage visualLabel = VisualizeBinaryData.renderLabeledBG(label, contours.size(), null);
BufferedImage visualContour = VisualizeBinaryData.renderContours(contours, colorExternal, colorInternal,
input.width, input.height, null);
ListDisplayPanel panel = new ListDisplayPanel();
panel.addImage(visualBinary, "Binary Original");
panel.addImage(visualFiltered, "Binary Filtered");
panel.addImage(visualLabel, "Labeled Blobs");
panel.addImage(visualContour, "Contours");
ShowImages.showWindow(panel,"Binary Operations",true);
}
开发者ID:petezybrick,项目名称:iote2e,代码行数:48,代码来源:ExampleBinaryOps.java
示例18: main
import boofcv.gui.ListDisplayPanel; //导入依赖的package包/类
public static void main( String args[] ) {
String dir = "../data/applet/calibration/stereo/Bumblebee2_Chess/";
StereoParameters param = BoofMiscOps.loadXML(dir+"stereo.xml");
// load images
BufferedImage origLeft = UtilImageIO.loadImage(dir+"left05.jpg");
BufferedImage origRight = UtilImageIO.loadImage(dir+"right05.jpg");
// distorted images
MultiSpectral<ImageFloat32> distLeft = ConvertBufferedImage.convertFromMulti(origLeft, null, ImageFloat32.class);
MultiSpectral<ImageFloat32> distRight = ConvertBufferedImage.convertFromMulti(origRight, null, ImageFloat32.class);
ConvertBufferedImage.orderBandsIntoRGB(distLeft,origLeft);
ConvertBufferedImage.orderBandsIntoRGB(distRight,origRight);
// storage for undistorted + rectified images
MultiSpectral<ImageFloat32> rectLeft = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
distLeft.getWidth(),distLeft.getHeight(),distLeft.getNumBands());
MultiSpectral<ImageFloat32> rectRight = new MultiSpectral<ImageFloat32>(ImageFloat32.class,
distRight.getWidth(),distRight.getHeight(),distRight.getNumBands());
// Compute rectification
RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated();
Se3_F64 leftToRight = param.getRightToLeft().invert(null);
// original camera calibration matrices
DenseMatrix64F K1 = PerspectiveOps.calibrationMatrix(param.getLeft(), null);
DenseMatrix64F K2 = PerspectiveOps.calibrationMatrix(param.getRight(), null);
rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight);
// rectification matrix for each image
DenseMatrix64F rect1 = rectifyAlg.getRect1();
DenseMatrix64F rect2 = rectifyAlg.getRect2();
// New calibration matrix,
// Both cameras have the same one after rectification.
DenseMatrix64F rectK = rectifyAlg.getCalibrationMatrix();
// Adjust the rectification to make the view area more useful
RectifyImageOps.fullViewLeft(param.left, rect1, rect2, rectK);
// RectifyImageOps.allInsideLeft(param.left, leftHanded, rect1, rect2, rectK);
// undistorted and rectify images
ImageDistort<ImageFloat32> imageDistortLeft =
RectifyImageOps.rectifyImage(param.getLeft(), rect1, ImageFloat32.class);
ImageDistort<ImageFloat32> imageDistortRight =
RectifyImageOps.rectifyImage(param.getRight(), rect2, ImageFloat32.class);
DistortImageOps.distortMS(distLeft, rectLeft, imageDistortLeft);
DistortImageOps.distortMS(distRight, rectRight, imageDistortRight);
// convert for output
BufferedImage outLeft = ConvertBufferedImage.convertTo(rectLeft,null);
BufferedImage outRight = ConvertBufferedImage.convertTo(rectRight, null);
// show results and draw a horizontal line where the user clicks to see rectification easier
ListDisplayPanel panel = new ListDisplayPanel();
panel.addItem(new RectifiedPairPanel(true, origLeft, origRight), "Original");
panel.addItem(new RectifiedPairPanel(true, outLeft, outRight), "Rectified");
ShowImages.showWindow(panel,"Stereo Rectification Calibrated");
}
开发者ID:intrack,项目名称:BoofCV-master,代码行数:63,代码来源:ExampleRectifyCalibratedStereo.java
注:本文中的boofcv.gui.ListDisplayPanel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论