refactor(api): move camera models
This commit is contained in:
parent
bc7e4919e2
commit
f54eef8ad1
|
@ -128,22 +128,25 @@ if(WITH_GLOG)
|
|||
)
|
||||
endif()
|
||||
|
||||
## camodocal
|
||||
## camera_models
|
||||
|
||||
if(WITH_CAM_MODELS)
|
||||
set(EIGEN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
message(STATUS "EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
|
||||
|
||||
include_directories(
|
||||
include
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include
|
||||
${EIGEN_INCLUDE_DIR}
|
||||
src/mynteye/api/camodocal/include
|
||||
src/mynteye/api/camera_models
|
||||
)
|
||||
|
||||
add_library(camodocal STATIC
|
||||
src/mynteye/api/camodocal/src/camera_models/Camera.cc
|
||||
src/mynteye/api/camodocal/src/camera_models/EquidistantCamera.cc
|
||||
src/mynteye/api/camodocal/src/gpl/gpl.cc
|
||||
add_library(camera_models STATIC
|
||||
src/mynteye/api/camera_models/camera.cc
|
||||
src/mynteye/api/camera_models/equidistant_camera.cc
|
||||
src/mynteye/api/camera_models/gpl.cc
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
||||
|
@ -252,7 +255,7 @@ if(OS_MAC)
|
|||
target_link_libraries(${MYNTEYE_NAME} PUBLIC ${OSX_EXTRA_LIBS} )
|
||||
endif()
|
||||
if(WITH_CAM_MODELS)
|
||||
target_link_libraries(${MYNTEYE_NAME} PRIVATE camodocal)
|
||||
target_link_libraries(${MYNTEYE_NAME} PRIVATE camera_models)
|
||||
endif()
|
||||
target_link_threads(${MYNTEYE_NAME})
|
||||
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#include "camodocal/camera_models/Camera.h"
|
||||
|
||||
namespace camodocal {
|
||||
#include "camera.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
Camera::Parameters::Parameters(ModelType modelType)
|
||||
: m_modelType(modelType), m_imageWidth(0), m_imageHeight(0) {
|
||||
|
@ -208,4 +211,7 @@ void Camera::projectPoints(
|
|||
imagePoints.push_back(cv::Point2f(p(0), p(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace models
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
|
@ -11,15 +11,19 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_CAMERA_H_
|
||||
#define SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_CAMERA_H_
|
||||
#ifndef MYNTEYE_CAMERA_MODELS_CAMERA_H_
|
||||
#define MYNTEYE_CAMERA_MODELS_CAMERA_H_
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "eigen3/Eigen/Dense"
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
namespace camodocal {
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
|
@ -134,5 +138,7 @@ typedef std::shared_ptr<Camera> CameraPtr;
|
|||
typedef std::shared_ptr<const Camera> CameraConstPtr;
|
||||
}
|
||||
|
||||
#endif // SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_CAMERA_H_
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_CAMERA_MODELS_CAMERA_H_
|
||||
|
|
@ -16,15 +16,19 @@
|
|||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include "camodocal/camera_models/EquidistantCamera.h"
|
||||
|
||||
#include "eigen3/Eigen/Dense"
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#include <opencv2/core/eigen.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include "camodocal/gpl/gpl.h"
|
||||
// #include "mynteye/logger.h"
|
||||
|
||||
namespace camodocal {
|
||||
#include "equidistant_camera.h"
|
||||
#include "gpl.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
#define PI M_PI
|
||||
#define PI_2 1.5707963
|
||||
float ApproxAtan2(float y, float x)
|
||||
|
@ -652,4 +656,7 @@ void EquidistantCamera::backprojectSymmetric(
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace camodocal
|
||||
|
||||
} // namespace models
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
|
@ -11,14 +11,17 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_EQUIDISTANTCAMERA_H_
|
||||
#define SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_EQUIDISTANTCAMERA_H_
|
||||
#ifndef MYNTEYE_CAMERA_MODELS_EQUIDISTANT_CAMERA_H_
|
||||
#define MYNTEYE_CAMERA_MODELS_EQUIDISTANT_CAMERA_H_
|
||||
|
||||
#include <string>
|
||||
#include "Camera.h"
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
namespace camodocal {
|
||||
#include "camera.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
/**
|
||||
* J. Kannala, and S. Brandt, A Generic Camera Model and Calibration Method
|
||||
|
@ -227,5 +230,7 @@ void EquidistantCamera::spaceToPlane(
|
|||
}
|
||||
}
|
||||
|
||||
#endif // SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_EQUIDISTANTCAMERA_H_
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_CAMERA_MODELS_EQUIDISTANT_CAMERA_H_
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include "camodocal/gpl/gpl.h"
|
||||
#include "gpl.h"
|
||||
|
||||
#include <set>
|
||||
#ifdef _WIN32
|
||||
|
@ -56,7 +56,9 @@ const double WGS84_ECCSQ = 0.00669437999013;
|
|||
#define fminf(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
namespace camodocal {
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
double hypot3(double x, double y, double z) {
|
||||
return sqrt(square(x) + square(y) + square(z));
|
||||
|
@ -524,5 +526,6 @@ char UTMLetterDesignator(double latitude) {
|
|||
return letterDesignator;
|
||||
}
|
||||
|
||||
} // namespace camodocal
|
||||
} // namespace models
|
||||
|
||||
MYNTEYE_END_NAMESPACE
|
|
@ -11,15 +11,19 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_GPL_GPL_H_
|
||||
#define SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_GPL_GPL_H_
|
||||
#ifndef MYNTEYE_CAMERA_MODELS_GPL_H_
|
||||
#define MYNTEYE_CAMERA_MODELS_GPL_H_
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
namespace camodocal {
|
||||
#include "mynteye/mynteye.h"
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
namespace models {
|
||||
|
||||
template <class T>
|
||||
const T clamp(const T &v, const T &a, const T &b) {
|
||||
|
@ -105,5 +109,7 @@ void UTMtoLL(
|
|||
double &latitude, double &longitude); // NOLINT
|
||||
}
|
||||
|
||||
#endif // SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_GPL_GPL_H_
|
||||
MYNTEYE_END_NAMESPACE
|
||||
|
||||
#endif // MYNTEYE_CAMERA_MODELS_GPL_H_
|
||||
|
|
@ -37,8 +37,8 @@ cv::Mat RectifyProcessor::rectifyrad(const cv::Mat& R) {
|
|||
return R.clone();
|
||||
}
|
||||
|
||||
void RectifyProcessor::stereoRectify(camodocal::CameraPtr leftOdo,
|
||||
camodocal::CameraPtr rightOdo, const CvMat* K1, const CvMat* K2,
|
||||
void RectifyProcessor::stereoRectify(models::CameraPtr leftOdo,
|
||||
models::CameraPtr rightOdo, const CvMat* K1, const CvMat* K2,
|
||||
const CvMat* D1, const CvMat* D2, CvSize imageSize,
|
||||
const CvMat* matR, const CvMat* matT,
|
||||
CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, double* T_mul_f,
|
||||
|
@ -249,8 +249,8 @@ struct CameraROSMsgInfo RectifyProcessor::getCalibMatData(
|
|||
}
|
||||
|
||||
std::shared_ptr<struct CameraROSMsgInfoPair> RectifyProcessor::stereoRectify(
|
||||
camodocal::CameraPtr leftOdo,
|
||||
camodocal::CameraPtr rightOdo,
|
||||
models::CameraPtr leftOdo,
|
||||
models::CameraPtr rightOdo,
|
||||
mynteye::IntrinsicsEquidistant in_left,
|
||||
mynteye::IntrinsicsEquidistant in_right,
|
||||
mynteye::Extrinsics ex_right_to_left) {
|
||||
|
@ -330,10 +330,10 @@ std::shared_ptr<struct CameraROSMsgInfoPair> RectifyProcessor::stereoRectify(
|
|||
return std::make_shared<struct CameraROSMsgInfoPair>(info_pair);
|
||||
}
|
||||
|
||||
camodocal::CameraPtr RectifyProcessor::generateCameraFromIntrinsicsEquidistant(
|
||||
models::CameraPtr RectifyProcessor::generateCameraFromIntrinsicsEquidistant(
|
||||
const mynteye::IntrinsicsEquidistant & in) {
|
||||
camodocal::EquidistantCameraPtr camera(
|
||||
new camodocal::EquidistantCamera("KANNALA_BRANDT",
|
||||
models::EquidistantCameraPtr camera(
|
||||
new models::EquidistantCamera("KANNALA_BRANDT",
|
||||
in.width,
|
||||
in.height,
|
||||
in.coeffs[0],
|
||||
|
@ -354,9 +354,9 @@ void RectifyProcessor::InitParams(
|
|||
calib_model = CalibrationModel::KANNALA_BRANDT;
|
||||
in_left.ResizeIntrinsics();
|
||||
in_right.ResizeIntrinsics();
|
||||
camodocal::CameraPtr camera_odo_ptr_left =
|
||||
models::CameraPtr camera_odo_ptr_left =
|
||||
generateCameraFromIntrinsicsEquidistant(in_left);
|
||||
camodocal::CameraPtr camera_odo_ptr_right =
|
||||
models::CameraPtr camera_odo_ptr_right =
|
||||
generateCameraFromIntrinsicsEquidistant(in_right);
|
||||
auto calib_info_tmp = stereoRectify(camera_odo_ptr_left,
|
||||
camera_odo_ptr_right,
|
||||
|
|
|
@ -23,11 +23,13 @@
|
|||
#include "mynteye/types.h"
|
||||
#include "mynteye/api/processor.h"
|
||||
#include "mynteye/device/device.h"
|
||||
#include <camodocal/camera_models/EquidistantCamera.h>
|
||||
#include <opencv2/core/eigen.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "equidistant_camera.h"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/core/eigen.hpp>
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -76,8 +78,8 @@ class RectifyProcessor : public Processor {
|
|||
|
||||
cv::Mat rectifyrad(const cv::Mat& R);
|
||||
|
||||
void stereoRectify(camodocal::CameraPtr leftOdo,
|
||||
camodocal::CameraPtr rightOdo, const CvMat* K1, const CvMat* K2,
|
||||
void stereoRectify(models::CameraPtr leftOdo,
|
||||
models::CameraPtr rightOdo, const CvMat* K1, const CvMat* K2,
|
||||
const CvMat* D1, const CvMat* D2, CvSize imageSize,
|
||||
const CvMat* matR, const CvMat* matT,
|
||||
CvMat* _R1, CvMat* _R2, CvMat* _P1, CvMat* _P2, double* T_mul_f,
|
||||
|
@ -93,13 +95,13 @@ class RectifyProcessor : public Processor {
|
|||
const mynteye::IntrinsicsEquidistant& in);
|
||||
|
||||
std::shared_ptr<struct CameraROSMsgInfoPair> stereoRectify(
|
||||
camodocal::CameraPtr leftOdo,
|
||||
camodocal::CameraPtr rightOdo,
|
||||
models::CameraPtr leftOdo,
|
||||
models::CameraPtr rightOdo,
|
||||
mynteye::IntrinsicsEquidistant in_left,
|
||||
mynteye::IntrinsicsEquidistant in_right,
|
||||
mynteye::Extrinsics ex_right_to_left);
|
||||
|
||||
camodocal::CameraPtr generateCameraFromIntrinsicsEquidistant(
|
||||
models::CameraPtr generateCameraFromIntrinsicsEquidistant(
|
||||
const mynteye::IntrinsicsEquidistant & in);
|
||||
|
||||
CalibrationModel calib_model;
|
||||
|
|
Loading…
Reference in New Issue
Block a user