some refactoring changes
This commit is contained in:
+1
-1
@@ -36,7 +36,7 @@ public class DescriptorMatcher_create implements Task {
|
||||
case org.opencv.features2d.DescriptorMatcher.BRUTEFORCE_HAMMINGLUT:
|
||||
return opencv_core.NORM_HAMMING2;
|
||||
default:
|
||||
throw new RuntimeException();
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -21,21 +21,21 @@ public class DescriptorMatchers {
|
||||
|
||||
public static void addMatcher(DescriptorMatcher matcher, int id) {
|
||||
if (DESCRIPTOR_MATCHER_MAP.containsKey(id)) {
|
||||
throw new RuntimeException();
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
DESCRIPTOR_MATCHER_MAP.put(id, matcher);
|
||||
}
|
||||
|
||||
public static void addCudaMatcher(org.bytedeco.opencv.opencv_cudafeatures2d.DescriptorMatcher matcher, int id) {
|
||||
if (CUDA_DESCRIPTOR_MATCHER_MAP.containsKey(id)) {
|
||||
throw new RuntimeException();
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
CUDA_DESCRIPTOR_MATCHER_MAP.put(id, matcher);
|
||||
}
|
||||
|
||||
public static DescriptorMatcher getById(int id) {
|
||||
if (!DESCRIPTOR_MATCHER_MAP.containsKey(id)) {
|
||||
throw new RuntimeException();
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
return DESCRIPTOR_MATCHER_MAP.get(id);
|
||||
}
|
||||
|
||||
+1
-3
@@ -56,9 +56,7 @@ public class DrawMatches implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
Features2d.drawMatches(this.img1, this.keypoints1, this.img2, this.keypoints2, this.matches1to2, this.outImg);
|
||||
};
|
||||
return () -> Features2d.drawMatches(this.img1, this.keypoints1, this.img2, this.keypoints2, this.matches1to2, this.outImg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class DownloadTask implements Task {
|
||||
|
||||
@Override
|
||||
public void initDescription() {
|
||||
|
||||
// description is build in getDescription()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class GenericGpuTask implements GpuTask {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -67,7 +67,7 @@ public class CvtColor implements Task {
|
||||
} else if (CvtColor.this.numParams == 4) {
|
||||
Imgproc.cvtColor(CvtColor.this.src, CvtColor.this.dst, CvtColor.this.code, CvtColor.this.dstCn);
|
||||
} else {
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class CvtColor implements Task {
|
||||
} else if (CvtColor.this.numParams == 4) {
|
||||
opencv_cudaimgproc.cvtColor(this.gpuSrc, this.gpuDst, CvtColor.this.code, CvtColor.this.dstCn, null);
|
||||
} else {
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class CvtColor implements Task {
|
||||
} else if (this.numParams == 4) {
|
||||
this.descr = "Imgproc.cvtColor(" + Objects.toString(this.src) + ", " + Objects.toString(this.dst) + ", " + this.code + ", " + this.dstCn + ")";
|
||||
} else {
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -45,9 +45,7 @@ public class Dilate implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
Imgproc.dilate(this.src, this.dst, this.kernel);
|
||||
};
|
||||
return () -> Imgproc.dilate(this.src, this.dst, this.kernel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-3
@@ -46,9 +46,7 @@ public class Erode implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
Imgproc.erode(this.src, this.dst, this.kernel);
|
||||
};
|
||||
return () -> Imgproc.erode(this.src, this.dst, this.kernel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-3
@@ -42,9 +42,7 @@ public class FindContours implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
Imgproc.findContours(this.image, this.contours, this.hierarchy, this.mode, this.method);
|
||||
};
|
||||
return () -> Imgproc.findContours(this.image, this.contours, this.hierarchy, this.mode, this.method);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-3
@@ -22,6 +22,9 @@ import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
*/
|
||||
public class GaussianBlur implements Task {
|
||||
|
||||
private static final String GAUSSIAN_BLUR_PREFIX = "Imgproc.GaussianBlur(";
|
||||
private static final String COMMA = ", ";
|
||||
|
||||
private final int numParams;
|
||||
|
||||
private final Mat src;
|
||||
@@ -168,15 +171,15 @@ public class GaussianBlur implements Task {
|
||||
public void initDescription() {
|
||||
switch (this.numParams) {
|
||||
case 4:
|
||||
this.descr = "Imgproc.GaussianBlur(" + Objects.toString(this.src) + ", " + Objects.toString(this.dst) + ", " + Objects.toString(this.ksize) + ", "
|
||||
this.descr = GAUSSIAN_BLUR_PREFIX + Objects.toString(this.src) + COMMA + Objects.toString(this.dst) + COMMA + Objects.toString(this.ksize) + COMMA
|
||||
+ this.sigmaX + ")";
|
||||
break;
|
||||
case 5:
|
||||
this.descr = "Imgproc.GaussianBlur(" + Objects.toString(this.src) + ", " + Objects.toString(this.dst) + ", " + Objects.toString(this.ksize) + ", "
|
||||
this.descr = GAUSSIAN_BLUR_PREFIX + Objects.toString(this.src) + COMMA + Objects.toString(this.dst) + COMMA + Objects.toString(this.ksize) + COMMA
|
||||
+ this.sigmaX + +this.sigmaY + ")";
|
||||
break;
|
||||
case 6:
|
||||
this.descr = "Imgproc.GaussianBlur(" + Objects.toString(this.src) + ", " + Objects.toString(this.dst) + ", " + Objects.toString(this.ksize) + ", "
|
||||
this.descr = GAUSSIAN_BLUR_PREFIX + Objects.toString(this.src) + COMMA + Objects.toString(this.dst) + COMMA + Objects.toString(this.ksize) + COMMA
|
||||
+ this.sigmaX + +this.sigmaY + this.borderType + ")";
|
||||
break;
|
||||
default:
|
||||
|
||||
+1
-3
@@ -27,9 +27,7 @@ public class GetStructuringElement implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
Imgproc.getStructuringElement(this.shape, this.ksize);
|
||||
};
|
||||
return () -> Imgproc.getStructuringElement(this.shape, this.ksize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,24 +16,24 @@ import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
public class Clone implements Task {
|
||||
|
||||
private final Mat _this;
|
||||
private final Mat clone;
|
||||
private final Mat theClone;
|
||||
|
||||
private String descr = "";
|
||||
|
||||
public Clone(Mat _this) {
|
||||
this._this = _this;
|
||||
this.clone = _this.clone();
|
||||
this.theClone = _this.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
this._this.copyTo(this.clone);
|
||||
return () -> this._this.clone();
|
||||
this._this.copyTo(this.theClone);
|
||||
return this._this::clone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpuTask toGpuTask() {
|
||||
this._this.copyTo(this.clone);
|
||||
this._this.copyTo(this.theClone);
|
||||
|
||||
return new GpuTask() {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Clone implements Task {
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
|
||||
// Nothing to clean up
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -63,11 +63,11 @@ public class Clone implements Task {
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
// Nothing to reset
|
||||
}
|
||||
|
||||
public Mat getClone() {
|
||||
return this.clone;
|
||||
return this.theClone;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+9
-6
@@ -13,6 +13,9 @@ import de.unidue.nes.gpu.testframework.tasks.Task;
|
||||
*/
|
||||
public class ConvertTo implements Task {
|
||||
|
||||
private static final String CONVERT_TO = ".convertTo(";
|
||||
private static final String COMMA = ", ";
|
||||
|
||||
private final int numParams;
|
||||
|
||||
private final Mat _this;
|
||||
@@ -88,7 +91,7 @@ public class ConvertTo implements Task {
|
||||
this._this.convertTo(this.m, this.rtype, this.alpha, this.beta);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -114,7 +117,7 @@ public class ConvertTo implements Task {
|
||||
this.gpu_this.convertTo(this.gpuM, ConvertTo.this.rtype, ConvertTo.this.alpha, ConvertTo.this.beta);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,16 +149,16 @@ public class ConvertTo implements Task {
|
||||
public void initDescription() {
|
||||
switch (this.numParams) {
|
||||
case 3:
|
||||
this.descr = this._this + ".convertTo(" + this.m + ", " + this.rtype + ")";
|
||||
this.descr = this._this + CONVERT_TO + this.m + COMMA + this.rtype + ")";
|
||||
break;
|
||||
case 4:
|
||||
this.descr = this._this + ".convertTo(" + this.m + ", " + this.rtype + ", " + this.alpha + ")";
|
||||
this.descr = this._this + CONVERT_TO + this.m + COMMA + this.rtype + COMMA + this.alpha + ")";
|
||||
break;
|
||||
case 5:
|
||||
this.descr = this._this + ".convertTo(" + this.m + ", " + this.rtype + ", " + this.alpha + ", " + this.beta + ")";
|
||||
this.descr = this._this + CONVERT_TO + this.m + COMMA + this.rtype + COMMA + this.alpha + COMMA + this.beta + ")";
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException();
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -36,9 +36,7 @@ public class CopyTo implements Task {
|
||||
|
||||
@Override
|
||||
public CpuTask toCpuTask() {
|
||||
return () -> {
|
||||
this._this.copyTo(this.m);
|
||||
};
|
||||
return () -> this._this.copyTo(this.m);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class DebugTask implements Task {
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
// Nothing to reset when debugging
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user