mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
Added Java ORB test
This commit is contained in:
parent
eab21b6106
commit
0b3dbdd4b3
@ -1,5 +1,13 @@
|
||||
package org.opencv.test.features2d;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.KeyPoint;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.features2d.Features2d;
|
||||
import org.opencv.features2d.ORB;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class ORBFeatureDetectorTest extends OpenCVTestCase {
|
||||
@ -36,4 +44,35 @@ public class ORBFeatureDetectorTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testDetectTwoPoints() {
|
||||
Mat img = new Mat(256,256, CvType.CV_8UC3, new Scalar(0,0,0));
|
||||
img.put(35, 40, 255,255, 255);
|
||||
img.put(152, 98, 200,0, 0);
|
||||
|
||||
MatOfKeyPoint keypoints = new MatOfKeyPoint();
|
||||
ORB orb = ORB.create();
|
||||
Mat descriptors = new Mat();
|
||||
orb.detectAndCompute(img, new Mat(), keypoints, descriptors);
|
||||
|
||||
KeyPoint[] keypointsArray = keypoints.toArray();
|
||||
assertEquals(2, keypointsArray.length);
|
||||
|
||||
long x1 = Math.round(keypointsArray[0].pt.x);
|
||||
long y1 = Math.round(keypointsArray[0].pt.y);
|
||||
long x2 = Math.round(keypointsArray[1].pt.x);
|
||||
long y2 = Math.round(keypointsArray[1].pt.y);
|
||||
|
||||
if (x2 > x1) {
|
||||
assertEquals(40, x1);
|
||||
assertEquals(35, y1);
|
||||
assertEquals(98, x2);
|
||||
assertEquals(152, y2);
|
||||
} else {
|
||||
assertEquals(40, x2);
|
||||
assertEquals(35, y2);
|
||||
assertEquals(98, x1);
|
||||
assertEquals(152, y1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user