mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
169 lines
4.7 KiB
169 lines
4.7 KiB
14 years ago
|
package org.opencv.test.highgui;
|
||
|
|
||
14 years ago
|
import java.util.List;
|
||
|
|
||
|
import org.opencv.core.Size;
|
||
11 years ago
|
import org.opencv.videoio.Videoio;
|
||
|
import org.opencv.videoio.VideoCapture;
|
||
14 years ago
|
|
||
|
import org.opencv.test.OpenCVTestCase;
|
||
|
|
||
|
public class VideoCaptureTest extends OpenCVTestCase {
|
||
14 years ago
|
|
||
|
private VideoCapture capture;
|
||
|
private boolean isOpened;
|
||
14 years ago
|
private boolean isSucceed;
|
||
14 years ago
|
|
||
14 years ago
|
@Override
|
||
|
protected void setUp() throws Exception {
|
||
|
super.setUp();
|
||
14 years ago
|
|
||
14 years ago
|
capture = null;
|
||
12 years ago
|
isTestCaseEnabled = false;
|
||
14 years ago
|
isSucceed = false;
|
||
|
isOpened = false;
|
||
|
}
|
||
14 years ago
|
|
||
14 years ago
|
public void testGet() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
|
double frameWidth = capture.get(Videoio.CV_CAP_PROP_FRAME_WIDTH);
|
||
14 years ago
|
assertTrue(0 != frameWidth);
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
14 years ago
|
public void testGetSupportedPreviewSizes() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
List<Size> sizes = capture.getSupportedPreviewSizes();
|
||
|
assertNotNull(sizes);
|
||
|
assertFalse(sizes.isEmpty());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testGrab() {
|
||
|
capture = new VideoCapture();
|
||
|
isSucceed = capture.grab();
|
||
|
assertFalse(isSucceed);
|
||
|
}
|
||
|
|
||
|
public void testGrabFromRealCamera() {
|
||
14 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
isSucceed = capture.grab();
|
||
|
assertTrue(isSucceed);
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testIsOpened() {
|
||
|
capture = new VideoCapture();
|
||
|
assertFalse(capture.isOpened());
|
||
|
}
|
||
|
|
||
|
public void testIsOpenedRealCamera() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
isOpened = capture.isOpened();
|
||
|
assertTrue(isOpened);
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testOpen() {
|
||
12 years ago
|
try {
|
||
14 years ago
|
capture = new VideoCapture();
|
||
11 years ago
|
capture.open(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
isOpened = capture.isOpened();
|
||
|
assertTrue(isOpened);
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testRead() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
isSucceed = capture.read(dst);
|
||
|
assertTrue(isSucceed);
|
||
|
assertFalse(dst.empty());
|
||
|
assertEquals(3, dst.channels());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testRelease() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
capture.release();
|
||
|
assertFalse(capture.isOpened());
|
||
|
capture = null;
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testRetrieveMat() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
capture.grab();
|
||
|
isSucceed = capture.retrieve(dst);
|
||
|
assertTrue(isSucceed);
|
||
|
assertFalse(dst.empty());
|
||
|
assertEquals(3, dst.channels());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testRetrieveMatInt() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
capture.grab();
|
||
11 years ago
|
isSucceed = capture.retrieve(dst, Videoio.CV_CAP_ANDROID_GREY_FRAME);
|
||
14 years ago
|
assertTrue(isSucceed);
|
||
|
assertFalse(dst.empty());
|
||
|
assertEquals(1, dst.channels());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testSet() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
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);
|
||
14 years ago
|
capture.read(dst);
|
||
|
assertEquals(640.0, frameWidth);
|
||
|
assertEquals(640, dst.cols());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testVideoCapture() {
|
||
|
capture = new VideoCapture();
|
||
14 years ago
|
assertNotNull(capture);
|
||
|
assertFalse(capture.isOpened());
|
||
14 years ago
|
}
|
||
|
|
||
|
public void testVideoCaptureInt() {
|
||
12 years ago
|
try {
|
||
11 years ago
|
capture = new VideoCapture(Videoio.CV_CAP_ANDROID);
|
||
14 years ago
|
assertNotNull(capture);
|
||
|
assertTrue(capture.isOpened());
|
||
|
} finally {
|
||
|
if (capture != null) capture.release();
|
||
|
}
|
||
14 years ago
|
}
|
||
14 years ago
|
}
|