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),
64 const std::string & pathLeft,
65 const std::string & pathRight,
69 Camera(imageRate, localTransform),
86 Camera(imageRate, localTransform),
102 Camera(imageRate, localTransform),
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.");
bool isValidForProjection() const
cv::VideoCapture capture_
virtual SensorData captureImage(CameraInfo *info=0)
CameraStereoVideo(const std::string &pathSideBySide, bool rectifyImages=false, float imageRate=0.0f, const Transform &localTransform=Transform::getIdentity())
Some conversion functions.
bool isValidForRectification() const
virtual bool isCalibrated() const
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
#define ULOGGER_DEBUG(...)
virtual std::string getSerial() const
bool isValidForRectification() const
StereoCameraModel stereoModel_
const Transform & getLocalTransform() const
bool load(const std::string &directory, const std::string &cameraName, bool ignoreStereoTransform=true)
cv::Mat rectifyImage(const cv::Mat &raw, int interpolation=cv::INTER_LINEAR) const
#define ULOGGER_WARN(...)
virtual ~CameraStereoVideo()
void setLocalTransform(const Transform &transform)
void setImageSize(const cv::Size &size)
#define ULOGGER_ERROR(...)
std::string UTILITE_EXP uFormat(const char *fmt,...)
const CameraModel & right() const
cv::VideoCapture capture2_
const CameraModel & left() const