mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 06:10:02 +08:00
Java API: fixing more tests
This commit is contained in:
parent
2e7a9041a7
commit
bb870a8270
@ -1,8 +1,11 @@
|
||||
package org.opencv.test.features2d;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.FeatureDetector;
|
||||
@ -10,10 +13,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
FeatureDetector detector;
|
||||
@ -56,11 +55,11 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
public void testDetectMatListOfKeyPoint() {
|
||||
Mat img = getTestImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(img, keypoints);
|
||||
|
||||
assertListKeyPointEquals(Arrays.asList(truth), keypoints, EPS);
|
||||
assertListKeyPointEquals(Arrays.asList(truth), keypoints.toList(), EPS);
|
||||
|
||||
// OpenCVTestRunner.Log("points found: " + keypoints.size());
|
||||
// for (KeyPoint kp : keypoints)
|
||||
@ -70,11 +69,11 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
public void testDetectMatListOfKeyPointMat() {
|
||||
Mat img = getTestImg();
|
||||
Mat mask = getMaskImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(img, keypoints, mask);
|
||||
|
||||
assertListKeyPointEquals(Arrays.asList(truth[0], truth[1]), keypoints, EPS);
|
||||
assertListKeyPointEquals(Arrays.asList(truth[0], truth[1]), keypoints.toList(), EPS);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
@ -87,18 +86,18 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
writeFile(filename, "%YAML:1.0\nthreshold: 130\nnonmaxSuppression: 1\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints1 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(grayChess, keypoints1);
|
||||
|
||||
writeFile(filename, "%YAML:1.0\nthreshold: 150\nnonmaxSuppression: 1\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints2 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(grayChess, keypoints2);
|
||||
|
||||
assertTrue(keypoints2.size() <= keypoints1.size());
|
||||
assertTrue(keypoints2.total() <= keypoints1.total());
|
||||
}
|
||||
|
||||
public void testReadYml() {
|
||||
@ -108,7 +107,7 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<threshold>130</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n</opencv_storage>\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints1 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(grayChess, keypoints1);
|
||||
|
||||
@ -116,11 +115,11 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
"<?xml version=\"1.0\"?>\n<opencv_storage>\n<threshold>150</threshold>\n<nonmaxSuppression>1</nonmaxSuppression>\n</opencv_storage>\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints2 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(grayChess, keypoints2);
|
||||
|
||||
assertTrue(keypoints2.size() <= keypoints1.size());
|
||||
assertTrue(keypoints2.total() <= keypoints1.total());
|
||||
}
|
||||
|
||||
public void testWrite() {
|
||||
|
@ -1,9 +1,14 @@
|
||||
package org.opencv.test.features2d;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvException;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.DMatch;
|
||||
@ -14,10 +19,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
|
||||
static final String xmlParamsDefault = "<?xml version=\"1.0\"?>\n"
|
||||
@ -109,7 +110,7 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
private Mat getBriefTestDescriptors(Mat img) {
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
FeatureDetector detector = FeatureDetector.create(FeatureDetector.FAST);
|
||||
@ -141,7 +142,7 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
|
||||
private Mat getQueryDescriptors() {
|
||||
Mat img = getQueryImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
FeatureDetector detector = FeatureDetector.create(FeatureDetector.SURF);
|
||||
@ -167,7 +168,7 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
|
||||
private Mat getTrainDescriptors() {
|
||||
Mat img = getTrainImg();
|
||||
List<KeyPoint> keypoints = Arrays.asList(new KeyPoint(50, 50, 16, 0, 20000, 1, -1), new KeyPoint(42, 42, 16, 160, 10000, 1, -1));
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint(new KeyPoint(50, 50, 16, 0, 20000, 1, -1), new KeyPoint(42, 42, 16, 160, 10000, 1, -1));
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
|
||||
@ -283,36 +284,36 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
public void testMatchMatListOfDMatch() {
|
||||
Mat train = getTrainDescriptors();
|
||||
Mat query = getQueryDescriptors();
|
||||
List<DMatch> matches = new ArrayList<DMatch>();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
matcher.add(Arrays.asList(train));
|
||||
matcher.train();
|
||||
|
||||
matcher.match(query, matches);
|
||||
|
||||
assertListDMatchEquals(Arrays.asList(truth), matches, EPS);
|
||||
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testMatchMatListOfDMatchListOfMat() {
|
||||
Mat train = getTrainDescriptors();
|
||||
Mat query = getQueryDescriptors();
|
||||
Mat mask = getMaskImg();
|
||||
List<DMatch> matches = new ArrayList<DMatch>();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
matcher.add(Arrays.asList(train));
|
||||
matcher.train();
|
||||
|
||||
matcher.match(query, matches, Arrays.asList(mask));
|
||||
|
||||
assertListDMatchEquals(Arrays.asList(truth), matches, EPS);
|
||||
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testMatchMatMatListOfDMatch() {
|
||||
Mat train = getTrainDescriptors();
|
||||
Mat query = getQueryDescriptors();
|
||||
List<DMatch> matches = new ArrayList<DMatch>();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
|
||||
matcher.match(query, train, matches);
|
||||
|
||||
assertListDMatchEquals(Arrays.asList(truth), matches, EPS);
|
||||
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
|
||||
|
||||
// OpenCVTestRunner.Log("matches found: " + matches.size());
|
||||
// for (DMatch m : matches)
|
||||
@ -323,11 +324,11 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
Mat train = getTrainDescriptors();
|
||||
Mat query = getQueryDescriptors();
|
||||
Mat mask = getMaskImg();
|
||||
List<DMatch> matches = new ArrayList<DMatch>();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
|
||||
matcher.match(query, train, matches, mask);
|
||||
|
||||
assertListDMatchEquals(Arrays.asList(truth), matches, EPS);
|
||||
assertListDMatchEquals(Arrays.asList(truth), matches.toList(), EPS);
|
||||
}
|
||||
|
||||
public void testRadiusMatchMatListOfListOfDMatchFloat() {
|
||||
@ -362,14 +363,15 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
|
||||
Mat train = getBriefTrainDescriptors();
|
||||
Mat query = getBriefQueryDescriptors();
|
||||
List<DMatch> matches = new ArrayList<DMatch>();
|
||||
MatOfDMatch matches = new MatOfDMatch();
|
||||
|
||||
matcher.match(query, train, matches);
|
||||
|
||||
assertListDMatchEquals(Arrays.asList(new DMatch(0, 0, 0, 0),
|
||||
assertArrayDMatchEquals(new DMatch[]{
|
||||
new DMatch(0, 0, 0, 0),
|
||||
new DMatch(1, 2, 0, 0),
|
||||
new DMatch(2, 1, 0, 0),
|
||||
new DMatch(3, 3, 0, 0)), matches, EPS);
|
||||
new DMatch(3, 3, 0, 0)}, matches.toArray(), EPS);
|
||||
}
|
||||
|
||||
public void testTrain() {
|
||||
|
@ -3,6 +3,7 @@ package org.opencv.test.features2d;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.DescriptorExtractor;
|
||||
@ -10,9 +11,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
DescriptorExtractor extractor;
|
||||
@ -40,7 +38,7 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
public void testComputeMatListOfKeyPointMat() {
|
||||
KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
|
||||
List<KeyPoint> keypoints = Arrays.asList(point);
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint(point);
|
||||
Mat img = getTestImg();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
@ -73,7 +71,7 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
public void testRead() {
|
||||
KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
|
||||
List<KeyPoint> keypoints = Arrays.asList(point);
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint(point);
|
||||
Mat img = getTestImg();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
|
@ -3,6 +3,7 @@ package org.opencv.test.features2d;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.DescriptorExtractor;
|
||||
@ -10,9 +11,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
DescriptorExtractor extractor;
|
||||
@ -50,7 +48,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testComputeMatListOfKeyPointMat() {
|
||||
List<KeyPoint> keypoints = Arrays.asList(keypoint);
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint(keypoint);
|
||||
Mat img = getTestImg();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
@ -76,7 +74,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRead() {
|
||||
List<KeyPoint> keypoints = Arrays.asList(keypoint);
|
||||
MatOfKeyPoint keypoints =new MatOfKeyPoint(keypoint);
|
||||
Mat img = getTestImg();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
package org.opencv.test.features2d;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.FeatureDetector;
|
||||
@ -10,10 +13,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class STARFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
FeatureDetector detector;
|
||||
@ -75,21 +74,21 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
public void testDetectMatListOfKeyPoint() {
|
||||
Mat img = getTestImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(img, keypoints);
|
||||
|
||||
assertListKeyPointEquals(Arrays.asList(truth), keypoints, EPS);
|
||||
assertListKeyPointEquals(Arrays.asList(truth), keypoints.toList(), EPS);
|
||||
}
|
||||
|
||||
public void testDetectMatListOfKeyPointMat() {
|
||||
Mat img = getTestImg();
|
||||
Mat mask = getMaskImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(img, keypoints, mask);
|
||||
|
||||
assertListKeyPointEquals(Arrays.asList(truth[0], truth[2], truth[5], truth[7]), keypoints, EPS);
|
||||
assertListKeyPointEquals(Arrays.asList(truth[0], truth[2], truth[5], truth[7]), keypoints.toList(), EPS);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
@ -99,17 +98,17 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
|
||||
public void testRead() {
|
||||
Mat img = getTestImg();
|
||||
|
||||
List<KeyPoint> keypoints1 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
detector.detect(img, keypoints1);
|
||||
|
||||
String filename = OpenCVTestRunner.getTempFileName("yml");
|
||||
writeFile(filename, "%YAML:1.0\nmaxSize: 45\nresponseThreshold: 150\nlineThresholdProjected: 10\nlineThresholdBinarized: 8\nsuppressNonmaxSize: 5\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints2 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
detector.detect(img, keypoints2);
|
||||
|
||||
assertTrue(keypoints2.size() <= keypoints1.size());
|
||||
assertTrue(keypoints2.total() <= keypoints1.total());
|
||||
}
|
||||
|
||||
public void testWrite() {
|
||||
|
@ -3,6 +3,7 @@ package org.opencv.test.features2d;
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.DescriptorExtractor;
|
||||
@ -10,9 +11,6 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SURFDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
DescriptorExtractor extractor;
|
||||
@ -40,7 +38,7 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
public void testComputeMatListOfKeyPointMat() {
|
||||
KeyPoint point = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
|
||||
List<KeyPoint> keypoints = Arrays.asList(point);
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint(point);
|
||||
Mat img = getTestImg();
|
||||
Mat descriptors = new Mat();
|
||||
|
||||
|
@ -1,21 +1,22 @@
|
||||
package org.opencv.test.features2d;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.FeatureDetector;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.FeatureDetector;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
FeatureDetector detector;
|
||||
@ -72,7 +73,7 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
writeFile(filename, "%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<List<KeyPoint>> keypoints = new ArrayList<List<KeyPoint>>();
|
||||
List<MatOfKeyPoint> keypoints = new ArrayList<MatOfKeyPoint>();
|
||||
Mat cross = getTestImg();
|
||||
List<Mat> crosses = new ArrayList<Mat>(3);
|
||||
crosses.add(cross);
|
||||
@ -83,7 +84,8 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
assertEquals(3, keypoints.size());
|
||||
|
||||
for (List<KeyPoint> lkp : keypoints) {
|
||||
for (MatOfKeyPoint mkp : keypoints) {
|
||||
List<KeyPoint> lkp = mkp.toList();
|
||||
order(lkp);
|
||||
assertListKeyPointEquals(Arrays.asList(truth), lkp, EPS);
|
||||
}
|
||||
@ -98,13 +100,14 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
writeFile(filename, "%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
Mat cross = getTestImg();
|
||||
|
||||
detector.detect(cross, keypoints);
|
||||
|
||||
order(keypoints);
|
||||
assertListKeyPointEquals(Arrays.asList(truth), keypoints, EPS);
|
||||
List<KeyPoint> lkp = keypoints.toList();
|
||||
order(lkp);
|
||||
assertListKeyPointEquals(Arrays.asList(truth), lkp, EPS);
|
||||
}
|
||||
|
||||
public void testDetectMatListOfKeyPointMat() {
|
||||
@ -114,12 +117,13 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
Mat img = getTestImg();
|
||||
Mat mask = getMaskImg();
|
||||
List<KeyPoint> keypoints = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
|
||||
detector.detect(img, keypoints, mask);
|
||||
|
||||
order(keypoints);
|
||||
assertListKeyPointEquals(Arrays.asList(truth[1], truth[2]), keypoints, EPS);
|
||||
List<KeyPoint> lkp = keypoints.toList();
|
||||
order(lkp);
|
||||
assertListKeyPointEquals(Arrays.asList(truth[1], truth[2]), lkp, EPS);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
@ -129,17 +133,17 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
public void testRead() {
|
||||
Mat cross = getTestImg();
|
||||
|
||||
List<KeyPoint> keypoints1 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints1 = new MatOfKeyPoint();
|
||||
detector.detect(cross, keypoints1);
|
||||
|
||||
String filename = OpenCVTestRunner.getTempFileName("yml");
|
||||
writeFile(filename, "%YAML:1.0\nhessianThreshold: 8000.\noctaves: 3\noctaveLayers: 4\nupright: 0\n");
|
||||
detector.read(filename);
|
||||
|
||||
List<KeyPoint> keypoints2 = new ArrayList<KeyPoint>();
|
||||
MatOfKeyPoint keypoints2 = new MatOfKeyPoint();
|
||||
detector.detect(cross, keypoints2);
|
||||
|
||||
assertTrue(keypoints2.size() <= keypoints1.size());
|
||||
assertTrue(keypoints2.total() <= keypoints1.total());
|
||||
}
|
||||
|
||||
public void testWrite() {
|
||||
|
Loading…
Reference in New Issue
Block a user