提交 309b76e7 编写于 作者: J jmtao 提交者: Liangliang Zhang

perception: migrate omnidirectional_model/polynomial and tests

上级 78a34322
......@@ -165,6 +165,35 @@ cc_test(
],
)
cc_library(
name = "omnidirectional_model",
hdrs = [
"omnidirectional_model.h",
],
srcs = [
"omnidirectional_model.cc",
],
deps = [
":camera",
":distortion_model",
":polynomial",
"//framework:cybertron",
"@eigen",
],
)
cc_test(
name = "omnidirectional_model_test",
size = "small",
srcs = [
"omnidirectional_model_test.cc",
],
deps = [
":omnidirectional_model",
"@gtest//:main",
],
)
cc_library(
name = "point_cloud",
hdrs = [
......@@ -189,6 +218,30 @@ cc_test(
],
)
cc_library(
name = "polynomial",
hdrs = [
"polynomial.h",
],
srcs = [
"polynomial.cc",
],
deps = [
],
)
cc_test(
name = "polynomial_test",
size = "small",
srcs = [
"polynomial_test.cc",
],
deps = [
":polynomial",
"@gtest//:main",
],
)
cc_library(
name = "syncedmem",
srcs = [
......
......@@ -14,6 +14,7 @@
* limitations under the License.
*****************************************************************************/
#include "modules/perception/base/distortion_model.h"
#include <cmath>
#include "cybertron/common/log.h"
......
......@@ -14,11 +14,13 @@
* limitations under the License.
*****************************************************************************/
#include "modules/perception/base/omnidirectional_model.h"
#include "modules/perception/base/camera.h"
#include "polynomial.h"
#include <cmath>
#include "modules/perception/base/log.h"
#include <limits>
#include "cybertron/common/log.h"
#include "modules/perception/base/camera.h"
#include "modules/perception/base/polynomial.h"
namespace apollo {
namespace perception {
......@@ -56,7 +58,7 @@ Eigen::Vector2f OmnidirectionalCameraDistortionModel::Project(
std::shared_ptr<BaseCameraModel>
OmnidirectionalCameraDistortionModel::get_camera_model() {
PinholeCameraModelPtr camera_model(new PinholeCameraModel());
std::shared_ptr<PinholeCameraModel> camera_model(new PinholeCameraModel());
camera_model->set_width(width_);
camera_model->set_height(height_);
camera_model->set_intrinsic_params(intrinsic_params_);
......@@ -67,25 +69,25 @@ std::shared_ptr<BaseCameraModel>
bool OmnidirectionalCameraDistortionModel::set_params(
size_t width, size_t height, const Eigen::VectorXf& params) {
if (params.size() < 9) {
LOG_INFO << "Missing cam2world and world2cam model.";
AINFO << "Missing cam2world and world2cam model.";
return false;
}
uint32_t cam2world_order = uint32_t(params(8));
LOG_INFO << "cam2world order: " << cam2world_order
<< ", size: " << params.size() << std::endl;
AINFO << "cam2world order: " << cam2world_order
<< ", size: " << params.size() << std::endl;
if (params.size() < 9 + cam2world_order + 1) {
LOG_INFO << "Incomplete cam2world model or missing world2cam model.";
AINFO << "Incomplete cam2world model or missing world2cam model.";
return false;
}
uint32_t world2cam_order = uint32_t(params(9 + cam2world_order));
LOG_INFO << "world2cam order: " << world2cam_order
<< ", size: " << params.size() << std::endl;
AINFO << "world2cam order: " << world2cam_order
<< ", size: " << params.size() << std::endl;
if (params.size() < 9 + cam2world_order + 1 + world2cam_order) {
LOG_INFO << "Incomplete world2cam model.";
AINFO << "Incomplete world2cam model.";
return false;
}
......
......@@ -51,10 +51,12 @@ class OmnidirectionalCameraDistortionModel : public BaseCameraDistortionModel {
float affine_[3]; // c, d, e
};
/* TODO(all): to remove
typedef std::shared_ptr<OmnidirectionalCameraDistortionModel>
OmnidirectionalCameraDistortionModelPtr;
typedef std::shared_ptr<const OmnidirectionalCameraDistortionModel>
OmnidirectionalCameraDistortionModelConstPtr;
*/
} // namespace base
} // namespace perception
......
......@@ -14,7 +14,6 @@
* limitations under the License.
*****************************************************************************/
#include "modules/perception/base/polynomial.h"
#include <vector>
namespace apollo {
namespace perception {
......@@ -52,7 +51,7 @@ double Polynomial::operator()(const double& x) {
for (auto& item : power_cache_) {
item.second = x;
for (int i = 0; i < item.first - 1; ++i) {
for (size_t i = 0; i < item.first - 1; ++i) {
item.second *= x;
}
}
......@@ -71,7 +70,7 @@ double Polynomial::operator()(const double& x) {
std::ostream& operator<<(std::ostream& o, const Polynomial& p) {
const std::map<uint32_t, double>& coeff = p.getCoeff();
int i = 0;
size_t i = 0;
for (auto it = coeff.rbegin(); it != coeff.rend(); ++it) {
const uint32_t& order = it->first;
const double& c = it->second;
......@@ -86,6 +85,6 @@ std::ostream& operator<<(std::ostream& o, const Polynomial& p) {
return o;
}
} // base
} // perception
} // apollo
} // namespace base
} // namespace perception
} // namespace apollo
......@@ -43,8 +43,8 @@ class Polynomial {
std::ostream& operator<<(std::ostream& o, const Polynomial& p);
} // base
} // perception
} // apollo
} // namespace base
} // namespace perception
} // namespace apollo
#endif
#endif // MODULES_PERCEPTION_BASE_POLYNOMIAL_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册