47 if( !cap_0.initializeVideo(0) )
49 std::cerr <<
"Cannot open camera video capture" << std::endl;
50 std::cerr <<
"See verbosity level for more details." << std::endl;
55 std::cout <<
"Connected to camera sn: " << cap_0.getSerialNumber() <<
" [" << cap_0.getDeviceName() <<
"]" << std::endl;
60 if( !cap_1.initializeVideo(2) )
62 std::cerr <<
"Cannot open camera video capture" << std::endl;
63 std::cerr <<
"See verbosity level for more details." << std::endl;
68 std::cout <<
"Connected to camera sn: " << cap_1.getSerialNumber() <<
" [" << cap_1.getDeviceName() <<
"]" << std::endl;
72 bool autoSettingEnable =
true;
73 cap_0.setAutoWhiteBalance(autoSettingEnable);
74 cap_0.setAECAGC(autoSettingEnable);
76 cap_1.setAutoWhiteBalance(autoSettingEnable);
77 cap_1.setAECAGC(autoSettingEnable);
83 uint64_t lastFrameTs = 0;
94 if(frame_0.
data!=
nullptr && frame_1.
data!=
nullptr)
101 double elapsed_sec = now - lastTime;
103 std::cout <<
"[System] Frame period: " << elapsed_sec <<
"sec - Freq: " << 1./elapsed_sec <<
" Hz" << std::endl;
107 double frame_dT =
static_cast<double>(frame.timestamp-lastFrameTs)/1e9;
108 std::cout <<
"[Camera] Frame period: " << frame_dT <<
"sec - Freq: " << 1./frame_dT <<
" Hz" << std::endl;
115 cv::Mat frameYUV_0 = cv::Mat( frame_0.
height, frame_0.
width, CV_8UC2, frame_0.
data );
117 cv::Mat frameYUV_1 = cv::Mat( frame_1.
height, frame_1.
width, CV_8UC2, frame_1.
data );
119 cv::cvtColor(frameYUV_0,frameBGR_0,cv::COLOR_YUV2BGR_YUYV);
120 cv::cvtColor(frameYUV_1,frameBGR_1,cv::COLOR_YUV2BGR_YUYV);
130 int key = cv::waitKey( 5 );
131 if(key==
'q' || key==
'Q')
133 if(key==
'a' || key==
'A')
135 autoSettingEnable = !autoSettingEnable;
136 cap_0.setAutoWhiteBalance(autoSettingEnable);
137 cap_0.setAECAGC(autoSettingEnable);
139 cap_1.setAutoWhiteBalance(autoSettingEnable);
140 cap_1.setAECAGC(autoSettingEnable);
142 std::cout <<
"Auto GAIN/EXPOSURE and Auto White Balance: " << (autoSettingEnable?
"ENABLED":
"DISABLED") << std::endl;
The VideoCapture class provides image grabbing functions and settings control for all the Stereolabs ...
uint64_t getSteadyTimestamp()
Get the current system clock as steady clock, so with no jumps even if the system time changes.
@ FPS_60
60 Frames per second. Not available for RESOLUTION::HD2K and RESOLUTION::HD1080.
The Frame struct containing the acquired video frames.
uint64_t timestamp
Timestamp in nanoseconds.
uint16_t height
Frame height.
uint16_t width
Frame width.
uint8_t * data
Frame data in YUV 4:2:2 format.
The camera configuration parameters.
RESOLUTION res
Camera resolution.
FPS fps
Frames per second.
sl_oc::video::VideoParams params