1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "libvideostitch/config.hpp"
#include <vector>
namespace VideoStitch {
namespace Core {
/**
* Represents an overlap between two inputs. Public API.
*/
class VS_EXPORT Overlap {
public:
virtual ~Overlap() {}
/**
* Returns the number of pixels in the overlap.
*/
virtual int getNumPixels() const = 0;
};
/**
* @brief A class that stores the geometric properties of a panorama setup. Public API.
*
* In particular, it stores the graph of overlaps. Nodes are images, and edges are overlaps.
*
*/
class VS_EXPORT GeometricProps {
public:
virtual ~GeometricProps() {}
/**
* Returns the overlap between two inputs, or NULL if the inputs don't overlap.
* @param firstInput ID of the first input.
* @param secondInput ID of the second input.
*/
virtual const Overlap* getOverlap(videoreaderid_t firstInput, videoreaderid_t secondInput) const = 0;
};
class Node;
class Edge;
/**
* @brief Overlap implementation.
*/
class OverlapImpl : public Overlap {
public:
OverlapImpl() : numPixels(0) {}
virtual int getNumPixels() const { return numPixels; }
void setNumPixels(int n) { numPixels = n; }
private:
int numPixels;
};
/**
* @brief GeometricProps implementation.
*/
class GeometricPropsImpl : public GeometricProps {
public:
virtual ~GeometricPropsImpl();
/**
* Returns the overlap between two inputs.
* @param firstInput First input.
* @param secondInput Second input.
*/
virtual const Overlap* getOverlap(videoreaderid_t firstInput, videoreaderid_t secondInput) const;
/**
* Sets the overlap between two inputs.
* @param firstInput First input.
* @param secondInput Second input.
* @param numPixels Area of the overlap.
*/
void setOverlap(videoreaderid_t firstInput, videoreaderid_t secondInput, int numPixels);
private:
/**
* Returns a node and creates it if needed.
*/
Node* createNodeIfNeeded(videoreaderid_t id);
/**
* Returns the edge between two inputs, and creates it if needed.
* @param firstInput First input.
* @param secondInput Second input.
* @Return THe edge. Ownership is retained.
*/
Edge* createEdgeIfNeeded(videoreaderid_t firstInput, videoreaderid_t secondInput);
Edge* createEdgeIfNeeded(Node* firstNode, Node* secondNode);
std::vector<Node*> nodes; // All nodes are owned here.
std::vector<Edge*> edges; // All edges are owned here.
};
} // namespace Core
} // namespace VideoStitch