Skip to content

Commit 149f56d

Browse files
authored
Make max panorama size user selectable (#129)
* Make max panorama size user selectable * Fix formatting * Make clang-tidy happy
1 parent e4464fd commit 149f56d

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

xpano/algorithm/algorithm.cc

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ StitchResult Stitch(const std::vector<cv::Mat>& images,
260260
false, user_options.match_conf));
261261
stitcher->SetWaveCorrection(user_options.wave_correction !=
262262
WaveCorrectionType::kOff);
263+
stitcher->SetMaxPanoSize(user_options.max_pano_size);
263264
if (stitcher->WaveCorrection()) {
264265
stitcher->SetWaveCorrectKind(
265266
PickWaveCorrectKind(user_options.wave_correction));

xpano/algorithm/options.h

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct StitchUserOptions {
8484
FeatureType feature = FeatureType::kSift;
8585
WaveCorrectionType wave_correction = WaveCorrectionType::kAuto;
8686
float match_conf = kDefaultMatchConf;
87+
int max_pano_size = kMaxPanoSize;
8788
BlendingMethod blending_method = kDefaultBlendingMethod;
8889
};
8990

xpano/algorithm/stitcher.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ Status Stitcher::ComposePanorama(cv::OutputArray pano) {
291291
}
292292
auto dst_roi = cv::detail::resultRoi(corners, sizes);
293293

294-
if (dst_roi.width >= kMaxPanoSize || dst_roi.height >= kMaxPanoSize) {
294+
if (dst_roi.width >= max_pano_size_ || dst_roi.height >= max_pano_size_) {
295295
spdlog::error("Panorama is too large to compute: {}x{}, max size is {}",
296-
dst_roi.width, dst_roi.height, kMaxPanoSize);
296+
dst_roi.width, dst_roi.height, max_pano_size_);
297297
return Status::kErrPanoTooLarge;
298298
}
299299

xpano/algorithm/stitcher.h

+4
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class Stitcher {
135135
features_matcher_ = features_matcher;
136136
}
137137

138+
[[nodiscard]] int MaxPanoSize() const { return max_pano_size_; }
139+
void SetMaxPanoSize(int max_pano_size) { max_pano_size_ = max_pano_size; }
140+
138141
[[nodiscard]] const cv::UMat& MatchingMask() const { return matching_mask_; }
139142
void SetMatchingMask(const cv::UMat& mask) {
140143
CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
@@ -272,6 +275,7 @@ class Stitcher {
272275

273276
ProgressMonitor* monitor_ = nullptr;
274277
WarpHelper warp_helper_ = {};
278+
int max_pano_size_;
275279
};
276280

277281
} // namespace xpano::algorithm::stitcher

xpano/constants.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ constexpr int kCancelAnimationFrameDuration = 128;
103103
const std::string kGithubIssuesLink = "https://github.com/krupkat/xpano/issues";
104104
const std::string kAuthorEmail = "[email protected]";
105105

106-
const int kMaxPanoSize = 16384;
106+
constexpr int kMaxPanoSize = 16384;
107+
constexpr int kMaxPanoSizeStep = 256;
107108

108109
} // namespace xpano

xpano/gui/panels/sidebar.cc

+13
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ Action DrawBlendingOptions(pipeline::StitchAlgorithmOptions* stitch_options) {
330330
return action;
331331
}
332332

333+
Action DrawMaxPanoSizeOptions(
334+
pipeline::StitchAlgorithmOptions* stitch_options) {
335+
Action action{};
336+
ImGui::Text("Max panorama size:");
337+
ImGui::Spacing();
338+
if (ImGui::InputInt("Max panorama size", &stitch_options->max_pano_size,
339+
kMaxPanoSizeStep)) {
340+
action |= {ActionType::kRecomputePano};
341+
}
342+
return action;
343+
}
344+
333345
Action DrawStitchOptionsMenu(pipeline::StitchAlgorithmOptions* stitch_options,
334346
bool debug_enabled) {
335347
Action action{};
@@ -340,6 +352,7 @@ Action DrawStitchOptionsMenu(pipeline::StitchAlgorithmOptions* stitch_options,
340352
if (debug_enabled) {
341353
ImGui::SeparatorText("Debug");
342354
action |= DrawBlendingOptions(stitch_options);
355+
action |= DrawMaxPanoSizeOptions(stitch_options);
343356
action |= DrawFeatureMatchingOptions(stitch_options);
344357

345358
if (DrawMatchConf(&stitch_options->match_conf)) {

0 commit comments

Comments
 (0)