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
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#include "gpu/testing.hpp"
#include "libvideostitch/panoDef.hpp"
#include "libvideostitch/parse.hpp"
namespace VideoStitch {
namespace Testing {
Core::PanoDefinition* getTestPanoDef() {
Potential<Ptv::Parser> parser = Ptv::Parser::create();
Logger::get(Logger::Info) << "parsing" << std::endl;
if (!parser->parse("data/calibrated_pano_definition.json")) {
Logger::get(Logger::Error) << parser->getErrorMessage() << std::endl;
ENSURE(false, "could not parse");
return nullptr;
}
std::unique_ptr<Core::PanoDefinition> panoDef(Core::PanoDefinition::create(parser->getRoot()));
ENSURE((bool)panoDef);
return panoDef.release();
}
void checkResetGeometry() {
Logger::get(Logger::Info) << "Creating PanoDefinition" << std::endl;
std::unique_ptr<Core::PanoDefinition> panoDef(getTestPanoDef());
Logger::get(Logger::Info) << "Resetting and checking input geometries" << std::endl;
std::vector<double> HFOVs = {90., 100., 110., 120., 130., 140.};
for (int i = 0; i < int(panoDef.get()->numVideoInputs()); ++i) {
Core::InputDefinition& idef = panoDef.get()->getInput(i);
if (idef.getIsVideoEnabled()) {
idef.resetGeometries(HFOVs[i]);
ENSURE_APPROX_EQ(idef.getGeometries().at(0).getEstimatedHorizontalFov(idef), HFOVs[i], .01);
}
}
}
} // namespace Testing
} // namespace VideoStitch
int main() {
VideoStitch::Testing::initTest();
// This checks the consistency of the horizontal field of view after an input is reset.
VideoStitch::Testing::checkResetGeometry();
return 0;
}