|
14 | 14 | #include <catch2/matchers/catch_matchers_floating_point.hpp>
|
15 | 15 | #include <catch2/matchers/catch_matchers_string.hpp>
|
16 | 16 | #include <catch2/matchers/catch_matchers_vector.hpp>
|
| 17 | + |
17 | 18 | #ifdef XPANO_WITH_EXIV2
|
18 | 19 | #include <exiv2/exiv2.hpp>
|
19 | 20 | #endif
|
|
23 | 24 |
|
24 | 25 | #include "tests/utils.h"
|
25 | 26 | #include "xpano/algorithm/options.h"
|
| 27 | +#include "xpano/algorithm/stitcher.h" |
26 | 28 | #include "xpano/constants.h"
|
27 | 29 |
|
28 | 30 | using Catch::Matchers::Equals;
|
@@ -143,6 +145,60 @@ TEST_CASE("Stitcher pipeline defaults [extra results]") {
|
143 | 145 | CHECK(stitch_result1.cameras->cameras.size() == 3);
|
144 | 146 | }
|
145 | 147 |
|
| 148 | +const std::vector<std::filesystem::path> kInputsFirstPano = { |
| 149 | + "data/image01.jpg", "data/image02.jpg", "data/image03.jpg", |
| 150 | + "data/image04.jpg", "data/image05.jpg"}; |
| 151 | + |
| 152 | +TEST_CASE("Pano too large") { |
| 153 | + xpano::pipeline::StitcherPipeline<kReturnFuture> stitcher; |
| 154 | + |
| 155 | + auto loading_task = stitcher.RunLoading(kInputsFirstPano, {}, {}); |
| 156 | + auto stitch_data = loading_task.future.get(); |
| 157 | + auto progress = loading_task.progress->Report(); |
| 158 | + CHECK(progress.tasks_done == progress.num_tasks); |
| 159 | + |
| 160 | + CHECK(stitch_data.images.size() == 5); |
| 161 | + REQUIRE(stitch_data.panos.size() == 1); |
| 162 | + REQUIRE_THAT(stitch_data.panos[0].ids, Equals<int>({0, 1, 2, 3, 4})); |
| 163 | + |
| 164 | + const float eps = 0.02; |
| 165 | + |
| 166 | + // stitch for the 1st time |
| 167 | + auto proj_options = xpano::algorithm::StitchUserOptions{ |
| 168 | + .projection = {.type = xpano::algorithm::ProjectionType::kPerspective}}; |
| 169 | + auto stitching_task0 = stitcher.RunStitching( |
| 170 | + stitch_data, {.pano_id = 0, .stitch_algorithm = proj_options}); |
| 171 | + |
| 172 | + auto stitch_result0 = stitching_task0.future.get(); |
| 173 | + progress = stitching_task0.progress->Report(); |
| 174 | + CHECK(progress.tasks_done == progress.num_tasks); |
| 175 | + |
| 176 | + REQUIRE(stitch_result0.pano.has_value()); |
| 177 | + CHECK_THAT(stitch_result0.pano->rows, WithinRel(1737, eps)); |
| 178 | + CHECK_THAT(stitch_result0.pano->cols, WithinRel(4303, eps)); |
| 179 | + |
| 180 | + REQUIRE(stitch_result0.cameras.has_value()); |
| 181 | + CHECK(stitch_result0.cameras->cameras.size() == 5); |
| 182 | + |
| 183 | + // rotate and stitch again |
| 184 | + auto rot_data = std::array{0.86f, -0.31f, -0.42f, 0.02f, 0.82f, |
| 185 | + -0.57f, 0.52f, 0.48f, 0.71f}; |
| 186 | + auto rotation_matrix = cv::Mat(3, 3, CV_32F, rot_data.data()); |
| 187 | + |
| 188 | + stitch_data.panos[0].cameras = |
| 189 | + xpano::algorithm::Rotate(*stitch_result0.cameras, rotation_matrix); |
| 190 | + auto stitching_task1 = stitcher.RunStitching( |
| 191 | + stitch_data, {.pano_id = 0, .stitch_algorithm = proj_options}); |
| 192 | + |
| 193 | + auto stitch_result1 = stitching_task1.future.get(); |
| 194 | + progress = stitching_task1.progress->Report(); |
| 195 | + |
| 196 | + REQUIRE(progress.tasks_done != progress.num_tasks); |
| 197 | + REQUIRE_FALSE(stitch_result1.pano.has_value()); |
| 198 | + REQUIRE(stitch_result1.status == |
| 199 | + xpano::algorithm::stitcher::Status::kErrPanoTooLarge); |
| 200 | +} |
| 201 | + |
146 | 202 | TEST_CASE("Stitcher pipeline single pano matching") {
|
147 | 203 | xpano::pipeline::StitcherPipeline<kReturnFuture> stitcher;
|
148 | 204 | auto loading_task = stitcher.RunLoading(
|
|
0 commit comments