small changes in ordering
This commit is contained in:
@@ -2,20 +2,11 @@ package de.unidue.nes.gpu.testframework;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.input.MatArrayInput;
|
||||
import de.unidue.nes.gpu.testframework.opencv.DescriptorMatcher;
|
||||
import de.unidue.nes.gpu.testframework.opencv.Features2d;
|
||||
import de.unidue.nes.gpu.testframework.opencv.Imgproc;
|
||||
import de.unidue.nes.gpu.testframework.opencv.MatFunctions;
|
||||
import de.unidue.nes.gpu.testframework.opencv.ORB;
|
||||
import de.unidue.nes.gpu.testframework.opencv.StereoBM;
|
||||
import de.unidue.nes.gpu.testframework.tasks.CustomTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.DummyTask;
|
||||
|
||||
@@ -33,62 +24,8 @@ public class Main {
|
||||
System.out.println(Instant.now());// Just to time
|
||||
TestUtils<Mat[]> utils = new TestUtils<>();
|
||||
utils.setCommandPipeline(arr -> {
|
||||
Mat skyscraper = arr.get()[2];
|
||||
Mat morph = new Mat();
|
||||
MatFunctions.copyTo(skyscraper, morph);
|
||||
Imgproc.cvtColor(morph, morph, Imgproc.COLOR_BGR2GRAY);
|
||||
Imgproc.threshold(morph, morph, 128, 255, Imgproc.THRESH_BINARY);
|
||||
Mat dil = new Mat();
|
||||
Mat ero = new Mat();
|
||||
Mat open = new Mat();
|
||||
Mat closed = new Mat();
|
||||
|
||||
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(11, 11));
|
||||
Imgproc.dilate(morph, dil, kernel);
|
||||
Imgproc.erode(morph, ero, kernel);
|
||||
Imgproc.morphologyEx(morph, open, Imgproc.MORPH_OPEN, kernel);
|
||||
Imgproc.morphologyEx(morph, closed, Imgproc.MORPH_CLOSE, kernel);
|
||||
|
||||
CustomTask.addTask(new DummyTask(morph, dil, ero, open, closed));
|
||||
|
||||
Mat left = arr.get()[0];
|
||||
Mat right = arr.get()[1];
|
||||
|
||||
Mat grayLeft = new Mat();
|
||||
Mat grayRight = new Mat();
|
||||
Imgproc.cvtColor(left, grayLeft, Imgproc.COLOR_BGR2GRAY);
|
||||
Imgproc.cvtColor(right, grayRight, Imgproc.COLOR_BGR2GRAY);
|
||||
|
||||
StereoBM stereobm = StereoBM.create();
|
||||
Mat disparity = new Mat();
|
||||
stereobm.compute(grayLeft, grayRight, disparity);
|
||||
Mat disparityConverted = new Mat();
|
||||
MatFunctions.convertTo(disparity, disparityConverted, CvType.CV_8U, 0.25);
|
||||
MatFunctions.copyTo(disparityConverted, disparity);
|
||||
CustomTask.addTask(new DummyTask(left, right, disparity));
|
||||
|
||||
ORB orb = ORB.create(1000);
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
Mat descriptors1 = new Mat();
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
Mat descriptors2 = new Mat();
|
||||
Mat gray1 = new Mat();
|
||||
Mat gray2 = new Mat();
|
||||
|
||||
Imgproc.cvtColor(left, gray1, Imgproc.COLOR_BGR2GRAY);
|
||||
Imgproc.cvtColor(right, gray2, Imgproc.COLOR_BGR2GRAY);
|
||||
orb.detectAndCompute(gray1, new Mat(), keypoints1, descriptors1);
|
||||
orb.detectAndCompute(gray2, new Mat(), keypoints2, descriptors2);
|
||||
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
matcher.match(descriptors2, descriptors1, matches);
|
||||
|
||||
Mat outImg = new Mat();
|
||||
Features2d.drawMatches(left, keypoints1, right, keypoints2, matches, outImg);
|
||||
CustomTask.addTask(new DummyTask(outImg));
|
||||
|
||||
Mat image = new Mat();
|
||||
MatFunctions.copyTo(skyscraper, image);
|
||||
Mat image = arr.get()[0];
|
||||
Mat gray = new Mat();
|
||||
Mat edges = new Mat();
|
||||
Imgproc.cvtColor(image, gray, Imgproc.COLOR_BGR2GRAY);
|
||||
@@ -98,15 +35,14 @@ public class Main {
|
||||
CustomTask.addTask(new DummyTask(image, gray, edges));
|
||||
|
||||
});
|
||||
utils.setInput(new MatArrayInput(Imgcodecs.imread("src/main/resources/left_small.png"), Imgcodecs.imread("src/main/resources/right_small.png"),
|
||||
Imgcodecs.imread("src/main/resources/skyscraper_small.jpg")));
|
||||
utils.setInput(new MatArrayInput(Imgcodecs.imread("src/main/resources/skyscraper_small.jpg")));
|
||||
// utils.setInput(new MatArrayInput(Imgcodecs.imread("src/main/resources/left_small.png"), Imgcodecs.imread("src/main/resources/right_small.png")));
|
||||
// utils.setInput(new MatInput(Imgcodecs.imread("src/main/resources/car.jpg")));
|
||||
// utils.setInput(new MatInput(Imgcodecs.imread("src/main/resources/skyscraper_small.jpg")));
|
||||
|
||||
utils.initializeCommands();
|
||||
utils.initializeCommands(false);
|
||||
utils.warmup(2);
|
||||
utils.runTests(5);
|
||||
utils.runTests(2);
|
||||
utils.evaluate();
|
||||
System.out.println(Instant.now());// Just to time
|
||||
}
|
||||
|
||||
@@ -49,6 +49,12 @@ public class TestUtils<T> {
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private boolean testFullGraph;
|
||||
|
||||
private int warmupIterations;
|
||||
|
||||
private int testIterations;
|
||||
|
||||
public TestUtils() {
|
||||
this.initialized = false;
|
||||
}
|
||||
@@ -72,13 +78,16 @@ public class TestUtils<T> {
|
||||
|
||||
/**
|
||||
* use this to initialize the commands
|
||||
*
|
||||
* @param testFullGraph
|
||||
*/
|
||||
public void initializeCommands() {
|
||||
public void initializeCommands(boolean testFullGraph) {
|
||||
checkNotInitialized();
|
||||
checkFieldsAreSet();
|
||||
this.commands.accept(this.input);
|
||||
initDescriptions();
|
||||
this.initialized = true;
|
||||
this.testFullGraph = testFullGraph;
|
||||
}
|
||||
|
||||
private void initDescriptions() {
|
||||
@@ -103,8 +112,7 @@ public class TestUtils<T> {
|
||||
* @param iterations the number of warmup iterations
|
||||
*/
|
||||
public void warmup(int iterations) {
|
||||
warmupCPUTests(iterations);
|
||||
warmupGPUTests(iterations);
|
||||
this.warmupIterations = iterations;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,8 +121,7 @@ public class TestUtils<T> {
|
||||
* @param iterations the number of iterations to test
|
||||
*/
|
||||
public void runTests(int iterations) {
|
||||
runCPUTests(iterations);
|
||||
runGPUTests(iterations);
|
||||
this.testIterations = iterations;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,6 +346,10 @@ public class TestUtils<T> {
|
||||
* used to start the evaluation
|
||||
*/
|
||||
public void evaluate() {
|
||||
warmupCPUTests(this.warmupIterations);
|
||||
warmupGPUTests(this.warmupIterations);
|
||||
runCPUTests(this.testIterations);
|
||||
runGPUTests(this.testIterations);
|
||||
ResultHandler.evaluate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user