added feature test and dilation test
This commit is contained in:
@@ -13,6 +13,7 @@ import de.unidue.nes.gpu.events.ApplicationFinishedEvent;
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.initialization.Initializer;
|
||||
import de.unidue.nes.gpu.tasks.Task;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.KernelTask;
|
||||
|
||||
/**
|
||||
* Class containing the main method of this project.
|
||||
@@ -84,9 +85,10 @@ public class GpuTestSystem {
|
||||
// new UploadDownloadTask(), //
|
||||
// new PageLockedUploadDownloadTask(), //
|
||||
// new PixelWiseTask(), //
|
||||
// new KernelTask(), //
|
||||
new KernelTask() //
|
||||
// new ImgProcTask(),//
|
||||
// new PipelineTask()//
|
||||
// new PipelineTask(),//
|
||||
// new FeatureBasedTask() //
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
package de.unidue.nes.gpu.events;
|
||||
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_CANNY;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_DILATE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_FEATURE_DETECTION1;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_FEATURE_DETECTION2;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_GAUSSIAN_BLUR;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_GRAYSCALE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_HOUGH_CIRCLE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_MEDIAN_BLUR;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_PIPELINE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_STEREO_MATCHING;
|
||||
import static de.unidue.nes.gpu.events.TaskType.CPU_THRESHOLD;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_CANNY;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_COMBINED;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_DILATE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_DOWNLOAD;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_FEATURE_DETECTION1;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_FEATURE_DETECTION2;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_GAUSSIAN_BLUR;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_GRAYSCALE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_HOUGH_CIRCLE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_MEDIAN_BLUR;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_PIPELINE;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_STEREO_MATCHING;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_THRESHOLD;
|
||||
import static de.unidue.nes.gpu.events.TaskType.GPU_UPLOAD;
|
||||
import static de.unidue.nes.gpu.events.TaskType.PAGE_LOCKED_GPU_COMBINED;
|
||||
@@ -74,6 +80,8 @@ public class EventHandler {
|
||||
printKernelTasks();
|
||||
printImageProcTasks();
|
||||
printPipelineTasks();
|
||||
printFeatureTasks();
|
||||
printStereoTable();
|
||||
|
||||
List<TaskResultEvent> notTested = this.events.stream().filter(evt -> !this.testedTasks.contains(evt.getType())).collect(Collectors.toList());
|
||||
if (!notTested.isEmpty()) {
|
||||
@@ -82,6 +90,16 @@ public class EventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void printStereoTable() {
|
||||
printTable("stereo matching table", new TaskType[] { CPU_STEREO_MATCHING, GPU_STEREO_MATCHING });
|
||||
}
|
||||
|
||||
private void printFeatureTasks() {
|
||||
// printTable("feature table", new TaskType[] { CPU_FEATURE_DETECTION, GPU_FEATURE_DETECTION });
|
||||
printTable("skyscraper table", new TaskType[] { CPU_FEATURE_DETECTION1, GPU_FEATURE_DETECTION1 });
|
||||
printTable("motorcycle table", new TaskType[] { CPU_FEATURE_DETECTION2, GPU_FEATURE_DETECTION2 });
|
||||
}
|
||||
|
||||
private void printPipelineTasks() {
|
||||
printTable("pipeline table", new TaskType[] { CPU_PIPELINE, GPU_PIPELINE });
|
||||
}
|
||||
@@ -91,7 +109,7 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
private void printKernelTasks() {
|
||||
printTable("kernel table", new TaskType[] { CPU_MEDIAN_BLUR, GPU_MEDIAN_BLUR, CPU_GAUSSIAN_BLUR, GPU_GAUSSIAN_BLUR });
|
||||
printTable("kernel table", new TaskType[] { CPU_GAUSSIAN_BLUR, GPU_GAUSSIAN_BLUR, CPU_DILATE, GPU_DILATE });
|
||||
}
|
||||
|
||||
private void printPixelwiseStuff() {
|
||||
@@ -125,6 +143,8 @@ public class EventHandler {
|
||||
table.append(content.toString());
|
||||
table.append("\\end{tabular}");
|
||||
System.out.println(table.toString());
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
private void buildDividedTable(boolean addHorizontalLines, List<TaskResultEvent> eventList, List<Size> sizes, StringBuilder headline,
|
||||
|
||||
@@ -10,7 +10,12 @@ public enum TaskType {
|
||||
CPU_MEDIAN_BLUR("CPU median filter"), GPU_MEDIAN_BLUR("GPU median filter"), //
|
||||
CPU_GAUSSIAN_BLUR("CPU gaussian filter"), GPU_GAUSSIAN_BLUR("GPU gaussian filter"), //
|
||||
CPU_CANNY("CPU edge detection"), GPU_CANNY("GPU edge detection"), CPU_HOUGH_CIRCLE("CPU circle detection"), GPU_HOUGH_CIRCLE("GPU circle detection"), //
|
||||
CPU_PIPELINE("CPU pipeline"), GPU_PIPELINE("GPU pipeline");
|
||||
CPU_PIPELINE("CPU pipeline"), GPU_PIPELINE("GPU pipeline"), //
|
||||
CPU_FEATURE_DETECTION("CPU feature detection"), GPU_FEATURE_DETECTION("GPU feature detection"), //
|
||||
CPU_FEATURE_MATCHING("CPU feature matching"), GPU_FEATURE_MATCHING("GPU feature matching"), //
|
||||
CPU_STEREO_MATCHING("CPU stereo matching"), GPU_STEREO_MATCHING("GPU stereo matching"), CPU_FEATURE_DETECTION1("CPU feature detection"),
|
||||
CPU_FEATURE_DETECTION2("CPU feature detection"), GPU_FEATURE_DETECTION1("GPU feature detection"), GPU_FEATURE_DETECTION2("GPU feature detection"), //
|
||||
CPU_DILATE("CPU dilate"), GPU_DILATE("GPU dilate");
|
||||
|
||||
private String title;
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.unidue.nes.gpu.tasks.cputasks;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.KernelTask;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class CPUDilation {
|
||||
|
||||
public void dilate(Mat img) {
|
||||
|
||||
Mat dst = new Mat();
|
||||
Mat kernel = Imgproc.getStructuringElement(Imgproc.CV_SHAPE_RECT, new Size(15, 15));
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.dilate(img, dst, kernel), KernelTask.TEST_RUNS);
|
||||
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.CPU_DILATE, time));
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,11 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.opencv.calib3d.StereoBM;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import de.unidue.nes.gpu.GpuTestSystem;
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.FeatureBasedTask;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
@@ -19,9 +23,10 @@ public class CPUStereoMatching {
|
||||
StereoBM matcher = StereoBM.create(256, 15);
|
||||
Mat disparity = new Mat();
|
||||
|
||||
long time = TimingService.measureTime(() -> matcher.compute(leftImage, rightImage, disparity), GpuTestSystem.TEST_RUNS);
|
||||
TimeDto time = TimingService.testPerformance(() -> matcher.compute(leftImage, rightImage, disparity), FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu stereo matching took of image size " + leftImage.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, leftImage.size(), TaskType.CPU_STEREO_MATCHING, time));
|
||||
// Just for debugging
|
||||
// Imgproc.resize(disparity, disparity, new Size(), 0.5, 0.5);
|
||||
// disparity.convertTo(disparity, CvType.CV_8U, 0.075);
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package de.unidue.nes.gpu.tasks.cputasks;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.features2d.DescriptorMatcher;
|
||||
import org.opencv.features2d.ORB;
|
||||
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.FeatureBasedTask;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class CpuFeatureTask {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(CpuFeatureTask.class);
|
||||
|
||||
public void detectAndCompute1(Mat image) {
|
||||
ORB orb = ORB.create();
|
||||
Mat mask = new Mat();
|
||||
|
||||
MatOfKeyPoint imageKeypoints = new MatOfKeyPoint();
|
||||
Mat imageDescriptors = new Mat();
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
orb.detectAndCompute(image, mask, imageKeypoints, imageDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.CPU_FEATURE_DETECTION1, time));
|
||||
}
|
||||
|
||||
public void detectAndCompute2(Mat image) {
|
||||
ORB orb = ORB.create();
|
||||
Mat mask = new Mat();
|
||||
|
||||
MatOfKeyPoint imageKeypoints = new MatOfKeyPoint();
|
||||
Mat imageDescriptors = new Mat();
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
orb.detectAndCompute(image, mask, imageKeypoints, imageDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.CPU_FEATURE_DETECTION2, time));
|
||||
}
|
||||
|
||||
public void match(Mat[] images) {
|
||||
if (images.length != 2) {
|
||||
throw new RuntimeException("This should not happen");
|
||||
}
|
||||
|
||||
ORB orb = ORB.create();
|
||||
DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
|
||||
|
||||
Mat mask = new Mat();
|
||||
|
||||
MatOfKeyPoint imageKeypoints = new MatOfKeyPoint();
|
||||
Mat imageDescriptors = new Mat();
|
||||
|
||||
MatOfKeyPoint testKeyPoints = new MatOfKeyPoint();
|
||||
Mat testDescriptors = new Mat();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
|
||||
orb.detectAndCompute(images[0], mask, imageKeypoints, imageDescriptors);
|
||||
orb.detectAndCompute(images[1], mask, testKeyPoints, testDescriptors);
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
matcher.match(testDescriptors, imageDescriptors, matches);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature matching time for images of size " + images[0].size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, images[0].size(), TaskType.CPU_FEATURE_MATCHING, time));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.unidue.nes.gpu.tasks.gputasks;
|
||||
|
||||
import org.bytedeco.opencv.global.opencv_core;
|
||||
import org.bytedeco.opencv.global.opencv_cudafilters;
|
||||
import org.bytedeco.opencv.global.opencv_imgproc;
|
||||
import org.bytedeco.opencv.opencv_core.GpuMat;
|
||||
import org.bytedeco.opencv.opencv_core.Mat;
|
||||
import org.bytedeco.opencv.opencv_core.Size;
|
||||
import org.bytedeco.opencv.opencv_cudafilters.Filter;
|
||||
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.KernelTask;
|
||||
import de.unidue.nes.gpu.utils.MatConverter;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class GPUDilation {
|
||||
|
||||
public void dilate(org.opencv.core.Mat img) {
|
||||
|
||||
Mat kernel = opencv_imgproc.getStructuringElement(opencv_imgproc.CV_SHAPE_RECT, new Size(15, 15));
|
||||
Filter filter = opencv_cudafilters.createMorphologyFilter(opencv_imgproc.MORPH_DILATE, opencv_core.CV_8U, kernel);
|
||||
GpuMat dst = new GpuMat();
|
||||
GpuMat src = new GpuMat();
|
||||
MatConverter converter = new MatConverter();
|
||||
Mat mat = converter.convert2Javacv(img);
|
||||
src.upload(mat);
|
||||
|
||||
// Mat dst = new Mat();
|
||||
// Mat kernel = Imgproc.getStructuringElement(Imgproc.CV_SHAPE_RECT, new Size(15, 15));
|
||||
TimeDto time = TimingService.testPerformance(() -> filter.apply(src, dst), KernelTask.TEST_RUNS);
|
||||
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.GPU_DILATE, time));
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,12 @@ import org.bytedeco.opencv.opencv_core.GpuMat;
|
||||
import org.bytedeco.opencv.opencv_cudastereo.StereoBM;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
import de.unidue.nes.gpu.GpuTestSystem;
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.FeatureBasedTask;
|
||||
import de.unidue.nes.gpu.utils.MatConverter;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
@@ -34,9 +38,10 @@ public class GPUStereoMatching {
|
||||
|
||||
right.upload(this.converter.convert2Javacv(rightImage));
|
||||
|
||||
long time = TimingService.measureTime(() -> matcher.compute(left, right, disparity), GpuTestSystem.TEST_RUNS);
|
||||
TimeDto time = TimingService.testPerformance(() -> matcher.compute(left, right, disparity), FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu stereo matching took of image size " + leftImage.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, leftImage.size(), TaskType.GPU_STEREO_MATCHING, time));
|
||||
|
||||
// Just for debugging
|
||||
// org.bytedeco.opencv.opencv_core.Mat res = new org.bytedeco.opencv.opencv_core.Mat();
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
package de.unidue.nes.gpu.tasks.gputasks;
|
||||
|
||||
import static org.bytedeco.opencv.global.opencv_core.NORM_HAMMING;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bytedeco.opencv.opencv_core.DMatchVector;
|
||||
import org.bytedeco.opencv.opencv_core.GpuMat;
|
||||
import org.bytedeco.opencv.opencv_core.KeyPointVector;
|
||||
import org.bytedeco.opencv.opencv_core.Mat;
|
||||
import org.bytedeco.opencv.opencv_cudafeatures2d.DescriptorMatcher;
|
||||
import org.bytedeco.opencv.opencv_cudafeatures2d.ORB;
|
||||
|
||||
import de.unidue.nes.gpu.events.GpuEventBus;
|
||||
import de.unidue.nes.gpu.events.TaskResultEvent;
|
||||
import de.unidue.nes.gpu.events.TaskType;
|
||||
import de.unidue.nes.gpu.tasks.taskdefinitions.FeatureBasedTask;
|
||||
import de.unidue.nes.gpu.utils.MatConverter;
|
||||
import de.unidue.nes.gpu.utils.TimeDto;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*/
|
||||
public class GpuFeatureTask {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(GpuFeatureTask.class);
|
||||
|
||||
private MatConverter converter;
|
||||
|
||||
public GpuFeatureTask() {
|
||||
this.converter = new MatConverter();
|
||||
}
|
||||
|
||||
public void detectAndCompute1(org.opencv.core.Mat image) {
|
||||
Mat first = new Mat();
|
||||
this.converter.convert(image, first);
|
||||
|
||||
try (GpuMat gpuImg = new GpuMat();
|
||||
GpuMat mask = new GpuMat();
|
||||
GpuMat imgDescriptors = new GpuMat();
|
||||
ORB orb = ORB.create();
|
||||
KeyPointVector keypoints = new KeyPointVector()) {
|
||||
|
||||
gpuImg.upload(first);
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
orb.detectAndCompute(gpuImg, mask, keypoints, imgDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.GPU_FEATURE_DETECTION1, time));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void detectAndCompute2(org.opencv.core.Mat image) {
|
||||
Mat first = new Mat();
|
||||
this.converter.convert(image, first);
|
||||
|
||||
try (GpuMat gpuImg = new GpuMat();
|
||||
GpuMat mask = new GpuMat();
|
||||
GpuMat imgDescriptors = new GpuMat();
|
||||
ORB orb = ORB.create();
|
||||
KeyPointVector keypoints = new KeyPointVector()) {
|
||||
|
||||
gpuImg.upload(first);
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
orb.detectAndCompute(gpuImg, mask, keypoints, imgDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.GPU_FEATURE_DETECTION2, time));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void match(org.opencv.core.Mat[] images) {
|
||||
if (images.length != 2) {
|
||||
throw new RuntimeException("This should not happen");
|
||||
}
|
||||
|
||||
Mat first = new Mat();
|
||||
Mat second = new Mat();
|
||||
this.converter.convert(images[0], first);
|
||||
this.converter.convert(images[1], second);
|
||||
|
||||
try (GpuMat gpuImg = new GpuMat();
|
||||
GpuMat gpuImg2 = new GpuMat();
|
||||
GpuMat mask = new GpuMat();
|
||||
GpuMat imgDescriptors = new GpuMat();
|
||||
GpuMat testDescriptors = new GpuMat();
|
||||
ORB orb = ORB.create();
|
||||
DescriptorMatcher matcher = DescriptorMatcher.createBFMatcher(NORM_HAMMING);
|
||||
KeyPointVector keypoints = new KeyPointVector();
|
||||
KeyPointVector testKeyPoints = new KeyPointVector();
|
||||
DMatchVector matches = new DMatchVector()) {
|
||||
|
||||
gpuImg.upload(first);
|
||||
gpuImg2.upload(second);
|
||||
orb.detectAndCompute(gpuImg, mask, keypoints, imgDescriptors);
|
||||
orb.detectAndCompute(gpuImg2, mask, testKeyPoints, testDescriptors);
|
||||
TimeDto time = TimingService.testPerformance(() -> {
|
||||
matcher.match(testDescriptors, imgDescriptors, matches);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu matching time for images of size " + images[0].size() + ": " + time + "ms");
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, images[0].size(), TaskType.GPU_FEATURE_MATCHING, time));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.unidue.nes.gpu.tasks.taskdefinitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import de.unidue.nes.gpu.tasks.Task;
|
||||
import de.unidue.nes.gpu.tasks.cputasks.CPUDilation;
|
||||
import de.unidue.nes.gpu.tasks.gputasks.GPUDilation;
|
||||
import de.unidue.nes.gpu.utils.ImageLoader;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class DilateTask implements Task {
|
||||
|
||||
@Override
|
||||
public void runTask() {
|
||||
Mat[] images = ImageLoader.getTestImagesForKernelOperations();
|
||||
Arrays.stream(images).forEach(img -> Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY));
|
||||
|
||||
CPUDilation cpuTask = new CPUDilation();
|
||||
GPUDilation gpuTask = new GPUDilation();
|
||||
|
||||
Arrays.stream(images).forEach(cpuTask::dilate);
|
||||
Arrays.stream(images).forEach(gpuTask::dilate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package de.unidue.nes.gpu.tasks.taskdefinitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import de.unidue.nes.gpu.tasks.Task;
|
||||
import de.unidue.nes.gpu.tasks.cputasks.CPUStereoMatching;
|
||||
import de.unidue.nes.gpu.tasks.cputasks.CpuFeatureTask;
|
||||
import de.unidue.nes.gpu.tasks.gputasks.GPUStereoMatching;
|
||||
import de.unidue.nes.gpu.tasks.gputasks.GpuFeatureTask;
|
||||
import de.unidue.nes.gpu.utils.ImageLoader;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
*
|
||||
*/
|
||||
public class FeatureBasedTask implements Task {
|
||||
|
||||
public static final int TEST_RUNS = 2;
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(FeatureBasedTask.class);
|
||||
|
||||
@Override
|
||||
public void runTask() {
|
||||
Mat[][] stereoimages = ImageLoader.getStereoImages();
|
||||
Mat[] featureimages = ImageLoader.getFeatureImages();
|
||||
// for (int i = 0; i < stereoimages.length; i++) {
|
||||
// Imgproc.cvtColor(stereoimages[i][0], stereoimages[i][0], Imgproc.COLOR_BGR2GRAY);
|
||||
// Imgproc.cvtColor(stereoimages[i][1], stereoimages[i][1], Imgproc.COLOR_BGR2GRAY);
|
||||
// }
|
||||
Stream.concat(Arrays.stream(stereoimages).flatMap(Stream::of), Arrays.stream(featureimages))
|
||||
.forEach(mat -> Imgproc.cvtColor(mat, mat, Imgproc.COLOR_BGR2GRAY));
|
||||
|
||||
CpuFeatureTask cpuTask = new CpuFeatureTask();
|
||||
GpuFeatureTask gpuTask = new GpuFeatureTask();
|
||||
CPUStereoMatching cpuStereo = new CPUStereoMatching();
|
||||
GPUStereoMatching gpuStereo = new GPUStereoMatching();
|
||||
|
||||
for (int i = 0; i < featureimages.length; i += 2) {
|
||||
final int index = i;
|
||||
LOG.info(() -> "Image sizes: " + featureimages[index].size() + ", " + featureimages[index + 1].size());
|
||||
Mat resizedImage = new Mat();
|
||||
Imgproc.resize(featureimages[i], resizedImage, featureimages[i + 1].size());
|
||||
cpuTask.detectAndCompute1(resizedImage);
|
||||
cpuTask.detectAndCompute2(featureimages[i + 1]);
|
||||
gpuTask.detectAndCompute1(resizedImage);
|
||||
gpuTask.detectAndCompute2(featureimages[i + 1]);
|
||||
}
|
||||
|
||||
// Arrays.stream(featureimages).forEach(gpuTask::detectAndCompute);
|
||||
// Arrays.stream(images).forEach(cpuTask::match);
|
||||
// Arrays.stream(images).forEach(gpuTask::match);
|
||||
|
||||
Arrays.stream(stereoimages).forEach(arr -> cpuStereo.matchImages(arr[0], arr[1]));
|
||||
Arrays.stream(stereoimages).forEach(arr -> gpuStereo.matchImages(arr[0], arr[1]));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,9 +29,9 @@ public class FilteringTask implements Task {
|
||||
Mat[] images = ImageLoader.getTestImagesForKernelOperations();
|
||||
Arrays.stream(images).forEach(img -> Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY));
|
||||
|
||||
Arrays.stream(images).forEach(this.cpuTask::runMedianFiltering);
|
||||
// Arrays.stream(images).forEach(this.cpuTask::runMedianFiltering);
|
||||
Arrays.stream(images).forEach(this.cpuTask::runGaussianBlur);
|
||||
Arrays.stream(images).forEach(this.gpuTask::runMedianFiltering);
|
||||
// Arrays.stream(images).forEach(this.gpuTask::runMedianFiltering);
|
||||
Arrays.stream(images).forEach(this.gpuTask::runGaussianBlur);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ public class KernelTask implements Task {
|
||||
public void runTask() {
|
||||
FilteringTask task = new FilteringTask();
|
||||
task.runTask();
|
||||
|
||||
DilateTask diltask = new DilateTask();
|
||||
diltask.runTask();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,4 +59,8 @@ public class ImageLoader {
|
||||
public static Mat[] getTestImagesForPipeline() {
|
||||
return getLargeImageDataset();
|
||||
}
|
||||
|
||||
public static Mat[] getFeatureImages() {
|
||||
return getLargeImageDataset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user