Merge branch 2.4
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package org.opencv.test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
@@ -426,24 +428,19 @@ public class OpenCVTestCase extends TestCase {
|
||||
}
|
||||
|
||||
protected static String readFile(String path) {
|
||||
FileInputStream stream = null;
|
||||
try {
|
||||
stream = new FileInputStream(new File(path));
|
||||
FileChannel fc = stream.getChannel();
|
||||
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0,
|
||||
fc.size());
|
||||
return Charset.defaultCharset().decode(bb).toString();
|
||||
BufferedReader br = new BufferedReader(new FileReader(path));
|
||||
String line;
|
||||
StringBuffer result = new StringBuffer();
|
||||
while ((line = br.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append("\n");
|
||||
}
|
||||
return result.toString();
|
||||
} catch (IOException e) {
|
||||
OpenCVTestRunner.Log("Failed to read file \"" + path
|
||||
+ "\". Exception is thrown: " + e);
|
||||
return null;
|
||||
} finally {
|
||||
if (stream != null)
|
||||
try {
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
OpenCVTestRunner.Log("Exception is thrown: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,8 @@ public class TermCriteriaTest extends OpenCVTestCase {
|
||||
|
||||
public void testToString() {
|
||||
String actual = tc2.toString();
|
||||
String expected = "{ type: 2, maxCount: 4, epsilon: 0.001}";
|
||||
double eps = EPS;
|
||||
String expected = "{ type: 2, maxCount: 4, epsilon: " + eps + "}";
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
@@ -26,10 +26,9 @@ public class BRIEFDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
extractor = DescriptorExtractor.create(DescriptorExtractor.BRIEF);
|
||||
matSize = 100;
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testComputeListOfMatListOfListOfKeyPointListOfMat() {
|
||||
|
@@ -80,6 +80,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
|
||||
matSize = 100;
|
||||
|
||||
@@ -90,8 +91,6 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(3, 1, 0, 0.48435235f),
|
||||
new DMatch(4, 0, 0, 1.0836693f)
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -65,6 +65,7 @@ public class BruteForceHammingDescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING);
|
||||
matSize = 100;
|
||||
|
||||
@@ -73,7 +74,6 @@ public class BruteForceHammingDescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(1, 2, 0, 42),
|
||||
new DMatch(2, 1, 0, 40),
|
||||
new DMatch(3, 3, 0, 53) };
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -65,6 +65,7 @@ public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMINGLUT);
|
||||
matSize = 100;
|
||||
|
||||
@@ -73,7 +74,6 @@ public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(1, 2, 0, 42),
|
||||
new DMatch(2, 1, 0, 40),
|
||||
new DMatch(3, 3, 0, 53) };
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -80,6 +80,7 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_L1);
|
||||
matSize = 100;
|
||||
|
||||
@@ -90,7 +91,6 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(3, 1, 0, 2.6545324f),
|
||||
new DMatch(4, 0, 0, 6.1294870f)
|
||||
};
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -85,6 +85,7 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_SL2);
|
||||
matSize = 100;
|
||||
|
||||
@@ -95,8 +96,6 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(3, 1, 0, 0.23459719f),
|
||||
new DMatch(4, 0, 0, 1.174339f)
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -35,12 +35,10 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
detector = FeatureDetector.create(FeatureDetector.FAST);
|
||||
|
||||
truth = new KeyPoint[] { new KeyPoint(32, 27, 7, -1, 254, 0, -1), new KeyPoint(27, 32, 7, -1, 254, 0, -1), new KeyPoint(73, 68, 7, -1, 254, 0, -1),
|
||||
new KeyPoint(68, 73, 7, -1, 254, 0, -1) };
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testCreate() {
|
||||
|
@@ -154,9 +154,9 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
matcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
|
||||
matSize = 100;
|
||||
|
||||
truth = new DMatch[] {
|
||||
new DMatch(0, 0, 0, 1.049694f),
|
||||
new DMatch(1, 0, 0, 1.0984558f),
|
||||
@@ -164,8 +164,6 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
|
||||
new DMatch(3, 1, 0, 0.48435235f),
|
||||
new DMatch(4, 0, 0, 1.0836693f)
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testAdd() {
|
||||
|
@@ -31,10 +31,9 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
extractor = DescriptorExtractor.create(DescriptorExtractor.ORB);
|
||||
matSize = 100;
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testComputeListOfMatListOfListOfKeyPointListOfMat() {
|
||||
@@ -101,7 +100,9 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
extractor.write(filename);
|
||||
|
||||
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.ORB</name>\n<WTA_K>2</WTA_K>\n<edgeThreshold>31</edgeThreshold>\n<firstLevel>0</firstLevel>\n<nFeatures>500</nFeatures>\n<nLevels>8</nLevels>\n<patchSize>31</patchSize>\n<scaleFactor>1.2000000476837158e+00</scaleFactor>\n<scoreType>0</scoreType>\n</opencv_storage>\n";
|
||||
assertEquals(truth, readFile(filename));
|
||||
String actual = readFile(filename);
|
||||
actual = actual.replaceAll("e\\+000", "e+00"); // NOTE: workaround for different platforms double representation
|
||||
assertEquals(truth, actual);
|
||||
}
|
||||
|
||||
public void testWriteYml() {
|
||||
@@ -110,7 +111,9 @@ public class ORBDescriptorExtractorTest extends OpenCVTestCase {
|
||||
extractor.write(filename);
|
||||
|
||||
String truth = "%YAML:1.0\nname: \"Feature2D.ORB\"\nWTA_K: 2\nedgeThreshold: 31\nfirstLevel: 0\nnFeatures: 500\nnLevels: 8\npatchSize: 31\nscaleFactor: 1.2000000476837158e+00\nscoreType: 0\n";
|
||||
assertEquals(truth, readFile(filename));
|
||||
String actual = readFile(filename);
|
||||
actual = actual.replaceAll("e\\+000", "e+00"); // NOTE: workaround for different platforms double representation
|
||||
assertEquals(truth, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
extractor = DescriptorExtractor.create(DescriptorExtractor.SIFT);
|
||||
keypoint = new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1);
|
||||
matSize = 100;
|
||||
@@ -44,8 +45,6 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testComputeListOfMatListOfListOfKeyPointListOfMat() {
|
||||
@@ -88,7 +87,9 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
extractor.write(filename);
|
||||
|
||||
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.SIFT</name>\n<contrastThreshold>4.0000000000000001e-02</contrastThreshold>\n<edgeThreshold>10.</edgeThreshold>\n<nFeatures>0</nFeatures>\n<nOctaveLayers>3</nOctaveLayers>\n<sigma>1.6000000000000001e+00</sigma>\n</opencv_storage>\n";
|
||||
assertEquals(truth, readFile(filename));
|
||||
String actual = readFile(filename);
|
||||
actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
|
||||
assertEquals(truth, actual);
|
||||
}
|
||||
|
||||
public void testWriteYml() {
|
||||
@@ -97,7 +98,9 @@ public class SIFTDescriptorExtractorTest extends OpenCVTestCase {
|
||||
extractor.write(filename);
|
||||
|
||||
String truth = "%YAML:1.0\nname: \"Feature2D.SIFT\"\ncontrastThreshold: 4.0000000000000001e-02\nedgeThreshold: 10.\nnFeatures: 0\nnOctaveLayers: 3\nsigma: 1.6000000000000001e+00\n";
|
||||
assertEquals(truth, readFile(filename));
|
||||
String actual = readFile(filename);
|
||||
actual = actual.replaceAll("e([+-])0(\\d\\d)", "e$1$2"); // NOTE: workaround for different platforms double representation
|
||||
assertEquals(truth, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,22 +42,10 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
detector = FeatureDetector.create(FeatureDetector.STAR);
|
||||
|
||||
matSize = 200;
|
||||
|
||||
truth = new KeyPoint[] {
|
||||
/*
|
||||
new KeyPoint(95, 80, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(105, 80, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(80, 95, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(120, 95, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(100, 100, 8, -1, -219.90825f, 0, -1),
|
||||
new KeyPoint(80, 105, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(120, 105, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(95, 120, 22, -1, 31.595734f, 0, -1),
|
||||
new KeyPoint(105, 120, 22, -1, 31.595734f, 0, -1)
|
||||
*/
|
||||
new KeyPoint( 95, 80, 22, -1, 31.5957f, 0, -1),
|
||||
new KeyPoint(105, 80, 22, -1, 31.5957f, 0, -1),
|
||||
new KeyPoint( 80, 95, 22, -1, 31.5957f, 0, -1),
|
||||
@@ -68,8 +56,6 @@ public class STARFeatureDetectorTest extends OpenCVTestCase {
|
||||
new KeyPoint( 95, 120, 22, -1, 31.5957f, 0, -1),
|
||||
new KeyPoint(105, 120, 22, -1, 31.5957f, 0, -1)
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testCreate() {
|
||||
|
@@ -26,10 +26,9 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
extractor = DescriptorExtractor.create(DescriptorExtractor.SURF);
|
||||
matSize = 100;
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testComputeListOfMatListOfListOfKeyPointListOfMat() {
|
||||
|
@@ -52,18 +52,15 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
detector = FeatureDetector.create(FeatureDetector.SURF);
|
||||
|
||||
matSize = 100;
|
||||
|
||||
truth = new KeyPoint[] {
|
||||
new KeyPoint(55.775578f, 55.775578f, 16, 80.245735f, 8617.8633f, 0, -1),
|
||||
new KeyPoint(44.224422f, 55.775578f, 16, 170.24574f, 8617.8633f, 0, -1),
|
||||
new KeyPoint(44.224422f, 44.224422f, 16, 260.24573f, 8617.8633f, 0, -1),
|
||||
new KeyPoint(55.775578f, 44.224422f, 16, 350.24573f, 8617.8633f, 0, -1)
|
||||
};
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void testCreate() {
|
||||
|
Reference in New Issue
Block a user