Blender  V3.3
reconstruction_scale.cc
Go to the documentation of this file.
1 // Copyright (c) 2013 libmv authors.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to
5 // deal in the Software without restriction, including without limitation the
6 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 // sell copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 // IN THE SOFTWARE.
20 
22 #include "libmv/logging/logging.h"
23 
24 namespace libmv {
25 
29 
30  // Calculate center of the mass of all cameras.
31  Vec3 cameras_mass_center = Vec3::Zero();
32  for (int i = 0; i < all_cameras.size(); ++i) {
33  cameras_mass_center += all_cameras[i].t;
34  }
35  cameras_mass_center /= all_cameras.size();
36 
37  // Find the most distant camera from the mass center.
38  double max_distance = 0.0;
39  for (int i = 0; i < all_cameras.size(); ++i) {
40  double distance = (all_cameras[i].t - cameras_mass_center).squaredNorm();
41  if (distance > max_distance) {
42  max_distance = distance;
43  }
44  }
45 
46  if (max_distance == 0.0) {
47  LG << "Cameras position variance is too small, can not rescale";
48  return;
49  }
50 
51  double scale_factor = 1.0 / sqrt(max_distance);
52 
53  // Rescale cameras positions.
54  for (int i = 0; i < all_cameras.size(); ++i) {
55  int image = all_cameras[i].image;
57  camera->t = camera->t * scale_factor;
58  }
59 
60  // Rescale points positions.
61  for (int i = 0; i < all_points.size(); ++i) {
62  int track = all_points[i].track;
64  point->X = point->X * scale_factor;
65  }
66 }
67 
68 } // namespace libmv
sqrt(x)+1/max(0
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
vector< ProjectivePoint > AllPoints() const
Returns all points.
vector< ProjectiveCamera > AllCameras() const
Returns all cameras.
ProjectivePoint * PointForTrack(int track)
Returns a pointer to the point corresponding to track.
ProjectiveCamera * CameraForImage(int image)
Returns a pointer to the camera corresponding to image.
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img image(1, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D_ARRAY, "out_weight_img") .image(3
const ProjectiveReconstruction & reconstruction
Definition: intersect.cc:198
#define LG
T distance(const T &a, const T &b)
void EuclideanScaleToUnity(EuclideanReconstruction *reconstruction)
Eigen::Vector3d Vec3
Definition: numeric.h:106