Apollo 10.0
自动驾驶开放平台
camera.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <memory>
20#include <string>
21
22#include "Eigen/Core"
23
24namespace apollo {
25namespace perception {
26namespace base {
27
29 public:
30 virtual ~BaseCameraModel() = default;
31
32 virtual Eigen::Vector2f Project(const Eigen::Vector3f& point3d) = 0;
33 virtual Eigen::Vector3f UnProject(const Eigen::Vector2f& point2d) = 0;
34 virtual std::string name() const = 0;
35
36 inline void set_width(size_t width) { image_width_ = width; }
37 inline void set_height(size_t height) { image_height_ = height; }
38
39 inline size_t get_width() const { return image_width_; }
40 inline size_t get_height() const { return image_height_; }
41
42 protected:
43 size_t image_width_ = 0;
44 size_t image_height_ = 0;
45};
46
48 public:
49 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
50
51 public:
53
54 Eigen::Vector2f Project(const Eigen::Vector3f& point3d) override;
55 Eigen::Vector3f UnProject(const Eigen::Vector2f& point2d) override;
56 std::string name() const override { return "PinholeCameraModel"; }
57
58 inline void set_intrinsic_params(const Eigen::Matrix3f& params) {
59 intrinsic_params_ = params;
60 }
61
62 inline Eigen::Matrix3f get_intrinsic_params() const {
63 return intrinsic_params_;
64 }
65
66 protected:
67 /* fx 0 cx
68 0 fy cy
69 0 0 1
70 */
71 Eigen::Matrix3f intrinsic_params_;
72};
73
74// TODO(all) remove later
75typedef std::shared_ptr<BaseCameraModel> BaseCameraModelPtr;
76typedef std::shared_ptr<const BaseCameraModel> BaseCameraModelConstPtr;
77typedef std::shared_ptr<PinholeCameraModel> PinholeCameraModelPtr;
78typedef std::shared_ptr<const PinholeCameraModel> PinholeCameraModelConstPtr;
79
80} // namespace base
81} // namespace perception
82} // namespace apollo
virtual std::string name() const =0
virtual Eigen::Vector2f Project(const Eigen::Vector3f &point3d)=0
virtual Eigen::Vector3f UnProject(const Eigen::Vector2f &point2d)=0
Eigen::Matrix3f get_intrinsic_params() const
Definition camera.h:62
void set_intrinsic_params(const Eigen::Matrix3f &params)
Definition camera.h:58
Eigen::Vector2f Project(const Eigen::Vector3f &point3d) override
Definition camera.cc:23
Eigen::Vector3f UnProject(const Eigen::Vector2f &point2d) override
Definition camera.cc:34
std::string name() const override
Definition camera.h:56
std::shared_ptr< BaseCameraModel > BaseCameraModelPtr
Definition camera.h:75
std::shared_ptr< PinholeCameraModel > PinholeCameraModelPtr
Definition camera.h:77
std::shared_ptr< const BaseCameraModel > BaseCameraModelConstPtr
Definition camera.h:76
std::shared_ptr< const PinholeCameraModel > PinholeCameraModelConstPtr
Definition camera.h:78
class register implement
Definition arena_queue.h:37