Open3D (C++ API)
PinholeCameraIntrinsic.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Core>
31 
32 namespace open3d {
33 namespace camera {
34 
39 };
40 
42 public:
46  int width, int height, double fx, double fy, double cx, double cy);
47  ~PinholeCameraIntrinsic() override;
48 
49 public:
51  int width, int height, double fx, double fy, double cx, double cy) {
52  width_ = width;
53  height_ = height;
54  intrinsic_matrix_.setIdentity();
55  intrinsic_matrix_(0, 0) = fx;
56  intrinsic_matrix_(1, 1) = fy;
57  intrinsic_matrix_(0, 2) = cx;
58  intrinsic_matrix_(1, 2) = cy;
59  }
60 
61  std::pair<double, double> GetFocalLength() const {
62  return std::make_pair(intrinsic_matrix_(0, 0), intrinsic_matrix_(1, 1));
63  }
64 
65  std::pair<double, double> GetPrincipalPoint() const {
66  return std::make_pair(intrinsic_matrix_(0, 2), intrinsic_matrix_(1, 2));
67  }
68 
69  double GetSkew() const { return intrinsic_matrix_(0, 1); }
70 
71  bool IsValid() const { return (width_ > 0 && height_ > 0); }
72 
73  bool ConvertToJsonValue(Json::Value &value) const override;
74  bool ConvertFromJsonValue(const Json::Value &value) override;
75 
76 public:
77  int width_ = -1;
78  int height_ = -1;
79  Eigen::Matrix3d intrinsic_matrix_;
80 };
81 } // namespace camera
82 } // namespace open3d
Eigen::Matrix3d intrinsic_matrix_
Definition: PinholeCameraIntrinsic.h:79
std::pair< double, double > GetPrincipalPoint() const
Definition: PinholeCameraIntrinsic.h:65
std::pair< double, double > GetFocalLength() const
Definition: PinholeCameraIntrinsic.h:61
Definition: PinholeCameraIntrinsic.h:41
void SetIntrinsics(int width, int height, double fx, double fy, double cx, double cy)
Definition: PinholeCameraIntrinsic.h:50
double GetSkew() const
Definition: PinholeCameraIntrinsic.h:69
bool IsValid() const
Definition: PinholeCameraIntrinsic.h:71
Definition: PinholeCameraIntrinsic.cpp:33
PinholeCameraIntrinsicParameters
Definition: PinholeCameraIntrinsic.h:35
int height
Definition: FilePCD.cpp:68
int width
Definition: FilePCD.cpp:67
Definition: IJsonConvertible.h:41