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
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "textureTarget.hpp"
#include "gpu/buffer.hpp"
#include "gpu/stream.hpp"
#include "libvideostitch/status.hpp"
#include "libvideostitch/ptv.hpp"
#include "core/pyramid.hpp"
#include <memory>
#include <vector>
namespace VideoStitch {
namespace Core {
class PanoDefinition;
class ImageMapping;
class ImageMerger;
class MaskMerger {
public:
enum class MaskMergerType {
VoronoiMask = 0 // Voronoi Mask
};
static MaskMergerType getDefaultMaskMerger();
MaskMerger();
static MaskMerger* factor(const MaskMergerType maskMergerType);
~MaskMerger();
virtual Status setParameters(const std::vector<double>& params) = 0;
Status setupMask(const PanoDefinition& pano, GPU::Buffer<const uint32_t> panoDevOut, const ImageMapping& fromIm,
const ImageMerger* const to, GPU::Stream stream);
Status setupMaskCubemap(const PanoDefinition& pano, GPU::Buffer<const uint32_t> panoDevOut,
const ImageMapping& fromIm, const ImageMerger* const to, GPU::Stream stream);
/**
* Called inside ImageMerger::prepareMergeAsync
* This function is called for MaskMerger that would change overtime
*/
virtual Status updateAsync() = 0;
GPU::Buffer<unsigned char> getAlpha(TextureTarget) const;
/**
* Construct a pyramid of the generated mask, used for multi-scale based mergers.
* This function should be called inside "ImageMerger::prepareMergeAsync"
* and after "MaskMerger::Async" was called
*/
Status buildPyramidMask(const ImageMapping&, std::string name, const int numLevels, const int gaussianRadius,
const int filterPasses, const bool warp, GPU::Stream stream);
Status buildPyramidMaskCubemap(const PanoDefinition&, const ImageMapping&, std::string name, const int numLevels,
const int gaussianRadius, const int filterPasses, const bool warp, GPU::Stream stream);
LaplacianPyramid<unsigned char>* getAlphaPyramid(TextureTarget) const;
protected:
/**
* Setup from the panorama setup mask. Asynchronous.
* This function is "normally" called inside ImageMerger::setup
* @return false on failure.
*/
virtual Status setup(const PanoDefinition&, GPU::Buffer<const uint32_t> inputsMask, const ImageMapping& fromIm,
const ImageMerger* const to, GPU::Stream) = 0;
std::array<GPU::UniqueBuffer<unsigned char>, 7> alpha;
std::array<std::unique_ptr<LaplacianPyramid<unsigned char>>, 7> alphaPyramids;
};
} // namespace Core
} // namespace VideoStitch