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
104
105
106
107
108
109
110
111
112
113
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#pragma once
#include "videoPipeline.hpp"
#include "panoStitcherBase.hpp"
#include "libvideostitch/gpu_device.hpp"
#include "libvideostitch/matrix.hpp"
#include "libvideostitch/stitchOutput.hpp"
#include <thread>
namespace VideoStitch {
namespace Core {
class PanoDefinition;
/**
* Implementation of a stereoscopic video pipeline.
*
* Forward asynchronously the request to the left and right
* Stitchers.
*/
class StereoPipeline : public VideoPipeline {
public:
typedef StereoOutput Output;
typedef StereoDeviceDefinition DeviceDefinition;
virtual ~StereoPipeline();
static Potential<StereoPipeline> createStereoPipeline(PanoStitcherImplBase<StereoOutput>* left,
PanoStitcherImplBase<StereoOutput>* right,
const std::vector<Input::VideoReader*>& readers,
const std::vector<PreProcessor*>& preprocs,
PostProcessor* postproc);
/**
* Stitches a full stereoscopic panorama image.
* @param output Where to write the output.
* @param readFrame If false, the stitcher will not read the next frame but will restitch the last frame.
* @return True on success.
*/
virtual Status stitch(mtime_t date, frameid_t frame, std::map<readerid_t, Input::PotentialFrame>& inputBuffers,
StereoOutput* output);
/**
* Stitches a full panorama image and extracts the input frames.
* @param output Where to write the panorama.
* @param extracts Which frames to write and where to write them.
* @return false on failure.
*/
virtual Status stitchAndExtract(mtime_t date, FrameRate frameRate,
std::map<readerid_t, Input::PotentialFrame>& inputBuffers, StereoOutput* output,
std::vector<ExtractOutput*> extracts, AlgorithmOutput* algo);
/**
* Computes the level of compatibility between two PanoDefinitions.
* @param pano reference pano
* @param newPano new pano
*/
virtual ChangeCompatibility getCompatibility(const PanoDefinition& pano, const PanoDefinition& newPano) const {
return leftStitcher->getCompatibility(pano, newPano);
}
virtual void applyRotation(double yaw, double pitch, double roll) {
leftStitcher->applyRotation(yaw, pitch, roll);
rightStitcher->applyRotation(yaw, pitch, roll);
}
virtual void resetRotation() {
leftStitcher->resetRotation();
rightStitcher->resetRotation();
}
virtual Quaternion<double> getRotation() const { return leftStitcher->getRotation(); }
/**
* Setup the panoStitcher.
* @param mergerFactory Used to create mergers. Can be released after the call.
* Returns true on success.
*/
Status setup(const ImageMergerFactory& mergerFactory, const ImageWarperFactory& warperFactory,
const ImageFlowFactory& flowFactory, const StereoRigDefinition*);
/**
* Re-setup the panoStitcher. This is less expensive that destroying and setting up, but is not compatible with all
* changes (see controller::resetPano()); Returns true on success.
*/
Status redoSetup(const PanoDefinition& pano, const ImageMergerFactory& mergerFactory,
const ImageWarperFactory& warperFactory, const ImageFlowFactory& flowFactory,
const StereoRigDefinition* rig) {
FAIL_RETURN(rightStitcher->redoSetup(pano, mergerFactory, warperFactory, flowFactory, readers, rig));
return leftStitcher->redoSetup(pano, mergerFactory, warperFactory, flowFactory, readers, rig);
}
void setPano(const PanoDefinition& p) {
leftStitcher->setPano(p);
rightStitcher->setPano(p);
}
const Matrix33<double>& getInteractivePersp() const { return leftStitcher->getInteractivePersp(); }
private:
StereoPipeline(PanoStitcherImplBase<StereoOutput>* left, PanoStitcherImplBase<StereoOutput>* right,
const std::vector<Input::VideoReader*>&, const std::vector<PreProcessor*>&, PostProcessor*);
PanoStitcherImplBase<StereoOutput>*leftStitcher, *rightStitcher;
std::thread leftThread, rightThread;
StereoPipeline& operator=(const StereoPipeline&);
};
} // namespace Core
} // namespace VideoStitch