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>
30 
32 
33 namespace open3d {
34 namespace camera {
35 
46 };
47 
52 public:
69  int width, int height, double fx, double fy, double cx, double cy);
70  ~PinholeCameraIntrinsic() override;
71 
72 public:
82  int width, int height, double fx, double fy, double cx, double cy) {
83  width_ = width;
84  height_ = height;
85  intrinsic_matrix_.setIdentity();
86  intrinsic_matrix_(0, 0) = fx;
87  intrinsic_matrix_(1, 1) = fy;
88  intrinsic_matrix_(0, 2) = cx;
89  intrinsic_matrix_(1, 2) = cy;
90  }
91 
93  std::pair<double, double> GetFocalLength() const {
94  return std::make_pair(intrinsic_matrix_(0, 0), intrinsic_matrix_(1, 1));
95  }
96 
99  std::pair<double, double> GetPrincipalPoint() const {
100  return std::make_pair(intrinsic_matrix_(0, 2), intrinsic_matrix_(1, 2));
101  }
102 
104  double GetSkew() const { return intrinsic_matrix_(0, 1); }
105 
107  bool IsValid() const { return (width_ > 0 && height_ > 0); }
108 
109  bool ConvertToJsonValue(Json::Value &value) const override;
110  bool ConvertFromJsonValue(const Json::Value &value) override;
111 
112 public:
114  int width_ = -1;
116  int height_ = -1;
122  Eigen::Matrix3d intrinsic_matrix_;
123 };
124 } // namespace camera
125 } // namespace open3d
Eigen::Matrix3d intrinsic_matrix_
Definition: PinholeCameraIntrinsic.h:122
std::pair< double, double > GetPrincipalPoint() const
Definition: PinholeCameraIntrinsic.h:99
std::pair< double, double > GetFocalLength() const
Returns the focal length in a tuple of X-axis and Y-axis focal lengths.
Definition: PinholeCameraIntrinsic.h:93
Contains the pinhole camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:51
Default settings for PrimeSense camera sensor.
void SetIntrinsics(int width, int height, double fx, double fy, double cx, double cy)
Set camera intrinsic parameters.
Definition: PinholeCameraIntrinsic.h:81
double GetSkew() const
Returns the skew.
Definition: PinholeCameraIntrinsic.h:104
bool IsValid() const
Returns true iff both the width and height are greater than 0.
Definition: PinholeCameraIntrinsic.h:107
Definition: Open3DViewer.h:29
PinholeCameraIntrinsicParameters
Sets default camera intrinsic parameters for sensors.
Definition: PinholeCameraIntrinsic.h:39
int height
Definition: FilePCD.cpp:70
int width
Definition: FilePCD.cpp:69
Definition: IJsonConvertible.h:42