AliceVision
Photogrammetric Computer Vision Framework
panoramaMap.hpp
1 // This file is part of the AliceVision project.
2 // Copyright (c) 2020 AliceVision contributors.
3 // This Source Code Form is subject to the terms of the Mozilla Public License,
4 // v. 2.0. If a copy of the MPL was not distributed with this file,
5 // You can obtain one at https://mozilla.org/MPL/2.0/.
6 
7 #pragma once
8 
9 #include "boundingBox.hpp"
10 
11 #include <aliceVision/types.hpp>
12 
13 #include <list>
14 #include <map>
15 
16 namespace aliceVision {
17 
19 {
20  public:
21  PanoramaMap(int width, int height, int scale, int borderSize)
22  : _panoramaWidth(width),
23  _panoramaHeight(height),
24  _scale(scale),
25  _borderSize(borderSize)
26  {}
27 
28  bool append(IndexT index, const BoundingBox& box);
29 
30  bool getOverlaps(std::vector<IndexT>& overlaps, IndexT reference) const;
31 
32  bool getOverlaps(std::vector<IndexT>& overlaps, const BoundingBox& referenceBoundingBox) const;
33 
34  int getWidth() const { return _panoramaWidth; }
35 
36  int getHeight() const { return _panoramaHeight; }
37 
38  size_t getScale() const { return _scale; }
39 
40  size_t getBorderSize() const { return _borderSize; }
41 
42  bool getBoundingBox(BoundingBox& bb, const IndexT& id) const
43  {
44  if (_map.find(id) == _map.end())
45  {
46  return false;
47  }
48 
49  bb = _map.at(id);
50 
51  return true;
52  }
53 
54  bool getIntersectionsList(std::vector<BoundingBox>& intersections,
55  std::vector<BoundingBox>& currentBoundingBoxes,
56  const IndexT& referenceIndex,
57  const IndexT& otherIndex) const;
58 
59  bool getIntersectionsList(std::vector<BoundingBox>& intersections,
60  std::vector<BoundingBox>& currentBoundingBoxes,
61  const BoundingBox& referenceBoundingBox,
62  const IndexT& otherIndex) const;
63 
64  bool optimizeChunks(std::vector<std::vector<IndexT>>& chunks, int chunkSize);
65 
66  private:
67  bool intersect(const BoundingBox& box1, const BoundingBox& box2) const;
68 
69  private:
70  std::map<IndexT, BoundingBox> _map;
71 
72  int _panoramaWidth;
73  int _panoramaHeight;
74  int _scale;
75  int _borderSize;
76 };
77 
78 } // namespace aliceVision
aliceVision::BoundingBox
Definition: boundingBox.hpp:17
aliceVision
Definition: checkerDetector.cpp:32
aliceVision::PanoramaMap
Definition: panoramaMap.hpp:18