added features2d implementation

This commit is contained in:
2020-05-07 13:54:27 +02:00
parent ce8ed0c18a
commit 544f0f5dcc
2 changed files with 69 additions and 10 deletions
@@ -2,6 +2,7 @@ package de.unidue.nes.gpu.testframework.internal.tasks.features2d;
import org.opencv.core.Mat;
import org.opencv.core.MatOfKeyPoint;
import org.opencv.features2d.Features2d;
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
@@ -12,28 +13,47 @@ import de.unidue.nes.gpu.testframework.tasks.Task;
*/
public class DrawKeypoints implements Task {
public DrawKeypoints(Mat image, MatOfKeyPoint keypoints, Mat outImage) {
private final Mat image;
private final MatOfKeyPoint keypoints;
private final Mat outImage;
private final Mat originalImage;
private final MatOfKeyPoint originalKeypoints;
private final Mat originalOutImage;
public DrawKeypoints(Mat image, MatOfKeyPoint keypoints, Mat outImage) {
this.image = image;
this.keypoints = keypoints;
this.outImage = outImage;
this.originalImage = new Mat();
this.image.copyTo(this.originalImage);
this.originalKeypoints = new MatOfKeyPoint();
this.keypoints.copyTo(this.originalKeypoints);
this.originalOutImage = new Mat();
this.outImage.copyTo(this.originalOutImage);
}
@Override
public CpuTask toCpuTask() {
return null;
return () -> Features2d.drawKeypoints(this.image, this.keypoints, this.originalOutImage);
}
@Override
public GpuTask toGpuTask() {
return null;
return null; // no drawing keypoints on gpu
}
@Override
public String getDescription() {
return null;
return "Features2d.drawKeypoints(" + this.image + ", " + this.keypoints + ", " + this.originalOutImage + ")";
}
@Override
public void reset() {
this.originalImage.copyTo(this.image);
this.originalKeypoints.copyTo(this.keypoints);
this.originalOutImage.copyTo(this.outImage);
}
}
@@ -3,6 +3,7 @@ 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 org.opencv.features2d.Features2d;
import de.unidue.nes.gpu.testframework.tasks.CpuTask;
import de.unidue.nes.gpu.testframework.tasks.GpuTask;
@@ -13,28 +14,66 @@ import de.unidue.nes.gpu.testframework.tasks.Task;
*/
public class DrawMatches implements Task {
public DrawMatches(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, Mat outImg) {
private final Mat img1;
private final MatOfKeyPoint keypoints1;
private final Mat img2;
private final MatOfKeyPoint keypoints2;
private final MatOfDMatch matches1to2;
private final Mat outImg;
private final Mat originalImg1;
private final MatOfKeyPoint originalKeypoints1;
private final Mat originalImg2;
private final MatOfKeyPoint originalKeypoints2;
private final MatOfDMatch originalMatches1to2;
private final Mat originalOutImg;
public DrawMatches(Mat img1, MatOfKeyPoint keypoints1, Mat img2, MatOfKeyPoint keypoints2, MatOfDMatch matches1to2, Mat outImg) {
this.img1 = img1;
this.keypoints1 = keypoints1;
this.img2 = img2;
this.keypoints2 = keypoints2;
this.matches1to2 = matches1to2;
this.outImg = outImg;
this.originalImg1 = new Mat();
this.img1.copyTo(this.originalImg1);
this.originalKeypoints1 = new MatOfKeyPoint();
this.keypoints1.copyTo(this.originalKeypoints1);
this.originalImg2 = new Mat();
this.img2.copyTo(this.originalImg2);
this.originalKeypoints2 = new MatOfKeyPoint();
this.keypoints2.copyTo(this.originalKeypoints2);
this.originalMatches1to2 = new MatOfDMatch();
this.matches1to2.copyTo(this.originalMatches1to2);
this.originalOutImg = new Mat();
this.outImg.copyTo(this.originalOutImg);
}
@Override
public CpuTask toCpuTask() {
return null;
return () -> Features2d.drawMatches(this.img1, this.keypoints1, this.img2, this.keypoints2, this.matches1to2, this.originalOutImg);
}
@Override
public GpuTask toGpuTask() {
return null;
return null;// drawMatches has no gpu counterpart
}
@Override
public String getDescription() {
return null;
return "Features2d.drawMatches(" + this.img1 + ", " + this.keypoints1 + ", " + this.img2 + ", " + this.keypoints2 + ", " + this.matches1to2 + ", "
+ this.originalOutImg + ")";
}
@Override
public void reset() {
this.originalImg1.copyTo(this.img1);
this.originalKeypoints1.copyTo(this.keypoints1);
this.originalImg2.copyTo(this.img2);
this.originalKeypoints2.copyTo(this.keypoints2);
this.originalMatches1to2.copyTo(this.matches1to2);
this.originalOutImg.copyTo(this.outImg);
}
}