ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
PinholeCameraIntrinsic.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 #include <Logging.h>
11 #include <json/json.h>
12 
13 #include <Eigen/Dense>
14 
15 namespace cloudViewer {
16 namespace camera {
17 using namespace cloudViewer;
18 
20  : width_(-1), height_(-1), intrinsic_matrix_(Eigen::Matrix3d::Zero()) {}
21 
23  int width, int height, const Eigen::Matrix3d &intrinsic_matrix)
24  : width_(width), height_(height), intrinsic_matrix_(intrinsic_matrix) {}
25 
27  int width, int height, double fx, double fy, double cx, double cy) {
28  SetIntrinsics(width, height, fx, fy, cx, cy);
29 }
30 
34  SetIntrinsics(640, 480, 525.0, 525.0, 319.5, 239.5);
35  else if (param ==
37  SetIntrinsics(512, 424, 365.456, 365.456, 254.878, 205.395);
38  else if (param ==
40  SetIntrinsics(1920, 1080, 1059.9718, 1059.9718, 975.7193, 545.9533);
41 }
42 
44 
46  value["width"] = width_;
47  value["height"] = height_;
49  value["intrinsic_matrix"]) == false) {
50  return false;
51  }
52  return true;
53 }
54 
56  if (value.isObject() == false) {
58  "PinholeCameraParameters read JSON failed: unsupported json "
59  "format.");
60  return false;
61  }
62  width_ = value.get("width", -1).asInt();
63  height_ = value.get("height", -1).asInt();
65  value["intrinsic_matrix"]) == false) {
67  "PinholeCameraParameters read JSON failed: wrong format.");
68  return false;
69  }
70  return true;
71 }
72 } // namespace camera
73 } // namespace cloudViewer
int width
int height
bool ConvertFromJsonValue(const Json::Value &value) override
bool ConvertToJsonValue(Json::Value &value) const override
void SetIntrinsics(int width, int height, double fx, double fy, double cx, double cy)
Set camera intrinsic parameters.
static bool EigenMatrix3dFromJsonArray(Eigen::Matrix3d &mat, const Json::Value &value)
static bool EigenMatrix3dToJsonArray(const Eigen::Matrix3d &mat, Json::Value &value)
#define LogWarning(...)
Definition: Logging.h:72
Definition: Eigen.h:103
PinholeCameraIntrinsicParameters
Sets default camera intrinsic parameters for sensors.
@ PrimeSenseDefault
Default settings for PrimeSense camera sensor.
@ Kinect2DepthCameraDefault
Default settings for Kinect2 depth camera.
@ Kinect2ColorCameraDefault
Default settings for Kinect2 color camera.
Generic file read and write utility for python interface.
static vtkPVTrivialProducerStaticInternal Value