Refactoring: set default local transform for camera drivers to opticalRotation. Added CameraModel::opticalRtotation() static function for convenience. Added CameraModel::load() from file directly for convenience. Added Camera::initFromFile() for convenience. Transform: Added opengl_T_rtabmap() and opengl_T_rtabmap() functions for convenience (convert back and forth between rtabmap world and opengl world coordinate frames)

This commit is contained in:
matlabbe
2020-06-08 11:40:47 -04:00
parent ff5695878c
commit 4769fc235f
27 changed files with 88 additions and 67 deletions
+17 -12
View File
@@ -211,7 +211,7 @@ void CameraModel::setImageSize(const cv::Size & size)
}
}
bool CameraModel::load(const std::string & directory, const std::string & cameraName)
bool CameraModel::load(const std::string & filePath)
{
K_ = cv::Mat();
D_ = cv::Mat();
@@ -222,7 +222,6 @@ bool CameraModel::load(const std::string & directory, const std::string & camera
name_.clear();
imageSize_ = cv::Size();
std::string filePath = directory+"/"+cameraName+".yaml";
if(UFile::exists(filePath))
{
try
@@ -361,6 +360,11 @@ bool CameraModel::load(const std::string & directory, const std::string & camera
return false;
}
bool CameraModel::load(const std::string & directory, const std::string & cameraName)
{
return load(directory+"/"+cameraName+".yaml");
}
bool CameraModel::save(const std::string & directory) const
{
std::string filePath = directory+"/"+name_+".yaml";
@@ -636,22 +640,23 @@ CameraModel CameraModel::roi(const cv::Rect & roi) const
return roiModel;
}
double CameraModel::fovX() const
{
return imageSize_.width>0 && fx()>0?2.0*atan(imageSize_.width/(fx()*2.0)):0.0;
}
double CameraModel::fovY() const
{
return imageSize_.height>0 && fy()>0?2.0*atan(imageSize_.height/(fy()*2.0)):0.0;
}
double CameraModel::horizontalFOV() const
{
if(imageWidth() > 0 && fx() > 0.0)
{
return atan((double(imageWidth())/2.0)/fx())*2.0*180.0/CV_PI;
}
return 0.0;
return fovX()*180.0/CV_PI;
}
double CameraModel::verticalFOV() const
{
if(imageHeight() > 0 && fy() > 0.0)
{
return atan((double(imageHeight())/2.0)/fy())*2.0*180.0/CV_PI;
}
return 0.0;
return fovY()*180.0/CV_PI;
}
cv::Mat CameraModel::rectifyImage(const cv::Mat & raw, int interpolation) const