1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
5 // Note: all tests here are DISABLED by default due specific requirements.
6 // Don't use #if 0 - these tests should be tested for compilation at least.
8 // Usage: opencv_test_videoio --gtest_also_run_disabled_tests --gtest_filter=*VideoIO_Camera*<tested case>*
10 #include "test_precomp.hpp"
12 namespace opencv_test { namespace {
14 static void test_readFrames(/*const*/ VideoCapture& capture, const int N = 100)
17 int64 time0 = cv::getTickCount();
18 for (int i = 0; i < N; i++)
20 SCOPED_TRACE(cv::format("frame=%d", i));
23 ASSERT_FALSE(frame.empty());
25 EXPECT_GT(cvtest::norm(frame, NORM_INF), 0) << "Complete black image has been received";
27 int64 time1 = cv::getTickCount();
28 printf("Processed %d frames on %.2f FPS\n", N, (N * cv::getTickFrequency()) / (time1 - time0 + 1));
31 TEST(DISABLED_VideoIO_Camera, basic)
33 VideoCapture capture(0);
34 ASSERT_TRUE(capture.isOpened());
35 std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
36 std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
37 std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
38 std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
39 test_readFrames(capture);
43 TEST(DISABLED_VideoIO_Camera, validate_V4L2_MJPEG)
45 VideoCapture capture(CAP_V4L2);
46 ASSERT_TRUE(capture.isOpened());
47 ASSERT_TRUE(capture.set(CAP_PROP_FOURCC, VideoWriter::fourcc('M', 'J', 'P', 'G')));
48 std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
49 std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
50 std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
51 std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
52 int fourcc = (int)capture.get(CAP_PROP_FOURCC);
53 std::cout << "FOURCC code: " << cv::format("0x%8x", fourcc) << std::endl;
54 test_readFrames(capture);
58 //Following test if for capture device using PhysConn_Video_SerialDigital as crossbar input pin
59 TEST(DISABLED_VideoIO_Camera, dshow_avermedia_capture)
61 VideoCapture capture(0);
62 ASSERT_TRUE(capture.isOpened());
63 capture.set(CAP_PROP_CHANNEL, 6);
64 std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
65 std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
66 std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
67 std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
68 test_readFrames(capture);