1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package org.opencv.test.highgui;
import java.util.List;
import org.opencv.core.Size;
import org.opencv.videoio.Videoio;
import org.opencv.videoio.VideoCapture;
import org.opencv.test.OpenCVTestCase;
public class VideoCaptureTest extends OpenCVTestCase {
private VideoCapture capture;
private boolean isOpened;
private boolean isSucceed;
@Override
protected void setUp() throws Exception {
super.setUp();
capture = null;
isTestCaseEnabled = false;
isSucceed = false;
isOpened = false;
}
public void testGet() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
double frameWidth = capture.get(Videoio.CV_CAP_PROP_FRAME_WIDTH);
assertTrue(0 != frameWidth);
} finally {
if (capture != null) capture.release();
}
}
public void testGetSupportedPreviewSizes() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
List<Size> sizes = capture.getSupportedPreviewSizes();
assertNotNull(sizes);
assertFalse(sizes.isEmpty());
} finally {
if (capture != null) capture.release();
}
}
public void testGrab() {
capture = new VideoCapture();
isSucceed = capture.grab();
assertFalse(isSucceed);
}
public void testGrabFromRealCamera() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
isSucceed = capture.grab();
assertTrue(isSucceed);
} finally {
if (capture != null) capture.release();
}
}
public void testIsOpened() {
capture = new VideoCapture();
assertFalse(capture.isOpened());
}
public void testIsOpenedRealCamera() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
isOpened = capture.isOpened();
assertTrue(isOpened);
} finally {
if (capture != null) capture.release();
}
}
public void testOpen() {
try {
capture = new VideoCapture();
capture.open(Videoio.CV_CAP_ANDROID);
isOpened = capture.isOpened();
assertTrue(isOpened);
} finally {
if (capture != null) capture.release();
}
}
public void testRead() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
isSucceed = capture.read(dst);
assertTrue(isSucceed);
assertFalse(dst.empty());
assertEquals(3, dst.channels());
} finally {
if (capture != null) capture.release();
}
}
public void testRelease() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
capture.release();
assertFalse(capture.isOpened());
capture = null;
} finally {
if (capture != null) capture.release();
}
}
public void testRetrieveMat() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
capture.grab();
isSucceed = capture.retrieve(dst);
assertTrue(isSucceed);
assertFalse(dst.empty());
assertEquals(3, dst.channels());
} finally {
if (capture != null) capture.release();
}
}
public void testRetrieveMatInt() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
capture.grab();
isSucceed = capture.retrieve(dst, Videoio.CV_CAP_ANDROID_GREY_FRAME);
assertTrue(isSucceed);
assertFalse(dst.empty());
assertEquals(1, dst.channels());
} finally {
if (capture != null) capture.release();
}
}
public void testSet() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
capture.set(Videoio.CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(Videoio.CV_CAP_PROP_FRAME_HEIGHT, 480);
double frameWidth = capture.get(Videoio.CV_CAP_PROP_FRAME_WIDTH);
capture.read(dst);
assertEquals(640.0, frameWidth);
assertEquals(640, dst.cols());
} finally {
if (capture != null) capture.release();
}
}
public void testVideoCapture() {
capture = new VideoCapture();
assertNotNull(capture);
assertFalse(capture.isOpened());
}
public void testVideoCaptureInt() {
try {
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
assertNotNull(capture);
assertTrue(capture.isOpened());
} finally {
if (capture != null) capture.release();
}
}
}