31 #include <opencv2/imgproc/types_c.h> 32 #if CV_MAJOR_VERSION > 3 33 #include <opencv2/videoio/videoio_c.h> 45 const std::string & path,
49 Camera(imageRate, localTransform),
59 const std::string & pathLeft,
60 const std::string & pathRight,
64 Camera(imageRate, localTransform),
79 Camera(imageRate, localTransform),
93 Camera(imageRate, localTransform),
152 ULOGGER_ERROR(
"CameraStereoVideo: Failed to create a capture object!");
160 unsigned int guid = (
unsigned int)
capture_.get(CV_CAP_PROP_GUID);
161 if (guid != 0 && guid != 0xffffffff)
168 if(!calibrationFolder.empty() && !
cameraName_.empty())
172 UWARN(
"Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!",
177 UINFO(
"Stereo parameters: fx=%f cx=%f cy=%f baseline=%f",
188 UERROR(
"Parameter \"rectifyImages\" is set, but no stereo model is loaded or valid.");
220 leftImage = cv::Mat(img, cv::Rect( 0, 0, img.size().width/2, img.size().height ));
221 rightImage = cv::Mat(img, cv::Rect( img.size().width/2, 0, img.size().width/2, img.size().height ));
227 else if(leftImage.cols != rightImage.cols || leftImage.rows != rightImage.rows)
229 UERROR(
"Left and right streams don't have image of the same size: left=%dx%d right=%dx%d",
230 leftImage.cols, leftImage.rows, rightImage.cols, rightImage.rows);
235 bool rightCvt =
false;
236 if(rightImage.type() != CV_8UC1)
239 cv::cvtColor(rightImage, tmp, CV_BGR2GRAY);
251 leftImage = leftImage.clone();
254 rightImage = rightImage.clone();
267 ULOGGER_WARN(
"The camera must be initialized before requesting an image.");
cv::VideoCapture capture_
const Transform & getLocalTransform() const
virtual SensorData captureImage(CameraInfo *info=0)
Some conversion functions.
CameraStereoVideo(const std::string &pathSideBySide, bool rectifyImages=false, float imageRate=0.0f, const Transform &localTransform=CameraModel::opticalRotation())
virtual bool init(const std::string &calibrationFolder=".", const std::string &cameraName="")
virtual std::string getSerial() const
bool isValidForProjection() const
const CameraModel & left() const
#define ULOGGER_DEBUG(...)
virtual bool isCalibrated() const
bool isValidForRectification() const
StereoCameraModel stereoModel_
cv::Mat rectifyImage(const cv::Mat &raw, int interpolation=cv::INTER_LINEAR) const
bool load(const std::string &directory, const std::string &cameraName, bool ignoreStereoTransform=true)
bool isValidForRectification() const
const CameraModel & right() 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,...)
cv::VideoCapture capture2_