Path: blob/master/modules/videoio/test/test_camera.cpp
16354 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.34// Note: all tests here are DISABLED by default due specific requirements.5// Don't use #if 0 - these tests should be tested for compilation at least.6//7// Usage: opencv_test_videoio --gtest_also_run_disabled_tests --gtest_filter=*VideoIO_Camera*<tested case>*89#include "test_precomp.hpp"1011namespace opencv_test { namespace {1213TEST(DISABLED_VideoIO_Camera, basic)14{15VideoCapture capture(0);16ASSERT_TRUE(capture.isOpened());17std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;18std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;19std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;20std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;2122const int N = 100;23Mat frame;24int64 time0 = cv::getTickCount();25for (int i = 0; i < N; i++)26{27SCOPED_TRACE(cv::format("frame=%d", i));2829capture >> frame;30ASSERT_FALSE(frame.empty());3132EXPECT_GT(cvtest::norm(frame, NORM_INF), 0) << "Complete black image has been received";33}34int64 time1 = cv::getTickCount();35printf("Processed %d frames on %.2f FPS\n", N, (N * cv::getTickFrequency()) / (time1 - time0 + 1));3637capture.release();38}3940//Following test if for capture device using PhysConn_Video_SerialDigital as crossbar input pin41TEST(DISABLED_VideoIO_Camera, dshow_avermedia_capture)42{43VideoCapture capture(0);44ASSERT_TRUE(capture.isOpened());45capture.set(CAP_CROSSBAR_INPIN_TYPE, 6);46std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;47std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;48std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;49std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;5051const int N = 100;52Mat frame;53int64 time0 = cv::getTickCount();54for (int i = 0; i < N; i++)55{56SCOPED_TRACE(cv::format("frame=%d", i));5758capture >> frame;59ASSERT_FALSE(frame.empty());6061EXPECT_GT(cvtest::norm(frame, NORM_INF), 0) << "Complete black image has been received";62}63int64 time1 = cv::getTickCount();64printf("Processed %d frames on %.2f FPS\n", N, (N * cv::getTickFrequency()) / (time1 - time0 + 1));6566capture.release();67}6869}} // namespace707172