Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/videoio/test/test_camera.cpp
16354 views
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.
4
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.
7
//
8
// Usage: opencv_test_videoio --gtest_also_run_disabled_tests --gtest_filter=*VideoIO_Camera*<tested case>*
9
10
#include "test_precomp.hpp"
11
12
namespace opencv_test { namespace {
13
14
TEST(DISABLED_VideoIO_Camera, basic)
15
{
16
VideoCapture capture(0);
17
ASSERT_TRUE(capture.isOpened());
18
std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
19
std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
20
std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
21
std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
22
23
const int N = 100;
24
Mat frame;
25
int64 time0 = cv::getTickCount();
26
for (int i = 0; i < N; i++)
27
{
28
SCOPED_TRACE(cv::format("frame=%d", i));
29
30
capture >> frame;
31
ASSERT_FALSE(frame.empty());
32
33
EXPECT_GT(cvtest::norm(frame, NORM_INF), 0) << "Complete black image has been received";
34
}
35
int64 time1 = cv::getTickCount();
36
printf("Processed %d frames on %.2f FPS\n", N, (N * cv::getTickFrequency()) / (time1 - time0 + 1));
37
38
capture.release();
39
}
40
41
//Following test if for capture device using PhysConn_Video_SerialDigital as crossbar input pin
42
TEST(DISABLED_VideoIO_Camera, dshow_avermedia_capture)
43
{
44
VideoCapture capture(0);
45
ASSERT_TRUE(capture.isOpened());
46
capture.set(CAP_CROSSBAR_INPIN_TYPE, 6);
47
std::cout << "Camera 0 via " << capture.getBackendName() << " backend" << std::endl;
48
std::cout << "Frame width: " << capture.get(CAP_PROP_FRAME_WIDTH) << std::endl;
49
std::cout << " height: " << capture.get(CAP_PROP_FRAME_HEIGHT) << std::endl;
50
std::cout << "Capturing FPS: " << capture.get(CAP_PROP_FPS) << std::endl;
51
52
const int N = 100;
53
Mat frame;
54
int64 time0 = cv::getTickCount();
55
for (int i = 0; i < N; i++)
56
{
57
SCOPED_TRACE(cv::format("frame=%d", i));
58
59
capture >> frame;
60
ASSERT_FALSE(frame.empty());
61
62
EXPECT_GT(cvtest::norm(frame, NORM_INF), 0) << "Complete black image has been received";
63
}
64
int64 time1 = cv::getTickCount();
65
printf("Processed %d frames on %.2f FPS\n", N, (N * cv::getTickFrequency()) / (time1 - time0 + 1));
66
67
capture.release();
68
}
69
70
}} // namespace
71
72