added stubs for feature related tasks
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package de.unidue.nes.gpu.testframework;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.input.MatTuple;
|
||||
import de.unidue.nes.gpu.testframework.input.MatTupleInput;
|
||||
import de.unidue.nes.gpu.testframework.opencv.Imgproc;
|
||||
import de.unidue.nes.gpu.testframework.input.MatInput;
|
||||
import de.unidue.nes.gpu.testframework.opencv.DescriptorMatcher;
|
||||
import de.unidue.nes.gpu.testframework.opencv.Features2d;
|
||||
import de.unidue.nes.gpu.testframework.opencv.ORB;
|
||||
import de.unidue.nes.gpu.testframework.tasks.CustomTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.DummyTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.DebugTask;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
@@ -21,24 +24,41 @@ public class Main {
|
||||
// main method only used to test
|
||||
public static void main(String[] args) {
|
||||
|
||||
TestUtils<MatTuple> utils = new TestUtils<>();
|
||||
utils.setCommandPipeline(tupleInput -> {
|
||||
Mat left = tupleInput.get().left;
|
||||
Mat right = tupleInput.get().right;
|
||||
Imgproc.cvtColor(left, left, org.opencv.imgproc.Imgproc.COLOR_BGR2GRAY);
|
||||
TestUtils<Mat> utils = new TestUtils<>();
|
||||
utils.setCommandPipeline(input -> {
|
||||
Mat mat = input.get();
|
||||
Mat other = new Mat();
|
||||
Imgproc.threshold(left, other, 150, 255, org.opencv.imgproc.Imgproc.THRESH_BINARY);
|
||||
CustomTask.addTask(new DummyTask(left, right, other));
|
||||
mat.copyTo(other);
|
||||
ORB orb = ORB.create();
|
||||
ORB.create(500);
|
||||
ORB.create(500, 0.5f);
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
Mat descriptors = new Mat();
|
||||
orb.detectAndCompute(mat, new Mat(), keypoints, descriptors);
|
||||
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
Mat descriptors2 = new Mat();
|
||||
orb.detectAndCompute(other, new Mat(), keypoints2, descriptors2);
|
||||
|
||||
DescriptorMatcher matcher = DescriptorMatcher.create(org.opencv.features2d.DescriptorMatcher.BRUTEFORCE_HAMMING);
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
matcher.match(descriptors2, descriptors, matches);
|
||||
Mat out = new Mat();
|
||||
Mat otherOut = new Mat();
|
||||
Features2d.drawMatches(mat, keypoints, other, keypoints2, matches, out);
|
||||
Features2d.drawKeypoints(mat, keypoints, otherOut);
|
||||
|
||||
CustomTask.addTask(new DebugTask(mat, out, otherOut));
|
||||
});
|
||||
utils.setInput(new MatTupleInput(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/left_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.warmupCPUTests(5);
|
||||
utils.runCPUTests(10);
|
||||
utils.warmupGPUTests(5);
|
||||
utils.runGPUTests(10);
|
||||
utils.evaluate();
|
||||
utils.warmupCPUTests(1);
|
||||
// utils.runCPUTests(10);
|
||||
// utils.warmupGPUTests(5);
|
||||
// utils.runGPUTests(10);
|
||||
// utils.evaluate();
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.descriptormatcher;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DescriptorMatcher_create implements Task {
|
||||
|
||||
public DescriptorMatcher_create(int id, int matcherType) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.descriptormatcher;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DescriptorMatcher_match implements Task {
|
||||
|
||||
public DescriptorMatcher_match(int id, Mat queryDescriptors, Mat trainDescriptors, MatOfDMatch matches) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.descriptormatcher;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DescriptorMatchers {
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.features2d;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DrawKeypoints implements Task {
|
||||
|
||||
public DrawKeypoints(Mat image, MatOfKeyPoint keypoints, Mat outImage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.features2d;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DrawMatches implements Task {
|
||||
|
||||
public DrawMatches(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, Mat outImg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.orb;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class ORB_create implements Task {
|
||||
|
||||
public ORB_create(int id) {
|
||||
|
||||
}
|
||||
|
||||
public ORB_create(int id, int nfeatures) {
|
||||
|
||||
}
|
||||
|
||||
public ORB_create(int id, int nfeatures, float scaleFactor) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.orb;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
|
||||
import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class ORB_detectAndCompute implements Task {
|
||||
|
||||
public ORB_detectAndCompute(int id, Mat image, Mat mask, MatOfKeyPoint keypoints, Mat descriptors) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.unidue.nes.gpu.testframework.internal.tasks.orb;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class ORBs {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.unidue.nes.gpu.testframework.opencv;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.internal.pipeline.TestPipeline;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.descriptormatcher.DescriptorMatcher_create;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.descriptormatcher.DescriptorMatcher_match;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class DescriptorMatcher {
|
||||
|
||||
private static final AtomicInteger nextId = new AtomicInteger();
|
||||
|
||||
private final int id;
|
||||
|
||||
private DescriptorMatcher(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static DescriptorMatcher create(int matcherType) {
|
||||
int newId = nextId.getAndIncrement();
|
||||
TestPipeline.INSTANCE.addTask(new DescriptorMatcher_create(newId, matcherType));
|
||||
return new DescriptorMatcher(newId);
|
||||
}
|
||||
|
||||
public void match(Mat queryDescriptors, Mat trainDescriptors, MatOfDMatch matches) {
|
||||
TestPipeline.INSTANCE.addTask(new DescriptorMatcher_match(this.id, queryDescriptors, trainDescriptors, matches));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.unidue.nes.gpu.testframework.opencv;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.internal.pipeline.TestPipeline;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.features2d.DrawKeypoints;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.features2d.DrawMatches;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class Features2d {
|
||||
|
||||
public static void drawMatches(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, Mat outImg) {
|
||||
TestPipeline.INSTANCE.addTask(new DrawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg));
|
||||
}
|
||||
|
||||
public static void drawKeypoints(Mat image, MatOfKeyPoint keypoints, Mat outImage) {
|
||||
TestPipeline.INSTANCE.addTask(new DrawKeypoints(image, keypoints, outImage));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.unidue.nes.gpu.testframework.opencv;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
|
||||
import de.unidue.nes.gpu.testframework.internal.pipeline.TestPipeline;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.orb.ORB_create;
|
||||
import de.unidue.nes.gpu.testframework.internal.tasks.orb.ORB_detectAndCompute;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class ORB {
|
||||
|
||||
private static final AtomicInteger nextId = new AtomicInteger();
|
||||
|
||||
private final int id;
|
||||
|
||||
private ORB(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static ORB create() {
|
||||
int newId = nextId.getAndIncrement();
|
||||
TestPipeline.INSTANCE.addTask(new ORB_create(newId));
|
||||
return new ORB(newId);
|
||||
}
|
||||
|
||||
public static ORB create(int nfeatures) {
|
||||
int newId = nextId.getAndIncrement();
|
||||
TestPipeline.INSTANCE.addTask(new ORB_create(newId, nfeatures));
|
||||
return new ORB(newId);
|
||||
}
|
||||
|
||||
public static ORB create(int nfeatures, float scaleFactor) {
|
||||
int newId = nextId.getAndIncrement();
|
||||
TestPipeline.INSTANCE.addTask(new ORB_create(newId, nfeatures, scaleFactor));
|
||||
return new ORB(newId);
|
||||
}
|
||||
|
||||
public void detectAndCompute(Mat image, Mat mask, MatOfKeyPoint keypoints, Mat descriptors) {
|
||||
TestPipeline.INSTANCE.addTask(new ORB_detectAndCompute(this.id, image, mask, keypoints, descriptors));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user