adjusted system to only test necessary stuff
This commit is contained in:
@@ -29,11 +29,14 @@ public class GpuTestSystem {
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(GpuTestSystem.class);
|
||||
|
||||
public static final int TEST_RUNS_PER_TEST = 2;
|
||||
// number of runs per test
|
||||
public static final int TEST_RUNS_PER_TEST = 25;
|
||||
|
||||
public static final int TEST_RUNS_ITERATIONS = 2;
|
||||
// number of runs to compute average and sigma
|
||||
public static final int TEST_RUNS_ITERATIONS = 10;
|
||||
|
||||
public static final int TEST_RUNS_WARMUP = 5;
|
||||
// number of runs during warmup (per test)
|
||||
public static final int TEST_RUNS_WARMUP = 10;
|
||||
|
||||
public static boolean initPhase = false;
|
||||
|
||||
@@ -55,11 +58,7 @@ public class GpuTestSystem {
|
||||
public void run() {
|
||||
List<Task> tasks = getTasks();
|
||||
GpuEventBus.INSTANCE.post(() -> tasks);
|
||||
try {
|
||||
Thread.sleep(90000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
GpuEventBus.INSTANCE.stopListening();
|
||||
LOG.info("Running tasks so dlls get loaded");
|
||||
muteLogger();
|
||||
@@ -68,9 +67,10 @@ public class GpuTestSystem {
|
||||
// run tasks for the first time to load dlls and initialize everything
|
||||
tasks.stream().peek(t -> System.out.println("starting " + t.getClass().getSimpleName())).forEach(Task::runTask);
|
||||
|
||||
LOG.info("second warmup run");
|
||||
// run again to be sure that nothing is loaded anymore
|
||||
// 1 run should already be sufficient
|
||||
tasks.forEach(Task::runTask);
|
||||
tasks.stream().peek(t -> System.out.println("starting " + t.getClass().getSimpleName())).forEach(Task::runTask);
|
||||
|
||||
resetLogger();
|
||||
initPhase = false;
|
||||
|
||||
@@ -21,16 +21,16 @@ public class PipelineTask implements Task {
|
||||
CpuPipeline cpuTask = new CpuPipeline();
|
||||
GpuPipeline gpuTask = new GpuPipeline();
|
||||
|
||||
Mat[] images = ImageLoader.getTestImagesForPipeline();
|
||||
Mat[] images = ImageLoader.getTestImagesForCannyPipeline();
|
||||
Arrays.stream(images).forEach(cpuTask::doCannyPipeline);
|
||||
|
||||
images = ImageLoader.getTestImagesForPipeline();
|
||||
images = ImageLoader.getTestImagesForCannyPipeline();
|
||||
Arrays.stream(images).forEach(gpuTask::doCannyPipeline);
|
||||
|
||||
Mat[][] stereoImages = ImageLoader.getStereoImages();
|
||||
Mat[][] stereoImages = ImageLoader.getStereoPipelineImages();
|
||||
Arrays.stream(stereoImages).forEach(cpuTask::doStereoPipeline);
|
||||
|
||||
stereoImages = ImageLoader.getStereoImages();
|
||||
stereoImages = ImageLoader.getStereoPipelineImages();
|
||||
Arrays.stream(stereoImages).forEach(gpuTask::doStereoPipeline);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,18 +37,13 @@ import static de.unidue.nes.gpu.events.TaskType.PAGE_LOCKED_GPU_UPLOAD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.opencv.core.Size;
|
||||
|
||||
import com.google.common.eventbus.DeadEvent;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
@@ -58,10 +53,6 @@ import com.google.common.eventbus.Subscribe;
|
||||
*/
|
||||
public class EventHandler {
|
||||
|
||||
private static final String HLINE_LINEBREAK = "\\hline\n";
|
||||
|
||||
private static final String LATEX_TABLE_END_OF_LINE = " \\\\\n";
|
||||
|
||||
private static final Logger LOG = LogManager.getLogger(EventHandler.class);
|
||||
|
||||
private List<TaskResultEvent> events;
|
||||
@@ -101,33 +92,33 @@ public class EventHandler {
|
||||
}
|
||||
|
||||
private void printMatchingTable() {
|
||||
printFeatureMatchingTable("feature matching table", new TaskType[] { CPU_FEATURE_MATCHING, GPU_FEATURE_MATCHING });
|
||||
printTable("feature matching", new TaskType[] { CPU_FEATURE_MATCHING, GPU_FEATURE_MATCHING });
|
||||
}
|
||||
|
||||
private void printStereoTable() {
|
||||
printTable("stereo matching table", new TaskType[] { CPU_STEREO_MATCHING, GPU_STEREO_MATCHING });
|
||||
printTable("stereo matching", new TaskType[] { CPU_STEREO_MATCHING, GPU_STEREO_MATCHING });
|
||||
}
|
||||
|
||||
private void printFeatureTasks() {
|
||||
printTable("feature table", new TaskType[] { CPU_FEATURE_DETECTION1, GPU_FEATURE_DETECTION1, CPU_FEATURE_DETECTION2, GPU_FEATURE_DETECTION2 });
|
||||
printTable("feature", new TaskType[] { CPU_FEATURE_DETECTION1, GPU_FEATURE_DETECTION1, CPU_FEATURE_DETECTION2, GPU_FEATURE_DETECTION2 });
|
||||
}
|
||||
|
||||
private void printPipelineTasks() {
|
||||
printTable("canny pipeline table", new TaskType[] { CPU_CANNY_PIPELINE, GPU_CANNY_PIPELINE });
|
||||
printTable("stereo pipeline table", new TaskType[] { CPU_STEREO_PIPELINE, GPU_STEREO_PIPELINE });
|
||||
printTable("canny pipeline", new TaskType[] { CPU_CANNY_PIPELINE, GPU_CANNY_PIPELINE });
|
||||
printTable("stereo pipeline", new TaskType[] { CPU_STEREO_PIPELINE, GPU_STEREO_PIPELINE });
|
||||
}
|
||||
|
||||
private void printImageProcTasks() {
|
||||
printTable("imgproc table", new TaskType[] { CPU_CANNY, GPU_CANNY, CPU_HOUGH_CIRCLE, GPU_HOUGH_CIRCLE });
|
||||
printTable("imgproc", new TaskType[] { CPU_CANNY, GPU_CANNY, CPU_HOUGH_CIRCLE, GPU_HOUGH_CIRCLE });
|
||||
}
|
||||
|
||||
private void printKernelTasks() {
|
||||
printTable("kernel table",
|
||||
printTable("kernel",
|
||||
new TaskType[] { CPU_MEDIAN_BLUR, GPU_MEDIAN_BLUR, CPU_GAUSSIAN_BLUR, GPU_GAUSSIAN_BLUR, CPU_DILATE, GPU_DILATE, CPU_ERODE, GPU_ERODE });
|
||||
}
|
||||
|
||||
private void printPixelwiseStuff() {
|
||||
printTable("pixel-wise table", new TaskType[] { CPU_THRESHOLD, GPU_THRESHOLD, CPU_GRAYSCALE, GPU_GRAYSCALE });
|
||||
printTable("pixel-wise", new TaskType[] { CPU_THRESHOLD, GPU_THRESHOLD, CPU_GRAYSCALE, GPU_GRAYSCALE });
|
||||
}
|
||||
|
||||
private void printUploadDownloadStuff() {
|
||||
@@ -135,138 +126,12 @@ public class EventHandler {
|
||||
new TaskType[] { GPU_UPLOAD, GPU_DOWNLOAD, GPU_COMBINED, PAGE_LOCKED_GPU_UPLOAD, PAGE_LOCKED_GPU_DOWNLOAD, PAGE_LOCKED_GPU_COMBINED });
|
||||
}
|
||||
|
||||
private void printFeatureMatchingTable(String tablename, TaskType[] types) {
|
||||
this.testedTasks.addAll(Arrays.asList(types));
|
||||
List<TaskResultEvent> eventList = this.events.stream().filter(ev -> Arrays.asList(types).contains(ev.getType())).collect(Collectors.toList());
|
||||
if (eventList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
System.out.println(tablename + ": ");
|
||||
List<Integer> numberOfFeatures = IntStream.iterate(500, i -> true, i -> i + 500).limit(20).boxed().collect(Collectors.toList());
|
||||
|
||||
Map<TaskType, List<TaskResultEvent>> mappedEvents = new EnumMap<>(TaskType.class);
|
||||
for (TaskResultEvent event : eventList) {
|
||||
mappedEvents.computeIfAbsent(event.getType(), k -> new ArrayList<>()).add(event);
|
||||
}
|
||||
StringBuilder content = new StringBuilder();
|
||||
mappedEvents.entrySet().stream().sorted(Comparator.comparingInt(entry -> entry.getKey().ordinal())).forEach(entry -> {
|
||||
content.append(entry.getKey().getTitle());
|
||||
content.append(" number of features = (average time, standard deviation):");
|
||||
entry.getValue().sort(Comparator.comparingDouble(evt -> evt.getTimeDto().avgTime));
|
||||
for (int i = 0; i < 20; i++) {
|
||||
content.append("\n");
|
||||
content.append(numberOfFeatures.get(i));
|
||||
content.append("=");
|
||||
content.append("(");
|
||||
content.append(entry.getValue().get(i).getTimeDto().avgTime);
|
||||
content.append(", ");
|
||||
content.append(entry.getValue().get(i).getTimeDto().stdAbweichung);
|
||||
content.append(")");
|
||||
}
|
||||
content.append("\n\n\n");
|
||||
});
|
||||
System.out.println(content);
|
||||
}
|
||||
|
||||
private void printTable(String tablename, TaskType[] types) {
|
||||
final boolean addHorizontalLines = true;
|
||||
this.testedTasks.addAll(Arrays.asList(types));
|
||||
List<TaskResultEvent> eventList = this.events.stream().filter(ev -> Arrays.asList(types).contains(ev.getType())).collect(Collectors.toList());
|
||||
if (eventList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
System.out.println(tablename + ": ");
|
||||
|
||||
List<Size> sizes = eventList.stream().map(TaskResultEvent::getImageSize).distinct().collect(Collectors.toList());
|
||||
if (sizes.size() != 10 && sizes.size() != 5) {// currently only 5 or 10 elements
|
||||
// throw new RuntimeException(sizes.size() + "");
|
||||
}
|
||||
StringBuilder headline = new StringBuilder();
|
||||
StringBuilder content = new StringBuilder();
|
||||
buildDividedTable(addHorizontalLines, eventList, sizes, headline, content);
|
||||
StringBuilder table = new StringBuilder();
|
||||
table.append("\\begin{tabular}{|l|rr|rr|rr|rr|rr|}\n\\hline\n");
|
||||
table.append(headline.toString());
|
||||
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,
|
||||
StringBuilder content) {
|
||||
|
||||
// buildHeadline(sizes, headline);
|
||||
// buildContent(addHorizontalLines, eventList, sizes, content);
|
||||
}
|
||||
|
||||
private void buildContent(boolean addHorizontalLines, List<TaskResultEvent> eventList, List<Size> sizes, StringBuilder content) {
|
||||
Map<TaskType, List<TaskResultEvent>> mappedEvents = new EnumMap<>(TaskType.class);
|
||||
for (TaskResultEvent event : eventList) {
|
||||
mappedEvents.computeIfAbsent(event.getType(), k -> new ArrayList<>()).add(event);
|
||||
}
|
||||
|
||||
mappedEvents.entrySet().stream().sorted(Comparator.comparingInt(entry -> entry.getKey().ordinal())).forEach(entry -> {
|
||||
content.append(entry.getKey().getTitle());
|
||||
entry.getValue().sort(Comparator.comparingDouble(evt -> evt.getImageSize().area()));
|
||||
for (int i = 0; i < 5; i++) {
|
||||
content.append(" & ");
|
||||
content.append(((int) (entry.getValue().get(i).getTimeDto().avgTime * 10)) / 10.0);
|
||||
content.append(" & ");
|
||||
content.append(((int) (entry.getValue().get(i).getTimeDto().stdAbweichung * 10)) / 10.0);
|
||||
}
|
||||
if (sizes.size() == 10) {
|
||||
content.append(LATEX_TABLE_END_OF_LINE);
|
||||
for (int i = 5; i < 10; i++) {
|
||||
content.append(" & ");
|
||||
content.append(((int) (entry.getValue().get(i).getTimeDto().avgTime * 10)) / 10.0);
|
||||
content.append(" & ");
|
||||
content.append(((int) (entry.getValue().get(i).getTimeDto().stdAbweichung * 10)) / 10.0);
|
||||
}
|
||||
}
|
||||
content.append(LATEX_TABLE_END_OF_LINE);
|
||||
if (addHorizontalLines) {
|
||||
content.append(HLINE_LINEBREAK);
|
||||
}
|
||||
});
|
||||
if (!addHorizontalLines) {
|
||||
content.append(HLINE_LINEBREAK);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildHeadline(List<Size> sizes, StringBuilder headline) {
|
||||
headline.append("Task");
|
||||
// appendHeadlineRow(sizes, headline, 0);
|
||||
if (sizes.size() == 10) {
|
||||
headline.append(LATEX_TABLE_END_OF_LINE);
|
||||
// appendHeadlineRow(sizes, headline, 5);
|
||||
}
|
||||
headline.append(LATEX_TABLE_END_OF_LINE);
|
||||
// appendAvgAndSigmaRow(headline);
|
||||
}
|
||||
|
||||
private void appendAvgAndSigmaRow(StringBuilder headline) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
headline.append(" & ");
|
||||
headline.append("\\multicolumn{1}{c}{");
|
||||
headline.append("$\\overline{\\mbox{time}}$");
|
||||
headline.append("}");
|
||||
headline.append(" & ");
|
||||
headline.append("\\multicolumn{1}{c|}{");
|
||||
headline.append("$\\sigma$");
|
||||
headline.append("}");
|
||||
}
|
||||
headline.append("\\\\\n\\hline\n");
|
||||
}
|
||||
|
||||
private void appendHeadlineRow(List<Size> sizes, StringBuilder headline, int index) {
|
||||
for (int i = index; i < index + 5; i++) {
|
||||
headline.append(" & ");
|
||||
headline.append("\\multicolumn{2}{c|}{");
|
||||
headline.append(sizes.get(i).toString());
|
||||
headline.append("}");
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Initializer {
|
||||
new EventHandler();
|
||||
|
||||
LOG.info("loading and verifying test images");
|
||||
Mat[] images = ImageLoader.getTestImages();
|
||||
Mat[] images = ImageLoader.getLargeImageDataset();
|
||||
if (Arrays.stream(images).anyMatch(Mat::empty)) {
|
||||
throw new RuntimeException("invalid test images");
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CPUColoring {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.cvtColor(image, gray, Imgproc.COLOR_BGR2GRAY), PixelWiseTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "Grayscaling the image of size " + image.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "Grayscaling the image of size " + image.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PixelWiseTask.TEST_RUNS, image.size(), TaskType.CPU_GRAYSCALE, time));
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CPUEdgeDetection {
|
||||
|
||||
// HighGui.imshow("CPU edges", edges);
|
||||
// HighGui.waitKey();
|
||||
LOG.info(() -> "cpu execution time for image of size " + img.size() + ": " + time + "ms");
|
||||
LOG.info(() -> "cpu execution time for image of size " + img.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", ImgProcTask.TEST_RUNS, img.size(), TaskType.CPU_CANNY, time));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CPUFiltering {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.medianBlur(img, dst, 15), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "median filter on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "median filter on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.CPU_MEDIAN_BLUR, time));
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CPUFiltering {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.GaussianBlur(img, dst, size, 0, 0), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gaussian filter on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "gaussian filter on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.CPU_GAUSSIAN_BLUR, time));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ public class CPUMorph {
|
||||
Mat kernel = Imgproc.getStructuringElement(Imgproc.CV_SHAPE_RECT, new Size(15, 15));
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.dilate(img, dst, kernel), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "dilate on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "dilate on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.CPU_DILATE, time));
|
||||
|
||||
TimeDto time2 = TimingService.testPerformance(() -> Imgproc.erode(img, dst, kernel), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "erode on size: " + img.size() + " took " + time2 + "ms");
|
||||
LOG.info(() -> "erode on size: " + img.size() + " took " + time2);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.CPU_ERODE, time2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ public class CPUStereoMatching {
|
||||
|
||||
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");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "cpu stereo matching of image size " + leftImage.size() + " took: " + time);
|
||||
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);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CPUThresholding {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> Imgproc.threshold(mat, res, 128, 255, Imgproc.THRESH_BINARY), PixelWiseTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "thresholding image from size " + mat.size() + " took " + time + "ms.");
|
||||
LOG.info(() -> "thresholding image from size " + mat.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PixelWiseTask.TEST_RUNS, mat.size(), TaskType.CPU_THRESHOLD, time));
|
||||
// Mat show = new Mat();
|
||||
// Imgproc.resize(mat, show, new Size(1000, 662));
|
||||
|
||||
@@ -33,9 +33,7 @@ public class CpuFeatureTask {
|
||||
orb.detectAndCompute(image, mask, imageKeypoints, imageDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "skyscraper image cpu feature detection time for images of size " + image.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.CPU_FEATURE_DETECTION1, time));
|
||||
}
|
||||
|
||||
@@ -50,9 +48,7 @@ public class CpuFeatureTask {
|
||||
orb.detectAndCompute(image, mask, imageKeypoints, imageDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "motorcycle image cpu feature detection time for images of size " + image.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.CPU_FEATURE_DETECTION2, time));
|
||||
}
|
||||
|
||||
@@ -75,7 +71,7 @@ public class CpuFeatureTask {
|
||||
matcher.match(testDescriptors, imageDescriptors, matches);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "cpu feature matching time for " + imageKeypoints.toArray().length + " features in image of size " + image.size() + ": " + time + "ms");
|
||||
LOG.info(() -> "cpu feature matching time for " + imageKeypoints.toArray().length + " features in image of size " + image.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.CPU_FEATURE_MATCHING, time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GPUColoring {
|
||||
gpuImg.upload(javacvMat);
|
||||
time = TimingService.testPerformance(() -> opencv_cudaimgproc.cvtColor(gpuImg, grayImg, opencv_imgproc.COLOR_BGR2GRAY), PixelWiseTask.TEST_RUNS);
|
||||
}
|
||||
LOG.info(() -> "Grayscaling the image of size " + image.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "Grayscaling the image of size " + image.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PixelWiseTask.TEST_RUNS, image.size(), TaskType.GPU_GRAYSCALE, time));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class GPUEdgeDetection {
|
||||
// opencv_highgui.waitKey();
|
||||
}
|
||||
|
||||
LOG.info(() -> "gpu execution time for image of size " + img.size() + ": " + time + "ms");
|
||||
LOG.info(() -> "gpu execution time for image of size " + img.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", ImgProcTask.TEST_RUNS, img.size(), TaskType.GPU_CANNY, time));
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class GPUFiltering {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> filter.apply(gpuImg, dst), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "median filter on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "median filter on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.GPU_MEDIAN_BLUR, time));
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class GPUFiltering {
|
||||
|
||||
TimeDto time = TimingService.testPerformance(() -> filter.apply(gpuImg, dst), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gaussian filter on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "gaussian filter on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.GPU_GAUSSIAN_BLUR, time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,12 @@ public class GPUMorph {
|
||||
// Mat kernel = Imgproc.getStructuringElement(Imgproc.CV_SHAPE_RECT, new Size(15, 15));
|
||||
TimeDto time = TimingService.testPerformance(() -> filter.apply(src, dst), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "dilate on size: " + img.size() + " took " + time + "ms");
|
||||
LOG.info(() -> "dilate on size: " + img.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.GPU_DILATE, time));
|
||||
|
||||
TimeDto time2 = TimingService.testPerformance(() -> filter2.apply(src, dst), KernelTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "erode on size: " + img.size() + " took " + time2 + "ms");
|
||||
LOG.info(() -> "erode on size: " + img.size() + " took " + time2);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", KernelTask.TEST_RUNS, img.size(), TaskType.GPU_ERODE, time2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ public class GPUStereoMatching {
|
||||
|
||||
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");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "gpu stereo matching of image size " + leftImage.size() + " took: " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, leftImage.size(), TaskType.GPU_STEREO_MATCHING, time));
|
||||
|
||||
// Just for debugging
|
||||
|
||||
@@ -37,7 +37,7 @@ public class GPUThresholding {
|
||||
TimeDto time = TimingService.testPerformance(() -> opencv_cudaarithm.threshold(src, dst, 128, 255, opencv_imgproc.THRESH_BINARY),
|
||||
PixelWiseTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "thresholding image from size " + mat.size() + " took " + time + "ms.");
|
||||
LOG.info(() -> "thresholding image from size " + mat.size() + " took " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PixelWiseTask.TEST_RUNS, mat.size(), TaskType.GPU_THRESHOLD, time));
|
||||
// dst.download(javacvMat);
|
||||
// opencv_highgui.imshow("GPU result", javacvMat);
|
||||
|
||||
@@ -47,9 +47,7 @@ public class GpuFeatureTask {
|
||||
orb.detectAndCompute(gpuImg, mask, keypoints, imgDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "skyscraper image 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));
|
||||
}
|
||||
|
||||
@@ -71,9 +69,7 @@ public class GpuFeatureTask {
|
||||
orb.detectAndCompute(gpuImg, mask, keypoints, imgDescriptors);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu detection time for images of size " + image.size() + ": " + time + "ms");
|
||||
System.out.println("avg time: " + time.avgTime);
|
||||
System.out.println("standard abweichung: " + time.stdAbweichung);
|
||||
LOG.info(() -> "motorcycle image gpu detection time for images of size " + image.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.GPU_FEATURE_DETECTION2, time));
|
||||
}
|
||||
|
||||
@@ -104,7 +100,7 @@ public class GpuFeatureTask {
|
||||
matcher.match(testDescriptors, imgDescriptors, matches);
|
||||
}, FeatureBasedTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "gpu feature matching time for " + keypoints.size() + " features in image of size " + image.size() + ": " + time + "ms");
|
||||
LOG.info(() -> "gpu feature matching time for " + keypoints.size() + " features in image of size " + image.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", FeatureBasedTask.TEST_RUNS, image.size(), TaskType.GPU_FEATURE_MATCHING, time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.opencv.core.Mat;
|
||||
|
||||
import de.unidue.nes.gpu.GpuTestSystem;
|
||||
import de.unidue.nes.gpu.tasks.Task;
|
||||
import de.unidue.nes.gpu.utils.ImageLoader;
|
||||
import de.unidue.nes.gpu.utils.MatConverter;
|
||||
import de.unidue.nes.gpu.utils.TimingService;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class ConvertingTask implements Task {
|
||||
|
||||
@Override
|
||||
public void runTask() {
|
||||
Mat[] imgs = ImageLoader.getTestImages();
|
||||
// Mat[] imgs = ImageLoader.getTestImages();
|
||||
|
||||
// Arrays.stream(imgs).forEach(this::testConverter);
|
||||
// Arrays.stream(imgs).forEach(this::testCopyConvert);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CpuPipeline {
|
||||
Imgproc.Canny(edges, edges, 35, 100);
|
||||
}, PipelineTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> " canny pipeline cpu execution time for image of size " + img.size() + ": " + time + "ms");
|
||||
LOG.info(() -> " canny pipeline cpu execution time for image of size " + img.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PipelineTask.TEST_RUNS, img.size(), TaskType.CPU_CANNY_PIPELINE, time));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CpuPipeline {
|
||||
// HighGui.imshow("cpu", disparity);
|
||||
// HighGui.waitKey();
|
||||
|
||||
LOG.info(() -> " stereo pipeline cpu execution time for image of size " + images[0].size() + ": " + time + "ms");
|
||||
LOG.info(() -> " stereo pipeline cpu execution time for image of size " + images[0].size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PipelineTask.TEST_RUNS, images[0].size(), TaskType.CPU_STEREO_PIPELINE, time));
|
||||
}
|
||||
}
|
||||
|
||||
+22
-40
@@ -1,5 +1,9 @@
|
||||
package de.unidue.nes.gpu.tasks.taskdefinitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.opencv.core.Mat;
|
||||
@@ -28,56 +32,34 @@ public class FeatureBasedTask implements Task {
|
||||
Mat[][] stereoimages = ImageLoader.getStereoImages();
|
||||
Mat[] featureimages = ImageLoader.getFeatureImages();
|
||||
|
||||
// Stream.concat(Arrays.stream(stereoimages).flatMap(Stream::of), Arrays.stream(featureimages))
|
||||
// .forEach(mat -> Imgproc.cvtColor(mat, mat, 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();
|
||||
|
||||
Mat skyscraper = featureimages[0];
|
||||
Mat left = stereoimages[0][0];
|
||||
Mat right = stereoimages[0][1];
|
||||
for (int i = 0; i < featureimages.length; i += 2) {
|
||||
final int index = i;
|
||||
if (!featureimages[index].size().equals(featureimages[index + 1].size())) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
Imgproc.resize(left, left, skyscraper.size());
|
||||
Imgproc.resize(right, right, skyscraper.size());
|
||||
LOG.info(() -> "Image sizes: " + featureimages[index].size() + ", " + featureimages[index + 1].size());
|
||||
|
||||
Imgproc.cvtColor(skyscraper, skyscraper, Imgproc.COLOR_BGR2GRAY);
|
||||
Imgproc.cvtColor(left, left, Imgproc.COLOR_BGR2GRAY);
|
||||
Imgproc.cvtColor(right, right, Imgproc.COLOR_BGR2GRAY);
|
||||
cpuTask.detectAndCompute1(featureimages[index]);
|
||||
cpuTask.detectAndCompute2(featureimages[i + 1]);
|
||||
gpuTask.detectAndCompute1(featureimages[index]);
|
||||
gpuTask.detectAndCompute2(featureimages[i + 1]);
|
||||
}
|
||||
|
||||
System.out.println("CPU skyscraper image");
|
||||
cpuTask.detectAndCompute1(skyscraper);
|
||||
System.out.println("CPU motorcycle image");
|
||||
cpuTask.detectAndCompute2(left);
|
||||
System.out.println("GPU skyscraper image");
|
||||
gpuTask.detectAndCompute1(skyscraper);
|
||||
System.out.println("GPU motorcycle image");
|
||||
gpuTask.detectAndCompute2(left);
|
||||
Arrays.stream(stereoimages).forEach(arr -> cpuStereo.matchImages(arr[0], arr[1]));
|
||||
Arrays.stream(stereoimages).forEach(arr -> gpuStereo.matchImages(arr[0], arr[1]));
|
||||
|
||||
System.out.println("CPU stereo matching");
|
||||
cpuStereo.matchImages(left, right);
|
||||
System.out.println("GPU stereo matching");
|
||||
gpuStereo.matchImages(left, right);
|
||||
|
||||
// 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(stereoimages).forEach(arr -> cpuStereo.matchImages(arr[0], arr[1]));
|
||||
// Arrays.stream(stereoimages).forEach(arr -> gpuStereo.matchImages(arr[0], arr[1]));
|
||||
|
||||
// Mat matchingImage = stereoimages[4][0];
|
||||
// IntStream.iterate(500, i -> true, i -> i + 500).limit(20).forEach(i -> cpuTask.match(matchingImage, i));
|
||||
// IntStream.iterate(500, i -> true, i -> i + 500).limit(20).forEach(i -> gpuTask.match(matchingImage, i));
|
||||
Mat matchingImage = stereoimages[2][0];
|
||||
IntStream.iterate(500, i -> true, i -> i + 500).limit(20).forEach(i -> cpuTask.match(matchingImage, i));
|
||||
IntStream.iterate(500, i -> true, i -> i + 500).limit(20).forEach(i -> gpuTask.match(matchingImage, i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GpuPipeline {
|
||||
edges.download(res);
|
||||
}, PipelineTask.TEST_RUNS);
|
||||
|
||||
LOG.info(() -> "canny pipeline gpu execution time for image of size " + img.size() + ": " + time + "ms");
|
||||
LOG.info(() -> "canny pipeline gpu execution time for image of size " + img.size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PipelineTask.TEST_RUNS, img.size(), TaskType.GPU_CANNY_PIPELINE, time));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GpuPipeline {
|
||||
matcher.compute(leftGray, rightGray, disparity);
|
||||
disparity.download(result);
|
||||
}, PipelineTask.TEST_RUNS);
|
||||
LOG.info(() -> " stereo pipeline gpu execution time for image of size " + images[0].size() + ": " + time + "ms");
|
||||
LOG.info(() -> " stereo pipeline gpu execution time for image of size " + images[0].size() + ": " + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("", PipelineTask.TEST_RUNS, images[0].size(), TaskType.GPU_STEREO_PIPELINE, time));
|
||||
|
||||
// Debugging
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
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.CPUHistogramming;
|
||||
import de.unidue.nes.gpu.tasks.gputasks.GPUHistogramming;
|
||||
import de.unidue.nes.gpu.utils.ImageLoader;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
@@ -26,11 +20,11 @@ public class HistogramTask implements Task {
|
||||
|
||||
@Override
|
||||
public void runTask() {
|
||||
Mat[] images = ImageLoader.getTestImages();
|
||||
Arrays.stream(images).forEach(img -> Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY));
|
||||
|
||||
Arrays.stream(images).forEach(this.cpuTask::calcHistogram);
|
||||
Arrays.stream(images).forEach(this.gpuTask::calcHistogram);
|
||||
// Mat[] images = ImageLoader.getTestImages();
|
||||
// Arrays.stream(images).forEach(img -> Imgproc.cvtColor(img, img, Imgproc.COLOR_BGR2GRAY));
|
||||
//
|
||||
// Arrays.stream(images).forEach(this.cpuTask::calcHistogram);
|
||||
// Arrays.stream(images).forEach(this.gpuTask::calcHistogram);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,9 +13,7 @@ public class ImgProcTask implements Task {
|
||||
@Override
|
||||
public void runTask() {
|
||||
EdgeDetectionTask edgeTask = new EdgeDetectionTask();
|
||||
HoughCircleTask circleTask = new HoughCircleTask();
|
||||
edgeTask.runTask();
|
||||
// circleTask.runTask();//TODO: takes forever to test :(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ public class PageLockedUploadDownloadTask implements Task {
|
||||
private void testUpload(Mat m) {
|
||||
try (GpuMat gpuMat = new GpuMat()) {
|
||||
TimeDto time = TimingService.testPerformance(() -> gpuMat.upload(m), ITERATIONS);
|
||||
LOG.info(() -> "uploading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time + MS);
|
||||
LOG.info(() -> "uploading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time);
|
||||
GpuEventBus.INSTANCE
|
||||
.post(new TaskResultEvent("uploading Mat of size " + getSizeOfMat(m), ITERATIONS, getSizeOfMat(m), TaskType.PAGE_LOCKED_GPU_UPLOAD, time));
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class PageLockedUploadDownloadTask implements Task {
|
||||
try (GpuMat gpuMat = new GpuMat(); Mat res = new Mat()) {
|
||||
gpuMat.upload(m);
|
||||
TimeDto time = TimingService.testPerformance(() -> gpuMat.download(res), ITERATIONS);
|
||||
LOG.info(() -> "downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time + MS);
|
||||
LOG.info(() -> "downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time);
|
||||
GpuEventBus.INSTANCE.post(
|
||||
new TaskResultEvent(time, "downloading Mat of size " + getSizeOfMat(m), ITERATIONS, getSizeOfMat(m), TaskType.PAGE_LOCKED_GPU_DOWNLOAD));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package de.unidue.nes.gpu.tasks.taskdefinitions;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
|
||||
import de.unidue.nes.gpu.tasks.Task;
|
||||
import de.unidue.nes.gpu.tasks.cputasks.CPUResizing;
|
||||
import de.unidue.nes.gpu.tasks.gputasks.GPUResizing;
|
||||
import de.unidue.nes.gpu.utils.ImageLoader;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
@@ -27,24 +21,24 @@ public class ResizingTask implements Task {
|
||||
@Override
|
||||
public void runTask() {
|
||||
|
||||
Mat[] images = ImageLoader.getTestImages();
|
||||
Size[] sizes = Arrays.stream(images).map(Mat::size).toArray(Size[]::new);
|
||||
|
||||
for (int i = 0; i < images.length; i++) {
|
||||
for (int j = 0; j < images.length; j++) {
|
||||
if (i != j) {
|
||||
this.cpuTask.resize(images[i], sizes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < images.length; i++) {
|
||||
for (int j = 0; j < images.length; j++) {
|
||||
if (i != j) {
|
||||
this.gpuTask.resize(images[i], sizes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Mat[] images = ImageLoader.getTestImages();
|
||||
// Size[] sizes = Arrays.stream(images).map(Mat::size).toArray(Size[]::new);
|
||||
//
|
||||
// for (int i = 0; i < images.length; i++) {
|
||||
// for (int j = 0; j < images.length; j++) {
|
||||
// if (i != j) {
|
||||
// this.cpuTask.resize(images[i], sizes[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < images.length; i++) {
|
||||
// for (int j = 0; j < images.length; j++) {
|
||||
// if (i != j) {
|
||||
// this.gpuTask.resize(images[i], sizes[j]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -49,7 +49,7 @@ public class UploadDownloadTask implements Task {
|
||||
try (GpuMat gpuMat = new GpuMat()) {
|
||||
TimeDto time = TimingService.testPerformance(() -> gpuMat.upload(m), ITERATIONS);
|
||||
// long time = TimingService.measureTime(() -> gpuMat.upload(m), ITERATIONS);
|
||||
LOG.info(() -> "uploading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time + MS);
|
||||
LOG.info(() -> "uploading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time);
|
||||
GpuEventBus.INSTANCE.post(new TaskResultEvent("uploading Mat of size " + getSizeOfMat(m), ITERATIONS, getSizeOfMat(m), TaskType.GPU_UPLOAD, time));
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class UploadDownloadTask implements Task {
|
||||
try (GpuMat gpuMat = new GpuMat(); Mat res = new Mat()) {
|
||||
gpuMat.upload(m);
|
||||
TimeDto time = TimingService.testPerformance(() -> gpuMat.download(res), ITERATIONS);
|
||||
LOG.info(() -> "downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time + MS);
|
||||
LOG.info(() -> "downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time);
|
||||
GpuEventBus.INSTANCE
|
||||
.post(new TaskResultEvent("downloading Mat of size " + getSizeOfMat(m), ITERATIONS, getSizeOfMat(m), TaskType.GPU_DOWNLOAD, time));
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class UploadDownloadTask implements Task {
|
||||
gpuMat.upload(m);
|
||||
gpuMat.download(m);
|
||||
}, ITERATIONS);
|
||||
LOG.info(() -> "uploading and downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time + MS);
|
||||
LOG.info(() -> "uploading and downloading" + MAT_OF_SIZE + getSizeOfMat(m) + TOOK + time);
|
||||
GpuEventBus.INSTANCE.post(
|
||||
new TaskResultEvent("uploading and downloading Mat of size " + getSizeOfMat(m), ITERATIONS, getSizeOfMat(m), TaskType.GPU_COMBINED, time));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
/**
|
||||
* @author Roch P., Shahbaz Nejad B.
|
||||
@@ -16,14 +18,7 @@ public class ImageLoader {
|
||||
private ImageLoader() {
|
||||
}
|
||||
|
||||
public static Mat[] getTestImages() {
|
||||
return Arrays.stream(getStereoImages()).map(arr -> arr[0]).collect(Collectors.toList()).toArray(Mat[]::new);
|
||||
// return new Mat[] { Imgcodecs.imread("src/main/resources/skyscraper_small.jpg"), Imgcodecs.imread("src/main/resources/skyscraper_medium_small.jpg"),
|
||||
// Imgcodecs.imread("src/main/resources/skyscraper_medium.jpg"), Imgcodecs.imread("src/main/resources/skyscraper_medium_large.jpg"),
|
||||
// Imgcodecs.imread("src/main/resources/skyscraper_large.jpg") };
|
||||
}
|
||||
|
||||
public static Mat[][] getStereoImages() {
|
||||
public static Mat[][] getAllStereoImages() {
|
||||
return new Mat[][] { { Imgcodecs.imread("src/main/resources/left_small.png"), Imgcodecs.imread("src/main/resources/right_small.png") },
|
||||
{ Imgcodecs.imread("src/main/resources/left_medium_small.png"), Imgcodecs.imread("src/main/resources/right_medium_small.png") },
|
||||
{ Imgcodecs.imread("src/main/resources/left_medium.png"), Imgcodecs.imread("src/main/resources/right_medium.png") },
|
||||
@@ -32,35 +27,83 @@ public class ImageLoader {
|
||||
}
|
||||
|
||||
public static Mat[] getTestImagesForPixelWiseOperations() {
|
||||
return getLargeImageDataset();
|
||||
return getReducedDataset();
|
||||
}
|
||||
|
||||
public static Mat[] getUploadDownloadTestImages() {
|
||||
return getLargeImageDataset();
|
||||
}
|
||||
|
||||
private static Mat[] getLargeImageDataset() {
|
||||
public static Mat[] getLargeImageDataset() {
|
||||
return Stream
|
||||
.concat(Arrays.stream(getStereoImages()).map(arr -> arr[0]), Stream.of(Imgcodecs.imread("src/main/resources/skyscraper_small.jpg"),
|
||||
.concat(Arrays.stream(getAllStereoImages()).map(arr -> arr[0]), Stream.of(Imgcodecs.imread("src/main/resources/skyscraper_small.jpg"),
|
||||
Imgcodecs.imread("src/main/resources/skyscraper_medium_small.jpg"), Imgcodecs.imread("src/main/resources/skyscraper_medium.jpg"),
|
||||
Imgcodecs.imread("src/main/resources/skyscraper_medium_large.jpg"), Imgcodecs.imread("src/main/resources/skyscraper_large.jpg")))
|
||||
.sorted(Comparator.comparingDouble(mat -> mat.size().area())).collect(Collectors.toList()).toArray(Mat[]::new);
|
||||
|
||||
}
|
||||
|
||||
private static Mat[] getReducedDataset() {
|
||||
Mat[] allImages = getLargeImageDataset();
|
||||
Mat[] newImages = new Mat[3];
|
||||
newImages[0] = new Mat();
|
||||
allImages[0].copyTo(newImages[0]);
|
||||
newImages[1] = new Mat();
|
||||
allImages[3].copyTo(newImages[1]);
|
||||
newImages[2] = new Mat();
|
||||
allImages[9].copyTo(newImages[2]);
|
||||
return newImages;
|
||||
}
|
||||
|
||||
public static Mat[] getTestImagesForKernelOperations() {
|
||||
return getLargeImageDataset();
|
||||
return getReducedDataset();
|
||||
}
|
||||
|
||||
public static Mat[] getImgprocImages() {
|
||||
return getLargeImageDataset();
|
||||
return getReducedDataset();
|
||||
}
|
||||
|
||||
public static Mat[] getTestImagesForPipeline() {
|
||||
return getLargeImageDataset();
|
||||
public static Mat[] getTestImagesForCannyPipeline() {
|
||||
Mat lowestRes = Imgcodecs.imread("src/main/resources/skyscraper_small.jpg");
|
||||
Mat highestRes = Imgcodecs.imread("src/main/resources/left_large.png");
|
||||
return new Mat[] { lowestRes, highestRes };
|
||||
}
|
||||
|
||||
public static Mat[] getFeatureImages() {
|
||||
return getLargeImageDataset();
|
||||
public static Mat[] getFeatureImages() {// image[i] skyscraper, image[i+1] motorcycle
|
||||
Mat skyscraperSmall = Imgcodecs.imread("src/main/resources/skyscraper_small.jpg");
|
||||
Mat motorcycleSmall = Imgcodecs.imread("src/main/resources/left_small.png");
|
||||
Imgproc.resize(motorcycleSmall, motorcycleSmall, new Size(350, 232));
|
||||
|
||||
Mat skyscraperMedium = Imgcodecs.imread("src/main/resources/skyscraper_medium.jpg");
|
||||
Mat motorcycleMedium = Imgcodecs.imread("src/main/resources/left_medium_small.png");
|
||||
Imgproc.resize(skyscraperMedium, skyscraperMedium, new Size(1482, 1000));
|
||||
|
||||
Mat skyscraperHigh = Imgcodecs.imread("src/main/resources/skyscraper_large.jpg");
|
||||
Mat motorcycleHigh = Imgcodecs.imread("src/main/resources/left_large.png");
|
||||
Imgproc.resize(skyscraperHigh, skyscraperHigh, new Size(3705, 2500));
|
||||
|
||||
return new Mat[] { skyscraperSmall, motorcycleSmall, skyscraperMedium, motorcycleMedium, skyscraperHigh, motorcycleHigh };
|
||||
}
|
||||
|
||||
public static Mat[][] getStereoImages() {
|
||||
Mat[] smallRes = new Mat[] { Imgcodecs.imread("src/main/resources/left_small.png"), Imgcodecs.imread("src/main/resources/right_small.png") };
|
||||
Imgproc.resize(smallRes[0], smallRes[0], new Size(350, 232));
|
||||
Imgproc.resize(smallRes[1], smallRes[1], new Size(350, 232));
|
||||
|
||||
Mat[] mediumRes = new Mat[] { Imgcodecs.imread("src/main/resources/left_medium_small.png"),
|
||||
Imgcodecs.imread("src/main/resources/right_medium_small.png") };
|
||||
Mat[] highRes = new Mat[] { Imgcodecs.imread("src/main/resources/left_large.png"), Imgcodecs.imread("src/main/resources/right_large.png") };
|
||||
|
||||
return new Mat[][] { smallRes, mediumRes, highRes };
|
||||
}
|
||||
|
||||
public static Mat[][] getStereoPipelineImages() {
|
||||
Mat[] smallRes = new Mat[] { Imgcodecs.imread("src/main/resources/left_small.png"), Imgcodecs.imread("src/main/resources/right_small.png") };
|
||||
Imgproc.resize(smallRes[0], smallRes[0], new Size(350, 232));
|
||||
Imgproc.resize(smallRes[1], smallRes[1], new Size(350, 232));
|
||||
|
||||
Mat[] highRes = new Mat[] { Imgcodecs.imread("src/main/resources/left_large.png"), Imgcodecs.imread("src/main/resources/right_large.png") };
|
||||
|
||||
return new Mat[][] { smallRes, highRes };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ public class TimeDto {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.avgTime + "";
|
||||
return "average: " + this.avgTime + "ms, sigma: " + this.stdAbweichung + "ms";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user