Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gs-cv: Add test program for MeshgridRadon
- Loading branch information
1 parent
e1fc180
commit e9c038d
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
gs-cv/src/main/java/org/genericsystem/cv/application/MeshgridRadonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.genericsystem.cv.application; | ||
|
||
import org.genericsystem.cv.AbstractApp; | ||
import org.genericsystem.cv.Img; | ||
import org.genericsystem.cv.utils.NativeLibraryLoader; | ||
import org.opencv.core.Scalar; | ||
import org.opencv.imgcodecs.Imgcodecs; | ||
|
||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.layout.GridPane; | ||
|
||
public class MeshgridRadonTest extends AbstractApp { | ||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
|
||
static { | ||
NativeLibraryLoader.load(); | ||
} | ||
private Img image = new Img(Imgcodecs.imread("1_in.png"), false); | ||
private int cols = 3; | ||
private int rows = 2; | ||
|
||
@Override | ||
protected void fillGrid(GridPane mainGrid) { | ||
Image[] images = new Image[6]; | ||
images[0] = image.toJfxImage(); | ||
|
||
MeshGridRadon meshGrid = new MeshGridRadon(20, 40, 40, image.getSrc()); | ||
meshGrid.build(-5000, -45, 45); | ||
try (Img vertDirs = new Img(meshGrid.drawVerticalDirs(new Scalar(255, 0, 255)), false); | ||
Img baseLines = new Img(meshGrid.drawBaselines(new Scalar(255, 0, 0)), false); | ||
Img grid = new Img(meshGrid.drawOnCopy(new Scalar(0, 0, 255)), false); | ||
Img surface = new Img(meshGrid.draw3Dsurface(new Scalar(0, 255, 0), new Scalar(0, 0, 255)), false); | ||
Img dewarped = new Img(meshGrid.dewarp(), false)) { | ||
images[1] = baseLines.toJfxImage(); | ||
images[2] = vertDirs.toJfxImage(); | ||
images[3] = grid.toJfxImage(); | ||
images[4] = surface.toJfxImage(); | ||
images[5] = dewarped.toJfxImage(); | ||
for (int col = 0; col < cols; col++) | ||
for (int row = 0; row < rows; row++) { | ||
int i = row * cols + col; | ||
if (i < images.length) { | ||
ImageView imageView = new ImageView(images[i]); | ||
mainGrid.add(imageView, col, row); | ||
imageView.setPreserveRatio(true); | ||
imageView.setFitWidth(image.width()); | ||
imageView.setFitHeight(image.height()); | ||
} | ||
} | ||
} | ||
} | ||
} |