Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/core/misc/java/test/KeyPointTest.java
16354 views
1
package org.opencv.test.core;
2
3
import org.opencv.core.Point;
4
import org.opencv.core.KeyPoint;
5
import org.opencv.test.OpenCVTestCase;
6
7
public class KeyPointTest extends OpenCVTestCase {
8
9
private float angle;
10
private int classId;
11
private KeyPoint keyPoint;
12
private int octave;
13
private float response;
14
private float size;
15
private float x;
16
private float y;
17
18
@Override
19
protected void setUp() throws Exception {
20
super.setUp();
21
22
keyPoint = null;
23
x = 1.0f;
24
y = 2.0f;
25
size = 3.0f;
26
angle = 30.0f;
27
response = 2.0f;
28
octave = 1;
29
classId = 1;
30
}
31
32
public void testKeyPoint() {
33
keyPoint = new KeyPoint();
34
assertPointEquals(new Point(0, 0), keyPoint.pt, EPS);
35
}
36
37
public void testKeyPointFloatFloatFloat() {
38
keyPoint = new KeyPoint(x, y, size);
39
assertPointEquals(new Point(1, 2), keyPoint.pt, EPS);
40
}
41
42
public void testKeyPointFloatFloatFloatFloat() {
43
keyPoint = new KeyPoint(x, y, size, 10.0f);
44
assertEquals(10.0f, keyPoint.angle);
45
}
46
47
public void testKeyPointFloatFloatFloatFloatFloat() {
48
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f);
49
assertEquals(1.0f, keyPoint.response);
50
}
51
52
public void testKeyPointFloatFloatFloatFloatFloatInt() {
53
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1);
54
assertEquals(1, keyPoint.octave);
55
}
56
57
public void testKeyPointFloatFloatFloatFloatFloatIntInt() {
58
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1, 1);
59
assertEquals(1, keyPoint.class_id);
60
}
61
62
public void testToString() {
63
keyPoint = new KeyPoint(x, y, size, angle, response, octave, classId);
64
65
String actual = keyPoint.toString();
66
67
String expected = "KeyPoint [pt={1.0, 2.0}, size=3.0, angle=30.0, response=2.0, octave=1, class_id=1]";
68
assertEquals(expected, actual);
69
}
70
71
}
72
73