From 5bf8109dbc751bacec806ba2c8a77844033d03e4 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Mon, 23 May 2011 12:20:12 +0000 Subject: [PATCH] minor memory optimization in opencv_stitching --- modules/stitching/blenders.cpp | 3 +-- modules/stitching/main.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/stitching/blenders.cpp b/modules/stitching/blenders.cpp index edf9032e3..42c5c7f75 100644 --- a/modules/stitching/blenders.cpp +++ b/modules/stitching/blenders.cpp @@ -160,8 +160,7 @@ void MultiBandBlender::prepare(Rect dst_roi) Blender::prepare(dst_roi); dst_pyr_laplace_.resize(num_bands_ + 1); - dst_pyr_laplace_[0].create(dst_roi.size(), CV_32FC3); - dst_pyr_laplace_[0].setTo(Scalar::all(0)); + dst_pyr_laplace_[0] = dst_; dst_band_weights_.resize(num_bands_ + 1); dst_band_weights_[0].create(dst_roi.size(), CV_32F); diff --git a/modules/stitching/main.cpp b/modules/stitching/main.cpp index 9f2a18b7f..c9960f8bd 100644 --- a/modules/stitching/main.cpp +++ b/modules/stitching/main.cpp @@ -78,7 +78,7 @@ vector img_names; bool trygpu = false; double work_megapix = 0.3; double seam_megapix = 0.1; -double compose_megapix = 1; +double compose_megapix = 6; int ba_space = BundleAdjuster::FOCAL_RAY_SPACE; float conf_thresh = 1.f; bool wave_correct = true; @@ -453,6 +453,7 @@ int main(int argc, char* argv[]) else img = full_img; full_img.release(); + Size img_size = img.size(); // Update cameras paramters cameras[img_idx].focal *= compose_work_aspect; @@ -462,9 +463,10 @@ int main(int argc, char* argv[]) img_warped); img_warped.convertTo(img_warped_f, CV_32F); img_warped.release(); + img.release(); // Warp current image mask - mask.create(img.size(), CV_8U); + mask.create(img_size, CV_8U); mask.setTo(Scalar::all(255)); warper->warp(mask, static_cast(cameras[img_idx].focal), cameras[img_idx].R, mask_warped, INTER_NEAREST, BORDER_CONSTANT);