31 #include <opencv2/imgproc/types_c.h>
32 #if CV_MAJOR_VERSION > 3
33 #include <opencv2/videoio/videoio_c.h>
34 #if CV_MAJOR_VERSION > 4
35 #include <opencv2/videoio/legacy/constants_c.h>
48 const std::string & path,
52 Camera(imageRate, localTransform),
54 rectifyImages_(rectifyImages),
64 const std::string & pathLeft,
65 const std::string & pathRight,
69 Camera(imageRate, localTransform),
72 rectifyImages_(rectifyImages),
86 Camera(imageRate, localTransform),
87 rectifyImages_(rectifyImages),
102 Camera(imageRate, localTransform),
103 rectifyImages_(rectifyImages),
105 usbDevice_(deviceLeft),
106 usbDevice2_(deviceRight),
163 ULOGGER_ERROR(
"CameraStereoVideo: Failed to create a capture object!");
171 unsigned int guid = (
unsigned int)
capture_.get(CV_CAP_PROP_GUID);
172 if (guid != 0 && guid != 0xffffffff)
179 if(!calibrationFolder.empty() && !
cameraName_.empty())
183 UWARN(
"Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!",
188 UINFO(
"Stereo parameters: fx=%f cx=%f cy=%f baseline=%f",
230 UERROR(
"Parameter \"rectifyImages\" is set, but no stereo model is loaded or valid.");
262 leftImage = cv::Mat(
img, cv::Rect( 0, 0,
img.size().width/2,
img.size().height ));
263 rightImage = cv::Mat(
img, cv::Rect(
img.size().width/2, 0,
img.size().width/2,
img.size().height ));
269 else if(leftImage.cols != rightImage.cols || leftImage.rows != rightImage.rows)
271 UERROR(
"Left and right streams don't have image of the same size: left=%dx%d right=%dx%d",
272 leftImage.cols, leftImage.rows, rightImage.cols, rightImage.rows);
277 bool rightCvt =
false;
278 if(rightImage.type() != CV_8UC1)
281 cv::cvtColor(rightImage, tmp, CV_BGR2GRAY);
293 leftImage = leftImage.clone();
296 rightImage = rightImage.clone();
309 ULOGGER_WARN(
"The camera must be initialized before requesting an image.");