stitching: extend logging
This commit is contained in:
parent
a7f69a37e3
commit
c22d92c1cb
@ -248,7 +248,11 @@ void MultiBandBlender::prepare(Rect dst_roi)
|
||||
|
||||
void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||
{
|
||||
Mat img = _img.getMat();
|
||||
#if ENABLE_LOG
|
||||
int64 t = getTickCount();
|
||||
#endif
|
||||
|
||||
UMat img = _img.getUMat();
|
||||
CV_Assert(img.type() == CV_16SC3 || img.type() == CV_8UC3);
|
||||
CV_Assert(mask.type() == CV_8U);
|
||||
|
||||
@ -286,12 +290,22 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||
UMat img_with_border;
|
||||
copyMakeBorder(_img, img_with_border, top, bottom, left, right,
|
||||
BORDER_REFLECT);
|
||||
LOGLN(" Add border to the source image, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
t = getTickCount();
|
||||
#endif
|
||||
|
||||
std::vector<UMat> src_pyr_laplace;
|
||||
if (can_use_gpu_ && img_with_border.depth() == CV_16S)
|
||||
createLaplacePyrGpu(img_with_border, num_bands_, src_pyr_laplace);
|
||||
else
|
||||
createLaplacePyr(img_with_border, num_bands_, src_pyr_laplace);
|
||||
|
||||
LOGLN(" Create the source image Laplacian pyramid, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
t = getTickCount();
|
||||
#endif
|
||||
|
||||
// Create the weight map Gaussian pyramid
|
||||
UMat weight_map;
|
||||
std::vector<UMat> weight_pyr_gauss(num_bands_ + 1);
|
||||
@ -313,6 +327,11 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||
for (int i = 0; i < num_bands_; ++i)
|
||||
pyrDown(weight_pyr_gauss[i], weight_pyr_gauss[i + 1]);
|
||||
|
||||
LOGLN(" Create the weight map Gaussian pyramid, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
t = getTickCount();
|
||||
#endif
|
||||
|
||||
int y_tl = tl_new.y - dst_roi_.y;
|
||||
int y_br = br_new.y - dst_roi_.y;
|
||||
int x_tl = tl_new.x - dst_roi_.x;
|
||||
@ -348,7 +367,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||
x_br /= 2; y_br /= 2;
|
||||
}
|
||||
}
|
||||
else// weight_type_ == CV_16S
|
||||
else // weight_type_ == CV_16S
|
||||
{
|
||||
for (int i = 0; i <= num_bands_; ++i)
|
||||
{
|
||||
@ -377,6 +396,8 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
|
||||
x_br /= 2; y_br /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
LOGLN(" Add weighted layer of the source image to the final Laplacian pyramid layer, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,6 +220,9 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
||||
for (size_t img_idx = 0; img_idx < imgs_.size(); ++img_idx)
|
||||
{
|
||||
LOGLN("Compositing image #" << indices_[img_idx] + 1);
|
||||
#if ENABLE_LOG
|
||||
int64 compositing_t = getTickCount();
|
||||
#endif
|
||||
|
||||
// Read image and resize it if necessary
|
||||
full_img = imgs_[img_idx];
|
||||
@ -261,25 +264,48 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
||||
}
|
||||
}
|
||||
if (std::abs(compose_scale - 1) > 1e-1)
|
||||
{
|
||||
#if ENABLE_LOG
|
||||
int64 resize_t = getTickCount();
|
||||
#endif
|
||||
resize(full_img, img, Size(), compose_scale, compose_scale);
|
||||
LOGLN(" resize time: " << ((getTickCount() - resize_t) / getTickFrequency()) << " sec");
|
||||
}
|
||||
else
|
||||
img = full_img;
|
||||
full_img.release();
|
||||
Size img_size = img.size();
|
||||
|
||||
LOGLN(" after resize time: " << ((getTickCount() - compositing_t) / getTickFrequency()) << " sec");
|
||||
|
||||
Mat K;
|
||||
cameras_[img_idx].K().convertTo(K, CV_32F);
|
||||
|
||||
#if ENABLE_LOG
|
||||
int64 pt = getTickCount();
|
||||
#endif
|
||||
// Warp the current image
|
||||
w->warp(img, K, cameras_[img_idx].R, INTER_LINEAR, BORDER_CONSTANT, img_warped);
|
||||
LOGLN(" warp the current image: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
pt = getTickCount();
|
||||
#endif
|
||||
|
||||
// Warp the current image mask
|
||||
mask.create(img_size, CV_8U);
|
||||
mask.setTo(Scalar::all(255));
|
||||
w->warp(mask, K, cameras_[img_idx].R, INTER_NEAREST, BORDER_CONSTANT, mask_warped);
|
||||
LOGLN(" warp the current image mask: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
pt = getTickCount();
|
||||
#endif
|
||||
|
||||
// Compensate exposure
|
||||
exposure_comp_->apply((int)img_idx, corners[img_idx], img_warped, mask_warped);
|
||||
LOGLN(" compensate exposure: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
pt = getTickCount();
|
||||
#endif
|
||||
|
||||
img_warped.convertTo(img_warped_s, CV_16S);
|
||||
img_warped.release();
|
||||
@ -292,18 +318,35 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra
|
||||
|
||||
bitwise_and(seam_mask, mask_warped, mask_warped);
|
||||
|
||||
LOGLN(" other: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||
#if ENABLE_LOG
|
||||
pt = getTickCount();
|
||||
#endif
|
||||
|
||||
if (!is_blender_prepared)
|
||||
{
|
||||
blender_->prepare(corners, sizes);
|
||||
is_blender_prepared = true;
|
||||
}
|
||||
|
||||
LOGLN(" other2: " << ((getTickCount() - pt) / getTickFrequency()) << " sec");
|
||||
|
||||
LOGLN(" feed...");
|
||||
#if ENABLE_LOG
|
||||
int64 feed_t = getTickCount();
|
||||
#endif
|
||||
// Blend the current image
|
||||
blender_->feed(img_warped_s, mask_warped, corners[img_idx]);
|
||||
LOGLN(" feed time: " << ((getTickCount() - feed_t) / getTickFrequency()) << " sec");
|
||||
LOGLN("Compositing ## time: " << ((getTickCount() - compositing_t) / getTickFrequency()) << " sec");
|
||||
}
|
||||
|
||||
#if ENABLE_LOG
|
||||
int64 blend_t = getTickCount();
|
||||
#endif
|
||||
UMat result, result_mask;
|
||||
blender_->blend(result, result_mask);
|
||||
LOGLN("blend time: " << ((getTickCount() - blend_t) / getTickFrequency()) << " sec");
|
||||
|
||||
LOGLN("Compositing, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user