diff --git a/CMakeLists.txt b/CMakeLists.txt index cce8496..be04407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/Makefile b/Makefile index 08fb860..2e28fa6 100644 --- a/Makefile +++ b/Makefile @@ -25,16 +25,11 @@ MKFILE_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH))) # Options # # SUDO: sudo command -# CAM_MODELS: cmake build with -DWITH_CAM_MODELS=ON # # e.g. make [TARGET] SUDO= -# e.g. make [TARGET] CAM_MODELS=1 SUDO ?= sudo - -CAM_MODELS ?= - -CMAKE_BUILD_EXTRA_OPTIONS := $(CMAKE_BUILD_EXTRA_OPTIONS) -DWITH_CAM_MODELS=ON +CMAKE_BUILD_EXTRA_OPTIONS ?= .DEFAULT_GOAL := all diff --git a/cmake/Option.cmake b/cmake/Option.cmake index 658915b..d9c9104 100644 --- a/cmake/Option.cmake +++ b/cmake/Option.cmake @@ -23,7 +23,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake) option(WITH_API "Build with API layer, need OpenCV" ON) option(WITH_DEVICE_INFO_REQUIRED "Build with device info required" ON) -option(WITH_CAM_MODELS "Build with more camera models, WITH_API must be ON" OFF) +option(WITH_CAM_MODELS "Build with more camera models, WITH_API must be ON" ON) # 3rdparty components diff --git a/samples/tutorials/data/get_img_params.cc b/samples/tutorials/data/get_img_params.cc index a12cc48..0ad070e 100644 --- a/samples/tutorials/data/get_img_params.cc +++ b/samples/tutorials/data/get_img_params.cc @@ -48,8 +48,10 @@ int main(int argc, char *argv[]) { auto info = api->GetCameraROSMsgInfoPair(); - if (info && !info->isEmpty()) - std::cout << "ROSMsgInfoPair:"<< std::endl << *info << std::endl; + if (info && !info->isEmpty()) { + LOG(INFO) << "ROSMsgInfoPair:"; + LOG(INFO) << *info; + } return 0; } diff --git a/src/mynteye/api/api.cc b/src/mynteye/api/api.cc index f122c23..a5c7ec6 100644 --- a/src/mynteye/api/api.cc +++ b/src/mynteye/api/api.cc @@ -90,7 +90,10 @@ bool dir_exists(const std::string &p) { std::vector get_plugin_paths() { std::string info_path = utils::get_sdk_install_dir(); - info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info"); + if (info_path.empty()) return {}; + + info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" + MYNTEYE_OS_SEP "build.info"); cv::FileStorage fs(info_path, cv::FileStorage::READ); if (!fs.isOpened()) { @@ -332,17 +335,7 @@ std::string API::GetInfo(const Info &info) const { } std::string API::GetSDKVersion() const { - std::string info_path = - utils::get_sdk_install_dir(); - info_path.append(MYNTEYE_OS_SEP "share" \ - MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info"); - - cv::FileStorage fs(info_path, cv::FileStorage::READ); - if (!fs.isOpened()) { - LOG(WARNING) << "build.info not found: " << info_path; - return "null"; - } - return fs["MYNTEYE_VERSION"]; + return MYNTEYE_API_VERSION_STR; } IntrinsicsPinhole API::GetIntrinsics(const Stream &stream) const { diff --git a/src/mynteye/api/camodocal/src/camera_models/Camera.cc b/src/mynteye/api/camera_models/camera.cc similarity index 98% rename from src/mynteye/api/camodocal/src/camera_models/Camera.cc rename to src/mynteye/api/camera_models/camera.cc index 05e06a1..fa062d9 100644 --- a/src/mynteye/api/camodocal/src/camera_models/Camera.cc +++ b/src/mynteye/api/camera_models/camera.cc @@ -12,9 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. #include -#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 diff --git a/src/mynteye/api/camodocal/include/camodocal/camera_models/Camera.h b/src/mynteye/api/camera_models/camera.h similarity index 94% rename from src/mynteye/api/camodocal/include/camodocal/camera_models/Camera.h rename to src/mynteye/api/camera_models/camera.h index 6ccc943..c8d4607 100644 --- a/src/mynteye/api/camodocal/include/camodocal/camera_models/Camera.h +++ b/src/mynteye/api/camera_models/camera.h @@ -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 #include #include "eigen3/Eigen/Dense" #include -namespace camodocal { +#include "mynteye/mynteye.h" + +MYNTEYE_BEGIN_NAMESPACE + +namespace models { class Camera { public: @@ -134,5 +138,7 @@ typedef std::shared_ptr CameraPtr; typedef std::shared_ptr CameraConstPtr; } -#endif // SRC_MYNTEYE_API_CAMODOCAL_INCLUDE_CAMODOCAL_CAMERA_MODELS_CAMERA_H_ +MYNTEYE_END_NAMESPACE + +#endif // MYNTEYE_CAMERA_MODELS_CAMERA_H_ diff --git a/src/mynteye/api/camodocal/src/camera_models/EquidistantCamera.cc b/src/mynteye/api/camera_models/equidistant_camera.cc similarity index 99% rename from src/mynteye/api/camodocal/src/camera_models/EquidistantCamera.cc rename to src/mynteye/api/camera_models/equidistant_camera.cc index 34ff08f..57eb3c1 100644 --- a/src/mynteye/api/camodocal/src/camera_models/EquidistantCamera.cc +++ b/src/mynteye/api/camera_models/equidistant_camera.cc @@ -16,15 +16,19 @@ #include #include #include -#include "camodocal/camera_models/EquidistantCamera.h" + #include "eigen3/Eigen/Dense" #include #include #include -#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 diff --git a/src/mynteye/api/camodocal/include/camodocal/camera_models/EquidistantCamera.h b/src/mynteye/api/camera_models/equidistant_camera.h similarity index 92% rename from src/mynteye/api/camodocal/include/camodocal/camera_models/EquidistantCamera.h rename to src/mynteye/api/camera_models/equidistant_camera.h index 029a59d..72d694c 100644 --- a/src/mynteye/api/camodocal/include/camodocal/camera_models/EquidistantCamera.h +++ b/src/mynteye/api/camera_models/equidistant_camera.h @@ -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 -#include "Camera.h" #include -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_ diff --git a/src/mynteye/api/camodocal/src/gpl/gpl.cc b/src/mynteye/api/camera_models/gpl.cc similarity index 96% rename from src/mynteye/api/camodocal/src/gpl/gpl.cc rename to src/mynteye/api/camera_models/gpl.cc index 591b00d..d570a02 100644 --- a/src/mynteye/api/camodocal/src/gpl/gpl.cc +++ b/src/mynteye/api/camera_models/gpl.cc @@ -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 #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 diff --git a/src/mynteye/api/camodocal/include/camodocal/gpl/gpl.h b/src/mynteye/api/camera_models/gpl.h similarity index 89% rename from src/mynteye/api/camodocal/include/camodocal/gpl/gpl.h rename to src/mynteye/api/camera_models/gpl.h index b5b555c..a6bc31b 100644 --- a/src/mynteye/api/camodocal/include/camodocal/gpl/gpl.h +++ b/src/mynteye/api/camera_models/gpl.h @@ -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 #include #include #include -namespace camodocal { +#include "mynteye/mynteye.h" + +MYNTEYE_BEGIN_NAMESPACE + +namespace models { template 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_ diff --git a/src/mynteye/api/processor/rectify_processor.cc b/src/mynteye/api/processor/rectify_processor.cc index 05a1b47..9aad0fa 100644 --- a/src/mynteye/api/processor/rectify_processor.cc +++ b/src/mynteye/api/processor/rectify_processor.cc @@ -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 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 RectifyProcessor::stereoRectify( return std::make_shared(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, diff --git a/src/mynteye/api/processor/rectify_processor.h b/src/mynteye/api/processor/rectify_processor.h index acf1318..6c65259 100644 --- a/src/mynteye/api/processor/rectify_processor.h +++ b/src/mynteye/api/processor/rectify_processor.h @@ -23,11 +23,13 @@ #include "mynteye/types.h" #include "mynteye/api/processor.h" #include "mynteye/device/device.h" -#include -#include -#include -#include + +#include "equidistant_camera.h" + #include +#include +#include +#include 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 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; diff --git a/src/mynteye/api/synthetic.cc b/src/mynteye/api/synthetic.cc index 5fdc446..d97f4a4 100644 --- a/src/mynteye/api/synthetic.cc +++ b/src/mynteye/api/synthetic.cc @@ -65,7 +65,7 @@ void Synthetic::InitCalibInfo() { } else { calib_default_tag_ = true; calib_model_ = CalibrationModel::PINHOLE; - LOG(INFO) << "camera calib model: unknow ,use default pinhole data"; + LOG(INFO) << "camera calib model: unknow, use default pinhole data"; intr_left_ = getDefaultIntrinsics(); intr_right_ = getDefaultIntrinsics(); extr_ = getDefaultExtrinsics(); diff --git a/src/mynteye/types.cc b/src/mynteye/types.cc index a92671c..d31f56f 100644 --- a/src/mynteye/types.cc +++ b/src/mynteye/types.cc @@ -313,13 +313,14 @@ std::ostream &operator<<(std::ostream &os, const Extrinsics &ex) { } std::ostream &operator<<(std::ostream &os, const OptionInfo &info) { - return os << "min: " << info.min << ", max: " << info.max + return os << FULL_PRECISION << "min: " << info.min << ", max: " << info.max << ", def: " << info.def; } std::ostream &operator<<(std::ostream &os, const CameraROSMsgInfo &info) { - os << "width: " << info.width << ", height: " << info.height << std::endl - << "distortion_model: " << info.distortion_model; + os << FULL_PRECISION << "width: " << info.width << ", height: " + << info.height << std::endl << "distortion_model: " + << info.distortion_model; os << std::endl << "D: "; for (size_t i = 0; i < 5; i++) os << info.D[i] << ","; diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard.yaml b/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard.yaml index d02323b..39801af 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard.yaml +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/config/device/standard.yaml @@ -1,5 +1,5 @@ # standard/gain range: [0,48] -sstandard/gain: -1 +standard/gain: -1 # standard/gain: 24 # standard/brightness range: [0,240] diff --git a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc index 34e67bb..9d1d3c3 100644 --- a/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc +++ b/wrappers/ros/src/mynt_eye_ros_wrapper/src/wrapper_nodelet.cc @@ -843,7 +843,7 @@ class ROSWrapperNodelet : public nodelet::Nodelet { // return; auto &&in = api_->GetIntrinsicsBase(Stream::LEFT); - + in -> ResizeIntrinsics(); sensor_msgs::PointCloud2 msg; msg.header.seq = seq; msg.header.stamp = stamp;