Merge branch 'develop' of http://gitlab.mynt.com/mynteye/mynt-eye-s-sdk into develop

This commit is contained in:
Osenberg 2019-07-01 11:57:27 +08:00
commit 19c604702f
17 changed files with 105 additions and 76 deletions

View File

@ -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})

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -90,7 +90,10 @@ bool dir_exists(const std::string &p) {
std::vector<std::string> 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 {

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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_

View File

@ -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,

View File

@ -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;

View File

@ -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();

View File

@ -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] << ",";

View File

@ -1,5 +1,5 @@
# standard/gain range: [0,48]
sstandard/gain: -1
standard/gain: -1
# standard/gain: 24
# standard/brightness range: [0,240]

View File

@ -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;